[FFmpeg-devel] [PATCH 2/4] lavf/segment: Mark output contexts as non-seekable

Rodger Combs rodger.combs at gmail.com
Sun Mar 29 03:25:19 CEST 2015


This prevents sub-muxers from trying to seek back to the beginning of the
whole stream, only to find themselves overwriting some video data in the
current (often last) segment.
---
 libavformat/segment.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 06bc459..b623bb6 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -236,6 +236,7 @@ static int segment_start(AVFormatContext *s, int write_header)
         av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->filename);
         return err;
     }
+    oc->pb->seekable = 0;
 
     if (oc->oformat->priv_class && oc->priv_data)
         av_opt_set(oc->priv_data, "mpegts_flags", "+resend_headers", 0);
@@ -674,6 +675,7 @@ static int seg_write_header(AVFormatContext *s)
             av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->filename);
             goto fail;
         }
+        oc->pb->seekable = 0;
     } else {
         if ((ret = open_null_ctx(&oc->pb)) < 0)
             goto fail;
@@ -709,6 +711,7 @@ static int seg_write_header(AVFormatContext *s)
         if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
                               &s->interrupt_callback, NULL)) < 0)
             goto fail;
+        oc->pb->seekable = 0;
     }
 
 fail:
-- 
2.3.4



More information about the ffmpeg-devel mailing list