[FFmpeg-devel] [PATCH]: examples/transcode_aac.c - Do not use global pts for frame pts counting

James Almer jamrial at gmail.com
Tue May 11 17:57:50 EEST 2021


On 5/11/2021 10:53 AM, Nicolas George wrote:
> Ray (12021-05-11):
>> The example transcode_aac.c uses a global pts for counting.  For
>> libavcodec novices this can cause them to overlook this and result
>> with incorrect "start" times of output files if called multiple times
>> (see user error resulting in bug report
>> https://trac.ffmpeg.org/ticket/9228)
> 
> I think it is a bad idea, it makes the example more complex, and only
> fix a very particular issue for people who know it already.
> 
> Regards,

An alternative solution is introducing a struct containing all variables 
used by the process, including {input,output}_format_context, 
{input,output}_codec_context, resample_context, fifo, and pts, which 
will simplify the code a lot by making every function in the example 
take a single argument for all of them, so that should address your 
concerns about making the example more complex.

Our library usage examples should not result in people making mistakes 
like this when used as reference, so removing this global variable is a 
good idea.


More information about the ffmpeg-devel mailing list