We are currently trying to upgrade the ffmpeg version that our program uses. The jump is big because what we have used so far is ffmpeg 0.8, and latest version is 1.2.
In these tests I am using the (let me say) amazing packages I find here.
As first thing, I tried to download and build against ffmpeg 1.2, and of course I got a lot of warnings and errors, about function and variables deprecated or not existing any more.
To smooth the transition, I tried then to build against ffmpeg 1.0, the closest higher version with respect to 0.8. I got a list of warnings and errors that I list here below.
My question is the following: Does it exist any guide to help in these transition, to convert old ffmpeg paradigms/functions calls in the new version? Since we are speaking about a lot of code that I did not write and that I would like not to analyse line by line, I would be very happy if it would be possibly to do a one-to-one conversion of old functions calls to new functions calls, same for variables.
Here is the list of warnings and errors (I have cleaned it so there is only one entry per error/warning)
warning: 'AVStream* av_new_stream(AVFormatContext*, int)' is deprecated (declared at /ffmpeg/include/libavformat/avformat.h:1646) [-Wdeprecated-declarations]
warning: 'int avcodec_open(AVCodecContext*, AVCodec*)' is deprecated (declared at /ffmpeg/include/libavcodec/avcodec.h:3569) [-Wdeprecated-declarations]
error: 'avcodec_init' was not declared in this scope
warning: 'int avcodec_encode_video(AVCodecContext*, uint8_t*, int, const AVFrame*)' is deprecated (declared at /ffmpeg/include/libavcodec/avcodec.h:4272) [-Wdeprecated-declarations]
warning: 'AVCodecContext* avcodec_alloc_context()' is deprecated (declared at /ffmpeg/include/libavcodec/avcodec.h:3423) [-Wdeprecated-declarations]
warning: 'int avcodec_decode_audio3(AVCodecContext*, int16_t*, int*, AVPacket*)' is deprecated (declared at /ffmpeg/include/libavcodec/avcodec.h:3852) [-Wdeprecated-declarations]
warning: 'void av_close_input_file(AVFormatContext*)' is deprecated (declared at /ffmpeg/include/libavformat/avformat.h:1622) [-Wdeprecated-declarations]
error: 'av_open_input_file' was not declared in this scope
warning: 'int av_find_stream_info(AVFormatContext*)' is deprecated (declared at /ffmpeg/include/libavformat/avformat.h:1446) [-Wdeprecated-declarations]
error: 'av_set_parameters' was not declared in this scope
error: 'AVFormatContext' has no member named 'file_size'
error: 'URL_WRONLY' was not declared in this scope
error: 'url_fopen' was not declared in this scope
error: 'url_fclose' was not declared in this scope
error: 'SAMPLE_FMT_U8' was not declared in this scope
error: 'SAMPLE_FMT_S16' was not declared in this scope
error: 'SAMPLE_FMT_S32' was not declared in this scope
error: 'SAMPLE_FMT_FLT' was not declared in this scope
error: 'FF_I_TYPE' was not declared in this scope
Edit:
I am taking a look at these...
http://ffmpeg.org/doxygen/0.8/deprecated.html
http://ffmpeg.org/doxygen/0.9/deprecated.html
http://ffmpeg.org/doxygen/1.0/deprecated.html
http://ffmpeg.org/doxygen/1.1/deprecated.html
http://ffmpeg.org/doxygen/1.2/deprecated.html
http://ffmpeg.org/doxygen/trunk/deprecated.html
Take a look here.
URL_WRONLY -> AVIO_FLAG_WRITE
url_fopen -> avio_open
url_fclose -> avio_close
Hope the above is enough to get you started.
In case the link doesn't survive, here is the full text transcript:
I found some resources about how to port old code (here, here and here), but since it wasn't what I needed I decided to write my own version. So, here we go.
url_open()
This function has been changed to avio_open. There is also url_close which is renamed to avio_close. This information I found here.
av_new_stream()
This function is still supported as of FFMPEG 1.0.1 but it is marked as deprecated. It will be replaced with avformat_new_stream(). Suppose that the old code was:
AVStream *st = av_new_stream(oc, i);
the modified code should be:
AVStream *st = avformat_new_stream(oc, NULL); st->id = i
Be careful to check first that st isn't NULL!
dump_format()
This function was renamed to av_dump_format().
av_write_header()
Replaced with avformat_write_header() that accepts two arguments instead of one. Pass NULL as the second argument to get identical behavior to the old function.
av_codec_open()
This one is replaced with av_codec_open2(). The replacement function accepts three arguments instead of two, but put NULL as a third argument to get the same behavior as the old function.
avcodec_encode_audio()
Replaced with avcodec_encode_audio2().
av_set_parameters()
I couldn't fine the replacement for this one. First, I've found that this function doesn't have replacement. But it was when it was still available in FFMPEG, even though deprecated. Then, they removed it, and thus it has to have replacement. In certain places I found that they only disabled it, on others that its parameters have to be passed to avformat_write_header. In the end, I gave up because I didn't need working version of that part of the code for now. Since in my case avformat_alloc_context() is called and then av_set_parameters(), last what I looked at was to call avformat_alloc_output_context2() instead of avformat_alloc_context(). But the change is not trivial so I skipped it.
SampleFormat
This enum has been renamed AVSampleFormat.
URL_WRONLY
This constant has been replaced with AVIO_FLAG_WRITE.
SAMPLE_FMT_U8, SAMPLE_FMT_S16, SAMPLE_FMT_S32, etc.
Those are prefixed now with AV_, so use AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, etc.
As Gabi points out, that URL has most of the replacements of the deprecated constants.
However, it lacks a few of them, so I'll post all the changes that your output indicates are necessary to get through this compilation step:
avcodec_init -> avcodec_register_all
av_open_input_file -> avformat_open_input
It's probably worth noting here that av_set_parameters was deprecated and completely scrapped, so you should specify parameters in the call to avformat_open_input now.
AVFormatContext.file_size -> avio_size()
URL_WRONLY -> AVIO_FLAG_WRITE
url_fopen -> avio_open
url_fclose -> avio_close
SAMPLE_FMT_U8 -> AV_SAMPLE_FMT_U8
SAMPLE_FMT_S16 -> AV_SAMPLE_FMT_S16
SAMPLE_FMT_S32 -> AV_SAMPLE_FMT_S32
SAMPLE_FMT_FLT -> AV_SAMPLE_FMT_FLT
FF_I_TYPE -> AV_PICTURE_TYPE_I
That should cover all of your actual errors. If there's just a warning, then take some time to figure out what they're phasing in!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With