mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.49k stars 2.92k forks source link

Seeking fails reporting corrupt file, VLC seeks without error #13048

Open low-batt opened 11 months ago

low-batt commented 11 months ago

Important Information

Provide following Information:

This problem was reported against IINA in issue https://github.com/iina/iina/issues/4711.

Reproduction steps

Start the attached video playing and then press the ← key to seek backwards.

Expected behavior

Playback restarts at an earlier time and mpv continues playing the video.

Actual behavior

Playback terminates reporting the file is corrupt as shown here:

low-batt@gag issue-4711$ mpv --log-file=mpv.log --no-config 288381484-1ee2c539-96a7-4307-89bc-4dac010fcb75.webm
 (+) Video --vid=1 (*) (vp8 1024x768)
VO: [libmpv] 1024x768 yuv420p
[mkv] Discarding potentially broken or useless index.
[mkv] no target for seek found
[mkv] Corrupt file detected. Trying to resync starting from position 112912...
[mkv] Cluster found at 463646.
Exiting... (End of file)     
low-batt@gag issue-4711$

Full log attached. This clip from the log shows the warnings and error reported:

[   5.828][v][mkv] Seeking to 1155027 to read header element 0x1c53bb6b.
[   5.828][v][file] stream level seek from 131072 to 1155027
[   5.828][v][mkv] Parsing cues...
[   5.828][w][mkv] Discarding potentially broken or useless index.
[   5.828][v][file] stream level seek from 1155110 to 312
[   5.828][v][mkv] creating index until TC 795000000
[   5.829][w][mkv] no target for seek found
[   5.829][v][file] stream level seek from 1155110 to 112912
[   5.829][v][mkv] seek done
[   5.829][e][mkv] Corrupt file detected. Trying to resync starting from position 112912...

Playing this same video with VLC 3.0.20 I am able to seek backwards and forwards using the ← and → keys and playback restarts at the expected position and continues playing.

Log file

mpv.log

Sample files

288381484-1ee2c539-96a7-4307-89bc-4dac010fcb75.webm

llyyr commented 11 months ago

ffplay can seek through it, so it's an mpv issue.

edit: --demuxer=lavf works around the issue, confirming that this is an issue with mpv's mkv demuxer.

kasper93 commented 11 months ago

Related commit https://github.com/mpv-player/mpv/commit/ba384fffca982465e63c3ffe3a3fb34c08e75de2 if mpv detect potentially broken index it is discarded, ffmpeg might have some workarounds, but mpv does not. I haven't look into details for this file though.

1nsane000 commented 9 months ago

Looks like that the file in addition to having broken cues doesn't have any frames marked as keyframes either. As far as I can tell the mkv demuxer tries to find a keyframe to resync after seeking but since it can't it just seeks until the end of the stream.