[Libav-user] avformat_open_input using custom AVDictionary to set video_size

Kalileo kalileo at universalx.net
Thu Jan 24 10:35:58 CET 2013


I'm producing MPEGTS streams (h264/aac) using ffmpeg, so I know exactly how they are coded, and I could modify that if needed.

Now, when I receive them in my own code, I always have to run them through avformat_open_input and avformat_find_stream_info to get the settings into the codec context.

Because udp mpegts streams have no header, both avformat_open_input and avformat_find_stream_info  sometimes have problems to get all settings correctly.

However, all settings are known, and so I try to inform avformat_open_input and avformat_find_stream_info  about them, using a AVDictionary.

However, despite setting the video_size to 720x576, I often get "unspecified size". Other AVDictionary options such as "probesize" are honored though.

Ideally I want to skip the avformat_find_stream_info step completely and preset all settings. But how to do that correctly?

Also sometimes avformat_open_input does not get it correctly that there is a video and an audio stream.
    
I'm reading the stream though a memory buffer, and not directly from a file or url. This is what I tried:

======
 av_dict_set(&format_opts, "video_size", "720x576", 0);    <<== seems to be ignored
 // av_dict_set(&format_opts, "pixel_format", av_get_pix_fmt_name(ffmpeg::PIX_FMT_YUV420P), 0);
 av_dict_set(&format_opts, "pixel_format", "yuv420p", 0);
 av_dict_set(&format_opts, "sample_format", "fltp", 0);
 av_dict_set(&format_opts, "analyzeduration", "8000000", 0);   <<== honored
 av_dict_set(&format_opts, "probesize", "8000000", 0);    <<== honored
 av_dict_set(&format_opts, "channels", "2", 0);
 av_dict_set(&format_opts, "sample_rate", "48000", 0);
 av_dict_set(&format_opts, "seekable", "0", 0);
 ...
 err = avformat_open_input(&pFormatCtx, "", inputFmt, &format_opts);

 => sometimes sees one stream only

 av_dict_set(&format_opts, "video_size", "720x576", 0);   <<== seems to be ignored
 ...
 err = avformat_find_stream_info(pFormatCtx, &format_opts);


 av_dump_format(pFormatCtx, 0, "Memory Buffer", false);

 => often says "unspecified size"
======

I'm using the very latest ffmpeg 1.0.3 from 2 days ago.


My Questions are:

How do I pass the video size to avformat_open_input and avformat_find_stream_info so that it is taken?

Which settings do i have to set to set (and how) to avoid the need for avformat_find_stream_info?

How do i tell avformat_open_input  that there is a video stream and an audio stream, or help it to find them (possible a change in the encoding parameters)?


Thanks for any hints or help!

Regards,
Kalileo



More information about the Libav-user mailing list