[Libav-user] Idiomatic way to set encoding codec options for a stream

GRANGER Nicolas nicolas.granger at cea.fr
Thu Feb 13 15:06:32 EET 2020


Thank you for the quick reply.

If I understand correctly, the AVCodecContext is instantiated separately from the FormatContext and Streams.
So what I have to do is:

1- Instanciate the codec context and configure it as you suggested
2- Instanciate an AVFormatContext
3- Add a stream without codec using avformat_new_stream(fmt_ctx, NULL)
4- set stream id and update codecpar using avcodec_parameters_from_context
5- generate the format header with avformat_write_header
6- proceed to the frame encoding loop

right?

Le jeudi 13 février 2020 à 11:07 +0100, Strahinja Radman a écrit :
I need to encode images into an mkv container file using the h264
codec. I would like to set codec-specific options such as '-crf'
but I don't know how to do it. So far I have found/considered several
ways:


Before you call avcodec_open2 set the property by calling the

     av_opt_set_double(enc_ctx->priv_data, "crf", 23.0, 0);

Some of the options need to be set on the "priv_data", ones that are
codec related, others can be set directly to the enc_ctx

     av_opt_set_int(enc_ctx, "sc_threshold", 1, 0);


_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org<mailto:Libav-user at ffmpeg.org>
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-request at ffmpeg.org<mailto:libav-user-request at ffmpeg.org> with subject "unsubscribe".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200213/8178d2d2/attachment.html>


More information about the Libav-user mailing list