[FFmpeg-devel] [PATCH] examples/muxing: set timestamps in output audio packet
Stefano Sabatini
stefasab at gmail.com
Wed Jan 8 15:45:21 CET 2014
In particular, fix trac ticket #3231.
---
doc/examples/muxing.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c
index 33b2989..cf3e336 100644
--- a/doc/examples/muxing.c
+++ b/doc/examples/muxing.c
@@ -270,6 +270,7 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
}
audio_frame->nb_samples = dst_nb_samples;
+ audio_frame->pts += av_rescale_q(dst_nb_samples, (AVRational){1, c->sample_rate}, c->time_base);
avcodec_fill_audio_frame(audio_frame, c->channels, c->sample_fmt,
dst_samples_data[0], dst_samples_size, 0);
@@ -280,6 +281,13 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
}
pkt.stream_index = st->index;
+ /* rescale output packet timestamp values */
+ if (pkt.pts != AV_NOPTS_VALUE)
+ pkt.pts = av_rescale_q(pkt.pts, c->time_base, st->time_base);
+ if (pkt.dts != AV_NOPTS_VALUE)
+ pkt.dts = av_rescale_q(pkt.dts, c->time_base, st->time_base);
+ if (pkt.duration)
+ pkt.duration = av_rescale_q(pkt.duration, c->time_base, st->time_base);
/* Write the compressed frame to the media file. */
ret = av_interleaved_write_frame(oc, &pkt);
--
1.8.1.2
More information about the ffmpeg-devel
mailing list