[Libav-user] Create a muxer without enc_ctx = out_stream->codec
Charles
linux2 at orion15.org
Tue Aug 23 05:46:30 EEST 2016
On 08/22/2016 06:32 PM, Charles wrote:
> I seem to be lost in where the values get copied.
> Want to create a new h.264 file without an input stream to copy from
>
> Steps
> 1 - av_encode_codec = avcodec_find_encoder( codec_id )
> 2 - av_encode_codec_ctx = avcodec_alloc_context3( av_encode_codec )
> av_encode_codec_ctx->width = w_; /// \note multiple of 2
> av_encode_codec_ctx->height = h_; /// \note multiple of 2
> 3 - avcodec_open2( av_encode_codec_ctx, av_encode_codec, &av_dict_opts )
> 4 - avformat_alloc_output_context2( &av_out_fmt_ctx, NULL, (char*)"mp4", fname )
> 5 - video_st = avformat_new_stream( av_out_fmt_ctx, av_encode_codec )
> av_out_fmt_ctx->streams[ 0 ]->codecpar->width = w_;
> av_out_fmt_ctx->streams[ 0 ]->codecpar->height = h_;
> 6 - avcodec_parameters_to_context( av_encode_codec_ctx, av_out_fmt_ctx->streams[ 0 ]->codecpar )
> 7 - avio_open( &av_out_fmt_ctx->pb, fname, AVIO_FLAG_WRITE )
> 8 - avformat_write_header( av_out_fmt_ctx, NULL )
>
> [mp4 @ 0x29b4060] dimensions not set
>
> transcoding.c
> is using enc_ctx = out_stream->codec;
> Which should be the same as av_encode_codec_ctx
>
> What am I missing here?
>
> Thanks
> cco
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
Posted the code at :
https://gist.github.com/LinuxwitChdoCtOr/74c1721dd7688cf1d16509ea2a52d231
Current output:
Output #0, mp4, to 'enc.mp4':
Stream #0:0: Unknown: none (h264_nvenc) ([33][0][0][0] / 0x0021)
[mp4 @ 0x1a08a60] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mp4 @ 0x1a08a60] dimensions not set
More information about the Libav-user
mailing list