summaryrefslogtreecommitdiffstats
path: root/demux/demux_lavf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-01-20 12:56:32 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-22 23:48:27 -0800
commitc88ab96a7865e2fa3a167964ae2eeaefd76f745c (patch)
tree22b090dd4a6148a955de1bfdfd283af8f277b092 /demux/demux_lavf.c
parent70b2be3cf7cececd1c4114f21e80189360643a52 (diff)
downloadmpv-c88ab96a7865e2fa3a167964ae2eeaefd76f745c.tar.bz2
mpv-c88ab96a7865e2fa3a167964ae2eeaefd76f745c.tar.xz
video: warn user against FFmpeg's lies
I found that at least for mjpeg streams, FFmpeg will set packet pts/dts anyway. The mjpeg raw video demuxer (along with some other raw formats) has a "framerate" demuxer option which defaults to 25, so all mjpeg streams will be played at 25 FPS by default. mpv doesn't like this much. If AVFMT_NOTIMESTAMPS is set, it prints a warning, that might print a bogus FPS value for the assumed framerate. The code was originally written with the assumption that FFmpeg would not set pts/dts for such formats, but since it does, the printed estimated framerate will never be used. --fps will also not be used by default in this situation. To make this hopefully less confusing, explicitly state the situation when the AVFMT_NOTIMESTAMPS flag is set, and give instructions how to work it around. Also, remove the warning in dec_video.c. We don't know what FPS it's going to assume anyway. If there are really no timestamps in the stream, it will trigger our normal missing pts workaround. Add the assumed FPS there. In theory, we could just clear packet timestamps if AVFMT_NOTIMESTAMPS is set, and make up our own timestamps. That is non-trivial for advanced video codecs like h264, so I'm not going there. For seeking and buffering estimation the situation thus remains half-broken. This is a mitigation for #5419.
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r--demux/demux_lavf.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 2886780607..467569a42c 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -940,6 +940,19 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
demuxer->duration = duration;
}
+ // In some cases, libavformat will export bogus bullshit timestamps anyway,
+ // such as with mjpeg.
+ if (priv->avif_flags & AVFMT_NOTIMESTAMPS) {
+ MP_WARN(demuxer,
+ "This format is marked by FFmpeg as having no timestamps!\n"
+ "FFmpeg will likely make up its own broken timestamps. For\n"
+ "video streams you can correct this with:\n"
+ " --no-correct-pts --fps=VALUE\n"
+ "with VALUE being the real framerate of the stream. You can\n"
+ "expect seeking and buffering estimation to be generally\n"
+ "broken as well.\n");
+ }
+
return 0;
}