diff options
author | wm4 <wm4@nowhere> | 2013-11-28 15:10:45 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-28 15:20:33 +0100 |
commit | dc0b2046cdeb0bbf78e7012d9eafa29a2888b1ec (patch) | |
tree | e8fdb97e22f2ef067ded7f53a9b21153432b998e /demux/demux_lavf.c | |
parent | d9b5dedfe95dc9b24e6c59c33044396187918bc2 (diff) | |
download | mpv-dc0b2046cdeb0bbf78e7012d9eafa29a2888b1ec.tar.bz2 mpv-dc0b2046cdeb0bbf78e7012d9eafa29a2888b1ec.tar.xz |
video: add insane hack to work around FFmpeg/Libav insanity
So, FFmpeg/Libav requires us to figure out video timestamps ourselves
(see last 10 commits or so), but the methods it provides for this aren't
even sufficient. In particular, everything that uses AVI-style DTS (avi,
vfw-muxed mkv, possibly mpeg4-in-ogm) with a codec that has an internal
frame delay is broken. In this case, libavcodec will shift the packet-
to-image correspondence by the codec delay, meaning that with a delay=1,
the first AVFrame.pkt_dts is not 0, but that of the second packet. All
timestamps will appear shifted. The start time (e.g. the time displayed
when doing "mpv file.avi --pause") will not be exactly 0.
(According to Libav developers, this is how it's supposed to work; just
that the first DTS values are normally negative with formats that use
DTS "properly". Who cares if it doesn't work at all with very common
video formats? There's no indication that they'll fix this soon,
either. An elegant workaround is missing too.)
Add a hack to re-enable the old PTS code for AVI and vfw-muxed MKV.
Since these timestamps are not reorderd, we wouldn't need to sort them,
but it's less code this way (and possibly more robust, should a demuxer
unexpectedly output PTS).
The original intention of all the timestamp changes recently was
actually to get rid of demuxer-specific hacks and the old timestamp
sorting code, but it looks like this didn't work out. Yet another case
where trying to replace native MPlayer functionality with FFmpeg/Libav
led to disadvantages and bugs. (Note that the old PTS sorting code
doesn't and can't handle frame dropping correctly, though.)
Bug reports:
https://trac.ffmpeg.org/ticket/3178
https://bugzilla.libav.org/show_bug.cgi?id=600
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r-- | demux/demux_lavf.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 0e368cdf3d..1a6a1a9d74 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -441,6 +441,9 @@ static void handle_stream(demuxer_t *demuxer, int i) / (float)(codec->height * codec->sample_aspect_ratio.den); sh_video->i_bps = codec->bit_rate / 8; + // This also applies to vfw-muxed mkv, but we can't detect these easily. + sh_video->avi_dts = matches_avinputformat_name(priv, "avi"); + mp_msg(MSGT_DEMUX, MSGL_DBG2, "aspect= %d*%d/(%d*%d)\n", codec->width, codec->sample_aspect_ratio.num, codec->height, codec->sample_aspect_ratio.den); |