[FFmpeg-cvslog] lavf/segment: fix logic for segmenting audio-only inputs

Stefano Sabatini git at videolan.org
Tue Jul 3 23:26:58 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Sat Jan 14 02:40:09 2012 +0100| [a1e092ccd36ef0239749c2267104e7e59ee7176e] | committer: Stefano Sabatini

lavf/segment: fix logic for segmenting audio-only inputs

Also add a comment for clarifying the logic.

Fix trac ticket #1290.

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

 libavformat/segment.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 4902aff..3212826 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -203,7 +203,8 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
     int64_t end_pts = seg->recording_time * seg->number;
     int ret;
 
-    if ((seg->has_video && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
+    /* if the segment has video, start a new segment *only* with a key video frame */
+    if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO || !seg->has_video) &&
         av_compare_ts(pkt->pts, st->time_base,
                       end_pts, AV_TIME_BASE_Q) >= 0 &&
         pkt->flags & AV_PKT_FLAG_KEY) {



More information about the ffmpeg-cvslog mailing list