Commit 1741fece authored by Carl Eugen Hoyos's avatar Carl Eugen Hoyos

Only test the first frame for missing aac_adtstoasc bistream filter.

Many players ignore broken aac frames, so don't abort mov or flv
muxing when encountering one, just print a warning instead.

Fixes ticket #2380.
parent 8af593dd
...@@ -493,11 +493,14 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -493,11 +493,14 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
return ret; return ret;
} else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && } else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
(AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
if (!s->streams[pkt->stream_index]->nb_frames) {
av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: " av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: "
"use audio bitstream filter 'aac_adtstoasc' to fix it " "use audio bitstream filter 'aac_adtstoasc' to fix it "
"('-bsf:a aac_adtstoasc' option with ffmpeg)\n"); "('-bsf:a aac_adtstoasc' option with ffmpeg)\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
av_log(s, AV_LOG_WARNING, "aac bitstream error\n");
}
if (flv->delay == AV_NOPTS_VALUE) if (flv->delay == AV_NOPTS_VALUE)
flv->delay = -pkt->dts; flv->delay = -pkt->dts;
......
...@@ -3185,8 +3185,11 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -3185,8 +3185,11 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
} }
} else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && } else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
(AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
if (!s->streams[pkt->stream_index]->nb_frames) {
av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n"); av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n");
return -1; return -1;
}
av_log(s, AV_LOG_WARNING, "aac bitstream error\n");
} else { } else {
avio_write(pb, pkt->data, size); avio_write(pb, pkt->data, size);
} }
......
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