[Libav-user] Create a muxer without enc_ctx = out_stream->codec
Charles
linux2 at orion15.org
Tue Aug 23 18:59:43 EEST 2016
Am I even approaching the problem the right way?
I want to create a new output muxer, in my current case a file via AVFormatContext
Using the encoder context (AVCodecContext) I am going to push frames and read packets
Then I want to write those packets to the muxer
If the application layer has to loop over the encoder context with avcodec_send_frame / avcodec_receive_packet
Why does the muxer care about the encoding? Should he only know about the packets?
Without a demuxer how to you get stream data into the muxer?
Thanks
cco
On 08/23/2016 09:47 AM, Nicolas George wrote:
> 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,
More information about the Libav-user
mailing list