[FFmpeg-devel] [PATCH] doc: fix option setting for encoding example

Nicolas George george at nsup.org
Tue Jan 13 19:33:27 CET 2015


Le quartidi 24 nivôse, an CCXXIII, Michael Bradshaw a écrit :
> In the encoding/decoding example[1], in the video_encode_example()
> function, av_opt_set() is used to set the option "preset" to "slow" (here,
> c is a AVCodecContext*):
> 
>     av_opt_set(c->priv_data, "preset", "slow", 0);
> 
> I presume this is wrong to use priv_data, and instead the codec context
> should be passed. Attached patch passes the codec context instead of
> priv_data.

Did you test both?

As far as I can see, both are wrong, because both forget to check the return
value.

The current code is, IMHO, wrong because it accesses an undocumented, and
therefore for internal use, field in the structure instead of cleanly using
the API.

But I suspect your code is wrong too, because it lacks
AV_OPT_SEARCH_CHILDREN: it will only find options for AVCodecContext, not
options for the private data of the codec.

If the error check was done, it would probably show
AVERROR_OPTION_NOT_FOUND.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150113/9a585152/attachment.asc>


More information about the ffmpeg-devel mailing list