[FFmpeg-cvslog] smoothstreamingenc: Don't assume streams start from timestamp 0

Martin Storsjö git at videolan.org
Thu Oct 25 13:26:34 CEST 2012


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Oct 24 01:05:12 2012 +0300| [c44cef978bd5c2692606a7a4ef4a7da393147ab0] | committer: Martin Storsjö

smoothstreamingenc: Don't assume streams start from timestamp 0

Also use dts instead of pts for deciding where to split fragments.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c44cef978bd5c2692606a7a4ef4a7da393147ab0
---

 libavformat/smoothstreamingenc.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 69d555f..1ed675a 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -559,12 +559,15 @@ static int ism_write_packet(AVFormatContext *s, AVPacket *pkt)
     SmoothStreamingContext *c = s->priv_data;
     AVStream *st = s->streams[pkt->stream_index];
     OutputStream *os = &c->streams[pkt->stream_index];
-    int64_t end_pts = (c->nb_fragments + 1) * c->min_frag_duration;
+    int64_t end_dts = (c->nb_fragments + 1) * c->min_frag_duration;
     int ret;
 
+    if (st->first_dts == AV_NOPTS_VALUE)
+        st->first_dts = pkt->dts;
+
     if ((!c->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
-        av_compare_ts(pkt->pts, st->time_base,
-                      end_pts, AV_TIME_BASE_Q) >= 0 &&
+        av_compare_ts(pkt->dts - st->first_dts, st->time_base,
+                      end_dts, AV_TIME_BASE_Q) >= 0 &&
         pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) {
 
         if ((ret = ism_flush(s, 0)) < 0)



More information about the ffmpeg-cvslog mailing list