[Libav-user] setting up x264

Kalileo kalileo at universalx.net
Thu Mar 28 03:32:05 CET 2013


On Mar 28, 2013, at 01:20 , Thomas Sharpless wrote:

> I know the interface between libavcodec and libx264 is such that you can pass at least some of the native x264 option strings, such as preset names, through the opts argument to avcodec_open2().  However it also appears that this is not enough to put the codec into a usable state.  
> 
> Is it spelled out anywhere just what has to be set in the libavcodec contexts, and what can be set up with x264 options?
> 
> Thanks
> 
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user



Hi Thomas and all,

I found that you need to run avformat_find_stream_info to completely set up the codec, unfortunately. 

If you work with known / self produced streams (as I do), you should know all settings, and you should be able to manually set all required settings.

Unfortunately I did not mange yet to get it to work reliably without avformat_find_stream_info, despite going through the avformat_find_stream_info code looking for clues. 

Please see my attached question posted here earlier (which also contains some av_dict_set() examples which might help you) which I think asks the same question as you do just in other words.


> From: Kalileo 
> Subject: avformat_open_input using custom AVDictionary to set video_size
> Date: January 24, 2013 04:35:58 GMT+07:00
> To: "ffmpeg libav-user" <libav-user at ffmpeg.org>
> 
> 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