[Libav-user] Can't get MPEG4 decoder

Dan Haddix dan6992 at hotmail.com
Thu Nov 9 19:56:36 EET 2017

You don't need to enable codecs explicitly when you build ffmpeg unless you want to exclude everything else. Just do a build without any of the enable/disable flags and it will include most of the codecs and muxers by default.

I think you're a little confused on the terminology.

First off "mov" is part of the "mp4" demuxer. It's a slight variation of mp4 tha was developed by Apple before mp4 existed. It's actually what the mp4 specification was built from.

Secondly the MPEG-4 spec actually contains two video codecs. MPEG-4 part 2 is the older one that Divx and Xvid were based on. MPEG-4 part 10 is H.264 (aka AVC) and is what most people think of these days when you say MPEG-4.

In avlib the MP4 demuxer is "mp4". The MPEG-4 part 2 decoder is "mpeg4", the H.264 decoder is "h264".

A little trick for finding the right name. Look for the code file that you're trying to use, like h264dec.c for H.264 decoder, then scroll all the way to the bottom. There is a little constructor class and one of the variables is the .name which is what you're looking for.

Good luck,

On Nov 9, 2017 at 9:38 AM, <Michael IV<mailto:explomaster at gmail.com>> wrote:

But now I see in vlc that the MPEG4 codec is actually named "mp4v" .So that's the name I have to specificy in --enable-decoder when doing FFMPEG config?

On Thu, Nov 9, 2017 at 7:26 PM, Michael IV <explomaster at gmail.com<mailto:explomaster at gmail.com>> wrote:
And testing the actual codecId of the video stream in the file I am also getting NULL for avcodec_find_decoder:

        ret = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
st = pFormatCtx->streams[ret];
AVCodecContext *dec_ctx = NULL;
AVCodec *dec = NULL;
dec_ctx = st->codec;
dec = avcodec_find_decoder(dec_ctx->codec_id);

   where ec_ctx->codec_id == AV_CODEC_ID_MPEG4

On Thu, Nov 9, 2017 at 7:22 PM, Michael IV <explomaster at gmail.com<mailto:explomaster at gmail.com>> wrote:
Hi, thanks for the input. Now I am confused even more. All  I need is to start demuxing an mp4 file. Those codecs test above is not what I do.
I started to check those because I am getting into trouble in this part:

        pFormatCtx = avformat_alloc_context();  //ok
AVDictionary *d = NULL;
av_dict_set(&d, "protocol_whitelist","file", 0);  //ok
        int ret = avformat_open_input(&pFormatCtx, in_f_name , NULL, &d);  //ok
         avformat_find_stream_info(pFormatCtx, NULL) ///also ok

But once I get to access the codecpar I hit  "access violation reading location:


Because my codecpar is not initialized. That's what I don't understand here.

On Nov 9, 2017 8:14 PM, "Carl Eugen Hoyos" <ceffmpeg at gmail.com<mailto:ceffmpeg at gmail.com>> wrote:

> Am 09.11.2017 um 17:13 schrieb Michael IV <explomaster at gmail.com<mailto:explomaster at gmail.com>>:
> Hi All. What maybe a reason that  avcodec_find_decoder returns NULL ?
> I enabled in my FFMPEG build MOV and h264 demuxer. Configure report clearly
> states that.
> But doing this test:
>          av_register_all();
>        avcodec_register_all();
>          avformat_network_init();
>          AVCodec* h264codc = avcodec_find_decoder_by_name("h264");

This is supposed to work.

>        AVCodec* h264codc1 = avcodec_find_decoder_by_name("MOV");

This is not the name of any decoder, mov is a file format, you will find a demuxer (and a muxer) with that name (I think).

>        AVCodec* h264codc3 = avcodec_find_decoder_by_name("MPEG4");

There is codec "mpeg4" but that's not h264.

>        AVCodec* h264codc4 = avcodec_find_decoder_by_name("MP4");

See above for mov, although the same demuxer handles mov and mp4.

>        AVCodec* h264codc5 = avcodec_find_decoder(AV_CODEC_ID_MPEG4);

Again, this codec exists but it's not h264.

> Only h264codc  returns a valid codec.

> The only thing I didn't do during build config was not to enable libx264.

This only means that you have no h264 encoder.

> May this be the source of the problem? I didn't do that because I just need to demux  mp4 movie and get its elementary stream.

Then you don't care about a decoder, you only need a demuxer (and maybe a parser).

Carl Eugen
Libav-user mailing list
Libav-user at ffmpeg.org<mailto:Libav-user at ffmpeg.org>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20171109/84b90365/attachment.html>

More information about the Libav-user mailing list