summaryrefslogtreecommitdiffstats
path: root/demux/demux_lavf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-07-09 12:29:22 +0200
committerwm4 <wm4@nowhere>2020-07-09 12:29:22 +0200
commit06033df715b433d41b1a0855cf7805ff8f66d664 (patch)
tree6ecca1a978736238cc05db57643aea1d95cce1dd /demux/demux_lavf.c
parentadbd28b1dbe256dda82a6154b0ba2cf118c742d5 (diff)
downloadmpv-06033df715b433d41b1a0855cf7805ff8f66d664.tar.bz2
mpv-06033df715b433d41b1a0855cf7805ff8f66d664.tar.xz
demux_lavf: workaround reading gif from unseekable streams
FFmpeg, being the pile of trash as usual, recently broke this. Add our own trash hack to trashily workaround this shit. Fixes: #7893
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r--demux/demux_lavf.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 50b9e044e4..e3ebcbfdc6 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -148,6 +148,7 @@ struct format_hack {
bool no_seek : 1;
bool no_pcm_seek : 1;
bool no_seek_on_no_duration : 1;
+ bool readall_on_no_streamseek : 1;
};
#define BLACKLIST(fmt) {fmt, .ignore = true}
@@ -186,6 +187,10 @@ static const struct format_hack format_hacks[] = {
// reset timestamps, which causes all sorts of problems.
{"ogg", .linearize_audio_ts = true, .use_stream_ids = true},
+ // At some point, FFmpeg lost the ability to read gif from unseekable
+ // streams.
+ {"gif", .readall_on_no_streamseek = true},
+
TEXTSUB("aqtitle"), TEXTSUB("jacosub"), TEXTSUB("microdvd"),
TEXTSUB("mpl2"), TEXTSUB("mpsub"), TEXTSUB("pjs"), TEXTSUB("realtext"),
TEXTSUB("sami"), TEXTSUB("srt"), TEXTSUB("stl"), TEXTSUB("subviewer"),
@@ -1020,6 +1025,20 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
return -1;
}
+ if (priv->format_hack.readall_on_no_streamseek && priv->pb &&
+ !priv->pb->seekable)
+ {
+ MP_VERBOSE(demuxer, "Non-seekable demuxer pre-read hack...\n");
+ // Read incremental to avoid unnecessary large buffer sizes.
+ int r = 0;
+ for (int n = 16; n < 29; n++) {
+ r = stream_peek(priv->stream, 1 << n);
+ if (r < (1 << n))
+ break;
+ }
+ MP_VERBOSE(demuxer, "...did read %d bytes.\n", r);
+ }
+
if (avformat_open_input(&avfc, priv->filename, priv->avif, &dopts) < 0) {
MP_ERR(demuxer, "avformat_open_input() failed\n");
av_dict_free(&dopts);