[FFmpeg-devel] [PATCH] avformat/flvenc: add no_metadata to flvflags

Steven Liu lq at chinaffmpeg.org
Mon Nov 21 14:29:36 EET 2016


some flv have no metadata,
ffmpeg will same with the source flv stream.

Signed-off-by: Steven Liu <lingjiujianke at gmail.com>
---
 doc/muxers.texi      |    3 +++
 libavformat/flvenc.c |    8 +++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 806182a..8689341 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -148,6 +148,9 @@ Place AAC sequence header based on audio stream data.
 @item no_sequence_end
 Disable sequence end tag.
 
+ at item no_metadata
+Disable metadata tag.
+
 @item add_keyframe_index
 Used to facilitate seeking; particularly for HTTP pseudo streaming.
 @end table
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 4ca6aea..177052a 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -67,6 +67,7 @@ typedef enum {
     FLV_AAC_SEQ_HEADER_DETECT = (1 << 0),
     FLV_NO_SEQUENCE_END = (1 << 1),
     FLV_ADD_KEYFRAME_INDEX = (1 << 2),
+    FLV_NO_METADATA = (1 << 3),
 } FLVFlags;
 
 typedef struct FLVFileposition {
@@ -744,7 +745,11 @@ static int flv_write_header(AVFormatContext *s)
             flv->reserved = 5;
         }
 
-    write_metadata(s, 0);
+    if (flv->flags & FLV_NO_METADATA) {
+        pb->seekable = 0;
+    } else {
+        write_metadata(s, 0);
+    }
 
     for (i = 0; i < s->nb_streams; i++) {
         flv_write_codec_header(s, s->streams[i]->codecpar);
@@ -1055,6 +1060,7 @@ static const AVOption options[] = {
     { "flvflags", "FLV muxer flags", offsetof(FLVContext, flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
     { "aac_seq_header_detect", "Put AAC sequence header based on stream data", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_AAC_SEQ_HEADER_DETECT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
     { "no_sequence_end", "disable sequence end for FLV", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_NO_SEQUENCE_END}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
+    { "no_metadata", "disable metadata for FLV", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_NO_METADATA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
     { "add_keyframe_index", "Add keyframe index metadata", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_ADD_KEYFRAME_INDEX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
     { NULL },
 };
-- 
1.7.1





More information about the ffmpeg-devel mailing list