[FFmpeg-cvslog] flvenc: Correctly encode data stream into in-band metadata frames.

Joseph Wecker git at videolan.org
Wed Sep 7 02:50:15 CEST 2011


ffmpeg | branch: master | Joseph Wecker <jwecker at justin.tv> | Fri Aug 26 17:42:22 2011 -0700| [4ee53d7e8689095194ee74ad20d3cb0f02144eeb] | committer: Michael Niedermayer

flvenc: Correctly encode data stream into in-band metadata frames.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ee53d7e8689095194ee74ad20d3cb0f02144eeb
---

 libavformat/flvenc.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index d790a12..13a5a0f 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -198,7 +198,7 @@ static int flv_write_header(AVFormatContext *s)
                 av_log(enc, AV_LOG_ERROR, "video codec not compatible with flv\n");
                 return -1;
             }
-        } else {
+        } else if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
             audio_enc = enc;
             if(get_audio_flags(enc)<0)
                 return -1;
@@ -391,13 +391,18 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
 
         flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
-    } else {
-        assert(enc->codec_type == AVMEDIA_TYPE_AUDIO);
+    } else if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
         flags = get_audio_flags(enc);
 
         assert(size);
 
         avio_w8(pb, FLV_TAG_TYPE_AUDIO);
+    } else {
+        // In-band flv metadata ("scriptdata")
+        assert(enc->codec_type == AVMEDIA_TYPE_DATA);
+        avio_w8(pb, FLV_TAG_TYPE_META);
+        flags_size = 0;
+        flags = NULL;
     }
 
     if (enc->codec_id == CODEC_ID_H264 || enc->codec_id == CODEC_ID_MPEG4) {
@@ -423,7 +428,10 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
     avio_wb24(pb,ts);
     avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_
     avio_wb24(pb,flv->reserved);
-    avio_w8(pb,flags);
+
+    if(flags_size)
+        avio_w8(pb,flags);
+
     if (enc->codec_id == CODEC_ID_VP6)
         avio_w8(pb,0);
     if (enc->codec_id == CODEC_ID_VP6F)



More information about the ffmpeg-cvslog mailing list