diff options
author | Jeffrey Wescott <jeffrey.wescott@gmail.com> | 2014-09-29 21:06:38 -0700 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-09-30 20:27:07 +0200 |
commit | 07de0db74b56a5cb45039b58b6ff43ea5ffb90bc (patch) | |
tree | 5d044422b8381f3b0eb4f454bd67f441821cdf07 | |
parent | cda5d89defaf65eccd890488675dc3d6e7484d27 (diff) | |
download | ffmpeg-07de0db74b56a5cb45039b58b6ff43ea5ffb90bc.tar.gz |
avformat/flvenc: When using "-c:d copy", don't require a codec for passing the AMF metadata through from input to output.
-rw-r--r-- | libavformat/flvenc.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index febc5e5b30..1534667c6d 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); |