[FFmpeg-cvslog] avformat/flvenc: When using "-c:d copy", don' t require a codec for passing the AMF metadata through from input to output.

Jeffrey Wescott git at videolan.org
Tue Sep 30 20:34:47 CEST 2014


ffmpeg | branch: master | Jeffrey Wescott <jeffrey.wescott at gmail.com> | Mon Sep 29 21:06:38 2014 -0700| [07de0db74b56a5cb45039b58b6ff43ea5ffb90bc] | committer: Michael Niedermayer

avformat/flvenc: When using "-c:d copy", don't require a codec for passing the AMF metadata through from input to output.

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

 libavformat/flvenc.c |   32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index febc5e5..1534667 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -248,7 +248,7 @@ static int flv_write_header(AVFormatContext *s)
                        "16-bit big-endian audio in flv is valid but most likely unplayable (hardware dependent); use s16le\n");
             break;
         case AVMEDIA_TYPE_DATA:
-            if (enc->codec_id != AV_CODEC_ID_TEXT) {
+            if (enc->codec_id != AV_CODEC_ID_TEXT && enc->codec_id != AV_CODEC_ID_NONE) {
                 av_log(s, AV_LOG_ERROR, "Data codec '%s' for stream %d is not compatible with FLV\n",
                        avcodec_get_name(enc->codec_id), i);
                 return AVERROR_INVALIDDATA;
@@ -556,18 +556,24 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (enc->codec_type == AVMEDIA_TYPE_DATA) {
         int data_size;
         int64_t metadata_size_pos = avio_tell(pb);
-        avio_w8(pb, AMF_DATA_TYPE_STRING);
-        put_amf_string(pb, "onTextData");
-        avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
-        avio_wb32(pb, 2);
-        put_amf_string(pb, "type");
-        avio_w8(pb, AMF_DATA_TYPE_STRING);
-        put_amf_string(pb, "Text");
-        put_amf_string(pb, "text");
-        avio_w8(pb, AMF_DATA_TYPE_STRING);
-        put_amf_string(pb, pkt->data);
-        put_amf_string(pb, "");
-        avio_w8(pb, AMF_END_OF_OBJECT);
+        if (enc->codec_type == AV_CODEC_ID_TEXT) {
+            // legacy FFmpeg magic?
+            avio_w8(pb, AMF_DATA_TYPE_STRING);
+            put_amf_string(pb, "onTextData");
+            avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
+            avio_wb32(pb, 2);
+            put_amf_string(pb, "type");
+            avio_w8(pb, AMF_DATA_TYPE_STRING);
+            put_amf_string(pb, "Text");
+            put_amf_string(pb, "text");
+            avio_w8(pb, AMF_DATA_TYPE_STRING);
+            put_amf_string(pb, pkt->data);
+            put_amf_string(pb, "");
+            avio_w8(pb, AMF_END_OF_OBJECT);
+        } else {
+            // just pass the metadata through
+            avio_write(pb, data ? data : pkt->data, size);
+        }
         /* write total size of tag */
         data_size = avio_tell(pb) - metadata_size_pos;
         avio_seek(pb, metadata_size_pos - 10, SEEK_SET);



More information about the ffmpeg-cvslog mailing list