[FFmpeg-cvslog] examples/muxing: honour distinction between encoder PTS timebase and stream timebase
Stefano Sabatini
git at videolan.org
Thu Jan 9 10:55:37 CET 2014
ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Tue Jan 7 13:03:39 2014 +0100| [80bca6eabe8acd3bc6ab2d4257cc5d9bbcbe8a79] | committer: Stefano Sabatini
examples/muxing: honour distinction between encoder PTS timebase and stream timebase
Fix PTS set on the frame when encoding, which must be specified in the
encoder timebase or this will confuse the encoder.
When muxing the packet, the PTS/DTS generated by the encoder is then
rescaled to the stream timebase.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=80bca6eabe8acd3bc6ab2d4257cc5d9bbcbe8a79
---
doc/examples/muxing.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c
index 4cf72e5..5aeabc1 100644
--- a/doc/examples/muxing.c
+++ b/doc/examples/muxing.c
@@ -427,6 +427,10 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
/* If size is zero, it means the image was buffered. */
if (!ret && got_packet && pkt.size) {
+ /* rescale output packet timestamp values from codec to stream timebase */
+ pkt.pts = av_rescale_q_rnd(pkt.pts, c->time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
+ pkt.dts = av_rescale_q_rnd(pkt.dts, c->time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
+ pkt.duration = av_rescale_q(pkt.duration, c->time_base, st->time_base);
pkt.stream_index = st->index;
/* Write the compressed frame to the media file. */
@@ -545,7 +549,7 @@ int main(int argc, char **argv)
write_audio_frame(oc, audio_st);
} else {
write_video_frame(oc, video_st);
- frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base);
+ frame->pts++;
}
}
More information about the ffmpeg-cvslog
mailing list