[Libav-user] Create a muxer without enc_ctx = out_stream->codec
Charles
linux2 at orion15.org
Tue Aug 23 14:39:03 EEST 2016
On 08/23/2016 03:08 AM, Nicolas George wrote:
> Le sextidi 6 fructidor, an CCXXIV, Charles a écrit :
>> 6 - avcodec_parameters_to_context( av_encode_codec_ctx, av_out_fmt_ctx->streams[ 0 ]->codecpar )
>
> You are copying the parameters from a newly created blank stream to an
> initialized encoder. That feels wrong.
>
> Regards,
Thanks for the look, I did some rearranging and I am to the point where the muxer is happy or the encoder is happy but cant get both at the
same time:
Currently Op order:
1) av_encode_codec = avcodec_find_encoder( AV_CODEC_ID_H264 )
2) avformat_alloc_output_context2( &av_out_fmt_ctx, NULL, NULL, f.c_str() )
3) video_st = avformat_new_stream( av_out_fmt_ctx, av_encode_codec )
video_st->id = 0;
video_st->time_base.den = 60; // * 2;
video_st->time_base.num = 1;
// This solved the time_base error
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;
av_dict_set( &av_dict_opts, "b", "2.5M", 0);
av_dict_set( &av_dict_opts, "preset", "losslesshp", 0 );
av_dict_set( &av_dict_opts, "profile", "high", 0 );
av_dict_set( &av_dict_opts, "rc", "vbr_minqp", 0 );
av_dict_set( &av_dict_opts, "gpu", "1", 0 );
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 )
7) avcodec_open2( av_encode_codec_ctx, av_encode_codec, &av_dict_opts )
[mp4 @ 0xc2ed60] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mp4 @ 0xc2ed60] dimensions not set
AVStream does not have dimensions, and the error makes me think its in the ctx but I am setting those dims.
Clearly I am not setting something, just haven't found it.
Thanks
cco
More information about the Libav-user
mailing list