1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

lavf/segment: Mark output contexts as non-seekable when applicable

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.

We only do this when not writing individual header/trailers.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Rodger Combs 2015-03-29 10:57:09 -06:00 committed by Michael Niedermayer
parent 9573737dfb
commit de2aaf1a2a

View File

@ -237,6 +237,8 @@ static int segment_start(AVFormatContext *s, int write_header)
av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->filename); av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->filename);
return err; return err;
} }
if (!seg->individual_header_trailer)
oc->pb->seekable = 0;
if (oc->oformat->priv_class && oc->priv_data) if (oc->oformat->priv_class && oc->priv_data)
av_opt_set(oc->priv_data, "mpegts_flags", "+resend_headers", 0); av_opt_set(oc->priv_data, "mpegts_flags", "+resend_headers", 0);
@ -680,6 +682,8 @@ static int seg_write_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->filename); av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->filename);
goto fail; goto fail;
} }
if (!seg->individual_header_trailer)
oc->pb->seekable = 0;
} else { } else {
if ((ret = open_null_ctx(&oc->pb)) < 0) if ((ret = open_null_ctx(&oc->pb)) < 0)
goto fail; goto fail;
@ -720,6 +724,8 @@ static int seg_write_header(AVFormatContext *s)
if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE, if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0) &s->interrupt_callback, NULL)) < 0)
goto fail; goto fail;
if (!seg->individual_header_trailer)
oc->pb->seekable = 0;
} }
fail: fail: