---
 libavformat/segment.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 30d9190..1c53073 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -41,6 +41,7 @@ typedef struct {
     int  size;             /**< Set by a private option. */
     int64_t offset_time;
     int64_t recording_time;
+    int has_video;
 } SegmentContext;
 
 static int segment_header(AVFormatContext *s)
@@ -90,7 +91,7 @@ static int seg_write_header(AVFormatContext *s)
 {
     SegmentContext *seg = s->priv_data;
     AVFormatContext *oc;
-    int ret;
+    int ret, i;
 
     seg->number = 0;
     seg->offset_time = 0;
@@ -108,6 +109,10 @@ static int seg_write_header(AVFormatContext *s)
             return AVERROR_MUXER_NOT_FOUND;
     }
 
+    for (i = 0; i< s->nb_streams; i++)
+        seg->has_video +=
+            (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO);
+
     oc = avformat_alloc_context();
 
     if (!oc)
@@ -161,7 +166,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket 
*pkt)
     int64_t end_pts = seg->recording_time * seg->number;
     int ret;
 
-    if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+    if ((seg->has_video && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
         av_compare_ts(pkt->pts, st->time_base,
                       end_pts, AV_TIME_BASE_Q) >= 0 &&
         pkt->flags & AV_PKT_FLAG_KEY) {
-- 
1.7.8.rc1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to