[libav-api] How should I specify options to read raw video?

Anton Khirnov anton at khirnov.net
Thu Dec 15 15:17:51 CET 2011

On Thu, 15 Dec 2011 02:04:59 -0800 (PST), wl2776 <wl2776 at gmail.com> wrote:
> My application decodes video stream, processes it by its own means and saves
> to a file using LibAV functions.
> To save it to a file, it initializes input AVFormatContext with custom
> AVIOContext, then uses usual cycle:
> My problem is that avformat_find_stream_info returns -1 and writes the
> following messages
> I use the following code to initialize AVFormatContext:
> What's wrong with it?

You're passing an empty options dict to avformat_open_input().
Move those av_dict_set() before avformat_open_input() and it should

Also, you're passing the same options dict to both avformat_open_input()
and avformat_find_stream_info(). That's wrong as well, those parameters
have different meanings.

The options parameter passed to avformat_open_input() should contain the
format (container-level) options.

The options parameter passed to avformat_find_stream_info() should
contain an array of codec options for each stream (or NULL if you don't
want to pass options).

Anton Khirnov

More information about the libav-api mailing list