Question

I'm trying to program with ffmpeg for the first time, on Ubuntu. The nonclemature seems a bit messy but that's the same as libavformat, libavcodec, right?

I can compile and run a program which calls avformat_open_input on an mp3 file, apparently successfully, and now I am trying to get some information out of it.

For a start I want to call avcodec_get_name on the audio_codec_id member of AVFormatContext but no function of that name appears in any headers in /usr/include/libav{codec,format,util}.

I checked out the latest ffmpeg from GitHub and diffed avcodec.h against my installed version. The files are clearly much the same but, among other differences, avcodec_get_name(AVCodecID) has been replaced with avcodec_get_class(void) although there doesn't seem to be any correspondence between the two.

Confusingly, this documentation omits avcodec_get_class while this documentation omits avcodec_get_name. Looking at the urls, the former ought to be the latest version, corresponding to what I checked out of GitHub and the latter ought to be outdated, but the reverse seems to be true.

Can someone please tell me

  1. what API documentation should I be using for a) the ubuntu libraries and b) the GitHub latest?
  2. if I build against the latest source, will I have to statically link in order to distribute it?
  3. if I want to dynamically link and build against the provided Ubuntu headers, how do I get the name of a codec given its enum, if avocodec_get_name isn't available?
Was it helpful?

Solution

  1. If you run ffmpeg on your Ubuntu box, you should see the versions of the libraries installed with the package. If the package is sane, it will be a long-term release of ffmpeg (e.g. 1.1.x). You can then locate the documentation for that release by e.g. checking out the corresponding version from the ffmpeg repo. You may also find the documentation included with the tarball here. Note that I'm not sure whether the ffmpeg package included with your version of Ubuntu is the real ffmpeg or the so-called libav fork of ffmpeg. If you don't know about this, now would be a good time to learn. If you don't have real ffmpeg, all bets are off, unfortunately. The libav people could have removed avcodec_get_name() and there's nothing you can do about it. Also note that I just tried compiling my ffmpeg-based application with a very recent (< 2 weeks) old git checkout of ffmpeg and I get no deprecation warnings for my use of avcodec_get_name(). This suggests to me that calling avcodec_get_name() is valid practice with current ffmpeg.

  2. No. You can build shared and distribute the .so dynamic link libraries with your app. Then you only have to distribute the ffmpeg source if you modify it and you don't have to distribute your source. More info. I am not a lawyer, and this is not legal advice.

  3. I believe this is already answered in 1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top