<div dir="ltr"><div class="gmail_quote"><div dir="ltr">Hi,<div><br></div><div>It's some days I'm trying to figure how to do transcoding in 3.1.x without triggering warnings for AVStream::codec deprecation.</div><div><br></div><div>The ffmpeg examples and ffmpeg itself still use this deprecated field, I have some code that compiles and run, without using AVStream::codec but it doesn't work well (it seems that the output file is not compressed at all...)</div><div><br></div><div>The problem is the stream creation stage:</div><div><br></div><div>this is how transcoding.c, ffmpeg and most online code do:</div><div><br></div><div><div> out_stream = avformat_new_stream(ofmt_ctx, NULL);</div><div> in_stream = ifmt_ctx->streams[i];<br></div><div> dec_ctx = in_stream->codec;</div><div> enc_ctx = out_stream->codec;</div></div><div><div> encoder = avcodec_find_encoder(CODEC_ID_<wbr>H264);</div></div><div>[copy stuff from dec to enc and set the stuff you want to change]<br></div><div><div> avcodec_open2(enc_ctx, encoder, NULL);</div><div><br></div><div>this is how I think it should be now:</div><div><br></div><div><div> out_stream = avformat_new_stream(ofmt_ctx, NULL);</div><div> in_stream = ifmt_ctx->streams[i];<br></div><div> auto dec_par = in_stream->codecpar, enc_par = out_stream->codecpar;</div></div><div> encoder = avcodec_find_encoder(CODEC_ID_<wbr>H264);</div><div> enc_ctx = avcodec_alloc_context3(<wbr>encoder);<br></div><div>[copy some dec_par to ctx, set the other ctx parameters]</div><div> avcodec_open2(enc_ctx, encoder, NULL);</div><div> avcodec_parameters_from_<wbr>context(enc_par, ctx);<br></div><div><br></div><div>Is this correct?</div><div><br></div><div>Do I have in some way to set the output stream codec to something?</div><div><br></div><div>What do I have to do for streams I simpy want to remux that with the old api are resolved with:</div><div><br></div><div><div> avcodec_copy_context(ofmt_<wbr>ctx->streams[i]->codec,</div><div>                    ifmt_ctx->streams[i]->codec);</div></div><div><br></div><div>?</div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_-7621237516124540453gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div><b>Bye,</b></div></div><div><b> Gabry</b></div></div></div></div></div>
</font></span></div></div>
</div><br></div>