summaryrefslogtreecommitdiff
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorVignesh Venkatasubramanian <vigneshv@google.com>2015-03-30 14:46:10 -0700
committerMichael Niedermayer <michaelni@gmx.at>2015-04-07 15:08:59 +0200
commit6fd300ac6c2c3871736ce0e6df95603255004dc6 (patch)
treec158a948981bfa1db551a540c61157d3fe0f417c /libavformat/matroskaenc.c
parentc4b2017ba66e1623da9f527704c61c86a6e74844 (diff)
lavf: Add support for WebM Live Muxing
This patch adds support for WebM Live Muxing by adding a new WebM Chunk muxer. It writes out live WebM Chunks which can be used for playback using Live DASH Clients. Please see muxers.texi for sample usage. Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 5493e3c631..6f55c69043 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -120,6 +120,7 @@ typedef struct MatroskaMuxContext {
int64_t cluster_time_limit;
int is_dash;
int dash_track_number;
+ int is_live;
uint32_t chapter_id_offset;
int wrote_chapters;
@@ -1412,7 +1413,9 @@ static int mkv_write_header(AVFormatContext *s)
// reserve space for the duration
mkv->duration = 0;
mkv->duration_offset = avio_tell(pb);
- put_ebml_void(pb, 11); // assumes double-precision float to be written
+ if (!mkv->is_live) {
+ put_ebml_void(pb, 11); // assumes double-precision float to be written
+ }
end_ebml_master(pb, segment_info);
ret = mkv_write_tracks(s);
@@ -1436,7 +1439,7 @@ static int mkv_write_header(AVFormatContext *s)
return ret;
}
- if (!s->pb->seekable)
+ if (!s->pb->seekable && !mkv->is_live)
mkv_write_seekhead(pb, mkv->main_seekhead);
mkv->cues = mkv_start_cues(mkv->segment_offset);
@@ -1955,7 +1958,9 @@ static int mkv_write_trailer(AVFormatContext *s)
avio_seek(pb, currentpos, SEEK_SET);
}
- end_ebml_master(pb, mkv->segment);
+ if (!mkv->is_live) {
+ end_ebml_master(pb, mkv->segment);
+ }
av_freep(&mkv->tracks);
av_freep(&mkv->cues->entries);
av_freep(&mkv->cues);
@@ -2019,6 +2024,7 @@ static const AVOption options[] = {
{ "cluster_time_limit", "Store at most the provided number of milliseconds in a cluster.", OFFSET(cluster_time_limit), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, FLAGS },
{ "dash", "Create a WebM file conforming to WebM DASH specification", OFFSET(is_dash), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
{ "dash_track_number", "Track number for the DASH stream", OFFSET(dash_track_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 127, FLAGS },
+ { "live", "Write files assuming it is a live stream.", OFFSET(is_live), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
{ "allow_raw_vfw", "allow RAW VFW mode", OFFSET(allow_raw_vfw), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
{ NULL },
};