Search code examples
ffmpeglibavcodeclibavformatlibav

avcodec_find_decoder(CODEC_ID_MPEG2TS) always NULL


I want to decode an incoming MPEG2-Transport Stream and then encode it to h264. Everything works fine with the h264 Codec, but the problem is that libavcodec doesn't seem to recognize the MPEG2-Transportstream. I am basically doing it analogue to the official example:

http://ffmpeg.org/doxygen/trunk/decoding__encoding_8c-source.html

ptrCodec = avcodec_find_decoder(CODEC_ID_MPEG2TS);

ptrCodec is always NULL. Could anybody help me with this?


Solution

  • CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
                                * stream (only used by libavformat) */
    

    CODEC_ID_MPEG2TS is for internal use only.

    I think you are confusing codecs and file formats/containers. libavcodec can encode your video to h264, mpeg2video or mpeg4. If you want to put this video in avi, mpeg or mpeg-ts file you should use libavformat.

    You should look for a different example. In this one video is encoded to h264 and then written to raw file without any containers.