Reduce amount of deprecated symbols used from FFmpeg
This switches some areas of Blender which are related on FFmpeg stuff from deprecated symbols to currently supported one. Pretty straightforward changes based on documentation of FFmpeg's API which symbols should be now used. This should make Blender compatible with recent FFmpeg 0.11. Should be no functional changes.
This commit is contained in:
@@ -162,14 +162,14 @@ void VideoFFmpeg::initParams (short width, short height, float rate, bool image)
|
||||
}
|
||||
|
||||
|
||||
int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams)
|
||||
int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVDictionary **formatParams)
|
||||
{
|
||||
AVFormatContext *formatCtx;
|
||||
AVFormatContext *formatCtx = NULL;
|
||||
int i, videoStream;
|
||||
AVCodec *codec;
|
||||
AVCodecContext *codecCtx;
|
||||
|
||||
if (av_open_input_file(&formatCtx, filename, inputFormat, 0, formatParams)!=0)
|
||||
if (avformat_open_input(&formatCtx, filename, inputFormat, formatParams)!=0)
|
||||
return -1;
|
||||
|
||||
if (av_find_stream_info(formatCtx)<0)
|
||||
@@ -545,11 +545,7 @@ void VideoFFmpeg::openFile (char * filename)
|
||||
// but it is really not desirable to seek on http file, so force streaming.
|
||||
// It would be good to find this information from the context but there are no simple indication
|
||||
!strncmp(filename, "http://", 7) ||
|
||||
#ifdef FFMPEG_PB_IS_POINTER
|
||||
(m_formatCtx->pb && m_formatCtx->pb->is_streamed)
|
||||
#else
|
||||
m_formatCtx->pb.is_streamed
|
||||
#endif
|
||||
(m_formatCtx->pb && !m_formatCtx->pb->seekable)
|
||||
)
|
||||
{
|
||||
// the file is in fact a streaming source, treat as cam to prevent seeking
|
||||
@@ -586,14 +582,12 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
|
||||
{
|
||||
// open camera source
|
||||
AVInputFormat *inputFormat;
|
||||
AVFormatParameters formatParams;
|
||||
AVRational frameRate;
|
||||
AVDictionary *formatParams = NULL;
|
||||
char filename[28], rateStr[20];
|
||||
char *p;
|
||||
|
||||
do_init_ffmpeg();
|
||||
|
||||
memset(&formatParams, 0, sizeof(formatParams));
|
||||
#ifdef WIN32
|
||||
// video capture on windows only through Video For Windows driver
|
||||
inputFormat = av_find_input_format("vfwcap");
|
||||
@@ -623,7 +617,13 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
|
||||
sprintf(filename, "/dev/dv1394/%d", camIdx);
|
||||
} else
|
||||
{
|
||||
inputFormat = av_find_input_format("video4linux");
|
||||
const char *formats[] = {"video4linux2,v4l2", "video4linux2", "video4linux"};
|
||||
int i, formatsCount = sizeof(formats) / sizeof(char*);
|
||||
for (i = 0; i < formatsCount; i++) {
|
||||
inputFormat = av_find_input_format(formats[i]);
|
||||
if (inputFormat)
|
||||
break;
|
||||
}
|
||||
sprintf(filename, "/dev/video%d", camIdx);
|
||||
}
|
||||
if (!inputFormat)
|
||||
@@ -637,20 +637,22 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
|
||||
if ((p = strchr(filename, ':')) != 0)
|
||||
*p = 0;
|
||||
}
|
||||
if (file && (p = strchr(file, ':')) != NULL)
|
||||
formatParams.standard = p+1;
|
||||
if (file && (p = strchr(file, ':')) != NULL) {
|
||||
av_dict_set(&formatParams, "standard", p+1, 0);
|
||||
}
|
||||
#endif
|
||||
//frame rate
|
||||
if (m_captRate <= 0.f)
|
||||
m_captRate = defFrameRate;
|
||||
sprintf(rateStr, "%f", m_captRate);
|
||||
av_parse_video_rate(&frameRate, rateStr);
|
||||
// populate format parameters
|
||||
// need to specify the time base = inverse of rate
|
||||
formatParams.time_base.num = frameRate.den;
|
||||
formatParams.time_base.den = frameRate.num;
|
||||
formatParams.width = m_captWidth;
|
||||
formatParams.height = m_captHeight;
|
||||
|
||||
av_dict_set(&formatParams, "framerate", rateStr, 0);
|
||||
|
||||
if (m_captWidth > 0 && m_captHeight > 0) {
|
||||
char video_size[64];
|
||||
BLI_snprintf(video_size, sizeof(video_size), "%dx%d", m_captWidth, m_captHeight);
|
||||
av_dict_set(&formatParams, "video_size", video_size, 0);
|
||||
}
|
||||
|
||||
if (openStream(filename, inputFormat, &formatParams) != 0)
|
||||
return;
|
||||
@@ -665,6 +667,8 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
|
||||
// no need to thread if the system has a single core
|
||||
m_isThreaded = true;
|
||||
}
|
||||
|
||||
av_dict_free(&formatParams);
|
||||
}
|
||||
|
||||
// play video
|
||||
|
||||
Reference in New Issue
Block a user