From 36eeeecff665c66a3079f72b3f9469a83d3df79d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 15 Sep 2018 22:37:14 +0200 Subject: demux_lavf: hack-fix EDL mp4 DASH hack I encountered a stream that fails with "Could not demux init fragment.". It turns out this is a regression from the recent change to that code. The assumption was that demux_lavf.c would treat this as concatenated stream - which it does, but not for probing. Doing this transparently is hard without doing it properly. Doing it properly would mean creating some sort of stream_concat (reminiscent of that FFmpeg security bug). I probably don't want to go there, and I think libavformat should just support this directly, so whatever. Hack-fix this with the knowledge that the init segment will always contain the headers. (cherry picked from commit 315004a38a1bf9394507d8ca308da1ce86ca2204) --- demux/demux_lavf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index ee3918318a..8603a6a634 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -430,6 +430,10 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check) int nsize = av_clip(avpd.buf_size * 2, INITIAL_PROBE_SIZE, PROBE_BUF_SIZE); bstr buf = stream_peek(s, nsize); + if (demuxer->params && demuxer->params->init_fragment.len) { + buf = demuxer->params->init_fragment; + buf.len = MPMIN(buf.len, nsize); + } if (buf.len <= avpd.buf_size) final_probe = true; memcpy(avpd.buf, buf.start, buf.len); -- cgit v1.2.3