diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index c9badaa561..7f6148fa15 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -648,8 +648,6 @@ static int init_output_frame(AVFrame **frame,
return 0;
}
-/* Global timestamp for the audio frames. */
-static int64_t pts = 0;
/**
* Encode one frame worth of audio to the output file.
@@ -663,6 +661,7 @@ static int64_t pts = 0;
static int encode_audio_frame(AVFrame *frame,
AVFormatContext *output_format_context,
AVCodecContext *output_codec_context,
+ int64_t* pts,
int *data_present)
{
/* Packet used for temporary storage. */
@@ -675,8 +674,8 @@ static int encode_audio_frame(AVFrame *frame,
/* Set a timestamp based on the sample rate for the container. */
if (frame) {
- frame->pts = pts;
- pts += frame->nb_samples;
+ frame->pts = *pts;
+ *pts += frame->nb_samples;
}
/* Send the audio frame stored in the temporary packet to the encoder.
@@ -734,7 +733,8 @@ cleanup:
*/
static int load_encode_and_write(AVAudioFifo *fifo,
AVFormatContext *output_format_context,
- AVCodecContext *output_codec_context)
+ AVCodecContext *output_codec_context,
+ int64_t* pts)
{
/* Temporary storage of the output samples of the frame written to the file. */
AVFrame *output_frame;
@@ -759,7 +759,7 @@ static int load_encode_and_write(AVAudioFifo *fifo,
/* Encode one frame worth of audio samples. */
if (encode_audio_frame(output_frame, output_format_context,
- output_codec_context, &data_written)) {
+ output_codec_context, pts, &data_written)) {
av_frame_free(&output_frame);
return AVERROR_EXIT;
}
@@ -790,6 +790,8 @@ int main(int argc, char **argv)
SwrContext *resample_context = NULL;
AVAudioFifo *fifo = NULL;
int ret = AVERROR_EXIT;
+ /* timestamp for the audio frames. */
+ int64_t pts = 0;
if (argc != 3) {
fprintf(stderr, "Usage: %s