Commit 07de0db7 authored by Jeffrey Wescott's avatar Jeffrey Wescott Committed by Michael Niedermayer

avformat/flvenc: When using "-c:d copy", don't require a codec for passing the...

avformat/flvenc: When using "-c:d copy", don't require a codec for passing the AMF metadata through from input to output.
parent cda5d89d
...@@ -248,7 +248,7 @@ static int flv_write_header(AVFormatContext *s) ...@@ -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"); "16-bit big-endian audio in flv is valid but most likely unplayable (hardware dependent); use s16le\n");
break; break;
case AVMEDIA_TYPE_DATA: 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", 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); avcodec_get_name(enc->codec_id), i);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -556,18 +556,24 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -556,18 +556,24 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
if (enc->codec_type == AVMEDIA_TYPE_DATA) { if (enc->codec_type == AVMEDIA_TYPE_DATA) {
int data_size; int data_size;
int64_t metadata_size_pos = avio_tell(pb); int64_t metadata_size_pos = avio_tell(pb);
avio_w8(pb, AMF_DATA_TYPE_STRING); if (enc->codec_type == AV_CODEC_ID_TEXT) {
put_amf_string(pb, "onTextData"); // legacy FFmpeg magic?
avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY); avio_w8(pb, AMF_DATA_TYPE_STRING);
avio_wb32(pb, 2); put_amf_string(pb, "onTextData");
put_amf_string(pb, "type"); avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
avio_w8(pb, AMF_DATA_TYPE_STRING); avio_wb32(pb, 2);
put_amf_string(pb, "Text"); put_amf_string(pb, "type");
put_amf_string(pb, "text"); avio_w8(pb, AMF_DATA_TYPE_STRING);
avio_w8(pb, AMF_DATA_TYPE_STRING); put_amf_string(pb, "Text");
put_amf_string(pb, pkt->data); put_amf_string(pb, "text");
put_amf_string(pb, ""); avio_w8(pb, AMF_DATA_TYPE_STRING);
avio_w8(pb, AMF_END_OF_OBJECT); 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 */ /* write total size of tag */
data_size = avio_tell(pb) - metadata_size_pos; data_size = avio_tell(pb) - metadata_size_pos;
avio_seek(pb, metadata_size_pos - 10, SEEK_SET); avio_seek(pb, metadata_size_pos - 10, SEEK_SET);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment