[Libav-user] Create a muxer without enc_ctx = out_stream->codec

Nicolas George george at nsup.org
Tue Aug 23 17:47:54 EEST 2016


Le septidi 7 fructidor, an CCXXIV, Charles a écrit :
> 4) parameters = video_st->codecpar;
>    parameters->codec_tag = tag;
>    parameters->format    = AV_PIX_FMT_YUV420P;
>    parameters->bit_rate  = 5e6;
>    parameters->width     = 1024;
>    parameters->height    = 768;
>    parameters->bit_rate  = 5e6;

You are not supposed to fill the stream's parameters with random values, you
are supposed to fill them with the values used by the encoder. These values
will be very similar to the settings you chose for the encoder, but the
encoder is allowed to tweak them.

> 5) av_encode_codec_ctx = avcodec_alloc_context3( av_encode_codec )
>    av_encode_codec_ctx->bit_rate    = 5e6;
>    av_encode_codec_ctx->width       = 1024;   /// \note multiple of 2
>    av_encode_codec_ctx->height      = 768;   /// \note multiple of 2
>    av_encode_codec_ctx->time_base   = (AVRational) { 1, 60 }; //* 2;
>    av_encode_codec_ctx->gop_size    = 15;      // Intra frames per x P frames
>    av_encode_codec_ctx->pix_fmt     = AV_PIX_FMT_YUV420P; // MUST DO NOT CHANGE nvenc required
>    // This appears to make h264_nvenc happy
> 6) avcodec_parameters_to_context( av_encode_codec_ctx, parameters )

You are still overwriting the parameters of the encoder. It can not work.
The parameters are used for communication from demuxers to decoders and from
encoders to muxers. They are output from the decoders and you are using them
as input.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160823/2ffbab39/attachment.sig>


More information about the Libav-user mailing list