From beebc121f0f1f4e91415a4c58e7e6a79693c753e Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Sun, 3 May 2020 09:32:45 -0600 Subject: libav: fix remuxing aac from ts to mkv Fixes https://github.com/HandBrake/HandBrake/issues/2809 --- contrib/ffmpeg/A19-matroskaenc-aac-extradata.patch | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 contrib/ffmpeg/A19-matroskaenc-aac-extradata.patch diff --git a/contrib/ffmpeg/A19-matroskaenc-aac-extradata.patch b/contrib/ffmpeg/A19-matroskaenc-aac-extradata.patch new file mode 100644 index 000000000..73a406292 --- /dev/null +++ b/contrib/ffmpeg/A19-matroskaenc-aac-extradata.patch @@ -0,0 +1,36 @@ +From a3fa88bdfd6c9615ea9b9f64caf722fa2292d29a Mon Sep 17 00:00:00 2001 +From: John Stebbins +Date: Sat, 2 May 2020 07:26:29 -0600 +Subject: [PATCH] avformat/matroskaenc: return error if aac extradata changes + +extradata changing would result in an invalid stream. +also, as the code was written, rewriting extradata was corrupting the +track header resulting in an invalid file. + +(cherry picked from commit 805890cddee93ebafcf6db8784315aa3fd6faf81) +--- + libavformat/matroskaenc.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c +index cef504fa05..ea7f81ab94 100644 +--- a/libavformat/matroskaenc.c ++++ b/libavformat/matroskaenc.c +@@ -2283,6 +2283,14 @@ static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt) + if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) { + int filler, output_sample_rate = 0; + int64_t curpos; ++ if (par->extradata && par->extradata_size) ++ if (par->extradata_size != side_data_size || ++ memcmp(par->extradata, side_data, side_data_size)) { ++ av_log(s, AV_LOG_ERROR, "Error, AAC extradata changed mid-stream.\n"); ++ return AVERROR(EINVAL); ++ } else // Already written ++ break; ++ + ret = get_aac_sample_rates(s, side_data, side_data_size, &track->sample_rate, + &output_sample_rate); + if (ret < 0) +-- +2.25.4 + -- cgit v1.2.3