[Libav-user] How to use rawvideo conatiner format with mpeg4

Mark Pupilli mpupilli at gmail.com
Sat Oct 27 16:06:02 CEST 2012

I am having problems sending mpeg4 (FMP4) in the the rawvideo
container format. I am setting up the muxer as follows:

    m_outputFormat = av_guess_format( "rawvideo", 0, 0 );
    m_formatContext->oformat = m_outputFormat;

    // ... then later:

    int err = avio_open( &m_formatContext->pb,
m_formatContext->filename, AVIO_FLAG_WRITE );
    avformat_write_header( m_formatContext, 0 );

(I am using custom IO - which works for me when using avi as the
container format).

The problem appears when demuxing which I do as follows:

    AVInputFormat* inputFormat = av_find_input_format( "rawvideo" );
    AVDictionary *options = 0;
    av_dict_set( &options, "video_size", "320x240", 0 );
    av_dict_set( &options, "pixel_format", "yuv420p", 0 );

    m_open = ( avformat_open_input( &m_formatContext, streamName,
inputFormat, &options ) >= 0 );


    if ( m_open == false )

    int foundStreamInfo = avformat_find_stream_info( m_formatContext, 0 );

    if ( foundStreamInfo == -1)
        m_open = false;

This results in an incorrect detection of a rawvideo bytestream
instead of mpeg4:

[rawvideo @ 0x1303140] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'puppypc':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p,
320x240, 25 tbr, 25 tbn, 25 tbc

As you can see it has correctly determined the container format, but
not the codec. Is there a dictionary option to force the codec to
mpeg4? I tried "codec", and "video_codec", but I can't find where
valid options are documented.


More information about the Libav-user mailing list