[Libav-user] Using av_dict_set to set options

Joel Ng blood_elves88 at yahoo.com.sg
Tue Nov 29 07:51:42 EET 2016



On 29/11/2016 2:53 AM, Carl Eugen Hoyos wrote:
> 2016-11-28 3:16 GMT+01:00 Joel Ng <blood_elves88-at-yahoo.com.sg at ffmpeg.org>:
>> Hello, I have several questions about using av_dict_set(AVDictionary **pm,
>> const char *key, const char *value, int flags) to set the options for input
>> and output videos.
>>
>> I am trying to translate several options from the FFmpeg binary usage to the
>> libav-api, and I have trouble with some of them.
>>
>> 1. If I have multiple options to set (e.g. "-preset ultrafast", and "-tune
>> zerolatency"), do I just use av_dict_set repeatedly, one after the other?
> Yes.
>
>> Will they overwrite each other?
> One "preset" will (hopefully) overwrite another "preset".
>
>> I believe they do, since the documentation
>> says "Set the given entry in *pm, overwriting an existing entry."
> ... with the same name.
>
>> How do I add more options then?
>> 2. I used "-re" on FFmpeg. av_dict_set requires a key and value. How do I
>> apply this option?
> This is not an option that you can pass to the library, your calling
> code has to take care that it does not work faster than realtime.
> (Just as ffmpeg.c does)
>
>> 3. How would I translate this to an option:
>> "-x264opts ...
> "x264opts" is an option that takes a string as argument (iirc).
>
> Carl Eugen
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
Thank you. That clarified most of my doubts.

I managed to get the -x264opts working as an option:
av_opt_set(ctx->priv_data, "x264opts", "...stuff...", 0);

I also shifted -preset ultrafast and -tune zerolatency to use 
av_opt_set, and everything works great now. I was probably applying the 
options to the wrong context object.




More information about the Libav-user mailing list