aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-01-19 11:17:13 +0200
committerMartin Storsjö <martin@martin.st>2012-01-27 21:12:41 +0200
commite771e6dd63e837220aa5d959486546d2be972e83 (patch)
tree8911b42bcb162be212461cc6763e966b1b091ad9 /libavformat/movenc.c
parentf53221049933627a31fb4a530c290802715ccf65 (diff)
downloadffmpeg-e771e6dd63e837220aa5d959486546d2be972e83.tar.gz
movenc: Allow writing to a non-seekable output if using empty moov
In this mode, no seeks will be done except for within moov/moof fragments, which should fit within the AVIOContext buffer. This allows pushing live smooth streaming format data to a live publishing point on IIS over http. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8a40345716..22e8d842f4 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2518,6 +2518,7 @@ static int mov_flush_fragment(AVFormatContext *s)
mov->tracks[i].cluster[0].dts;
mov->tracks[i].entry = 0;
}
+ avio_flush(s->pb);
return 0;
}
@@ -2557,6 +2558,7 @@ static int mov_flush_fragment(AVFormatContext *s)
if (write_moof) {
MOVFragmentInfo *info;
+ avio_flush(s->pb);
track->nb_frag_info++;
track->frag_info = av_realloc(track->frag_info,
sizeof(*track->frag_info) *
@@ -2589,6 +2591,7 @@ static int mov_flush_fragment(AVFormatContext *s)
mov->mdat_size = 0;
+ avio_flush(s->pb);
return 0;
}
@@ -2602,7 +2605,9 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
int size= pkt->size;
uint8_t *reformatted_data = NULL;
- if (!s->pb->seekable) return 0; /* Can't handle that */
+ if (!s->pb->seekable && !(mov->flags & FF_MOV_FLAG_EMPTY_MOOV))
+ return 0; /* Can't handle that */
+
if (!size) return 0; /* Discard 0 sized packets */
if ((mov->max_fragment_duration && trk->entry &&
@@ -2782,7 +2787,13 @@ static int mov_write_header(AVFormatContext *s)
AVDictionaryEntry *t;
int i, hint_track = 0;
- if (!s->pb->seekable) {
+ /* Non-seekable output is ok if EMPTY_MOOV is set, or if using the ismv
+ * format (which sets EMPTY_MOOV later in this function). If ism_lookahead
+ * is enabled, we don't support non-seekable output at all. */
+ if (!s->pb->seekable &&
+ ((!(mov->flags & FF_MOV_FLAG_EMPTY_MOOV) &&
+ !(s->oformat && !strcmp(s->oformat->name, "ismv")))
+ || mov->ism_lookahead)) {
av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n");
return -1;
}