-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't seek if dvd title >1 #696
Comments
Can't reproduce - but it could depend on the DVD. Maybe try your luck with dvdnav:// |
I just came here to post the exact same issue. For my DVD there was no dvd://0 track, but dvd://1 is able to seek just fine, however anything higher and it just skips to the end. attempting dvdnav:// just gives me: |
I investigated this problem and think I've narrowed it down a bit. The problem comes after when the DEMUXER_CTRL_RESYNC message is sent to the demux.
The pos argument seems to be the new byte offset in the iso file after the seek. avio_size() however returns the size of the current title, not the entire iso file. When playing the first title on disc this doesn't matter because pos_min < pos < pos_max anyway but for other titles pos > pos_max. Pos will be set to pos_max and the following avio_seek will seek to the end of the title ending playback. Other seeking errors could also occur if the other title is large enough. This problem doesn't occur in mplayer2 because the DEMUXER_CTRL_RESYNC call will just return DEMUXER_CTRL_NOTIMPL without doing anything. I can work around the problem by not calling DEMUXER_CTRL_RESYNC at all but this will cause corruption when seeking. It seems to be the way dvdnav do it. |
Interesting! Good job.
The purpose of DEMUXER_CTRL_RESYNC is to make libavformat drop its internal buffers. libavformat can have a lot of data queued, both in its internal byte-level stream buffer, and the demuxer internal packet queue. Obviously all of this must be cleared when seeking. Normally, the demuxer seeks the stream itself. But with DVD, everything is special, and seeking by time has to be done on the stream level. So for the demuxer, the stream should look like a linear unseekable stream, which can sometimes interrupted DEMUXER_CTRL_RESYNC |
Oops. Actually got on a key stroke and closed the issue. Anyway, continuing my previous post:
, which happens when seeking is done on the stream level. To make the stream seem like a linear byte stream, we also disable (or rather, not implement) stream-level seeking by byte position. This means we should probably pretend that we don't know the byte size of the stream on the stream level. Or in other word, stream.end_pos should not be set in stream_dvd. |
Maybe you can try this patch, though with my sample I didn't notice a change at all:
|
Tried it but no dice. With the patch the avio_size() call will return -1 giving pos_max = -2. Then pos > pos_max and pos will be set to -2 followed by the avio_seek to -2. Basically and any seeking will reset back to time 0. |
What do you mean by this? |
I've recently made some unrelated changes to dvd:// in git master. Can you test whether this affected this case? |
It has changed. The main problem with playback ending when seeking is fixed but there are new problems.
Some of these problems exists for dvdnav also so it might be better to file them as separate bugs? |
Sorry, I completely broke dvd:// seeking. Try this patch: http://sprunge.us/RCPG
dvdnav should not be affected. |
The patch fixes most problems. There are still some video corruptions and seeking backwards is almost guaranteed to cut off sound. The sound comes back when seeking forward or when playback reach the position before the backwards seek. Seeking backwards to a position before the start of the stream will seek forward by 1 sec instead of back. Seek back 10 min only works if playtime is >10 min. |
Even with dvdnav? |
Yes, the corruptions and sound problem are the same with dvdnav. |
Did a good deal of debugging. But it seems dvdnav (as well as libdvdread) is really returning invalid data. (Or we forget to flush some data somewhere, but I didn't find anything.) |
I found another DVD seek problem. When seeking close to the end of a chapter mpv sometimes gets stuck in an infinite loop. I can only reproduce it with some dvds and only on the final chapter. I guess it happens when the seek ends up just at the end of the chapter. gdb thread apply all bt on latest git master Thread 13 (Thread 0x7f3572c79700 (LWP 9970)): Thread 12 (Thread 0x7f3568e0c700 (LWP 9972)): Thread 11 (Thread 0x7f355fff7700 (LWP 10193)): Thread 10 (Thread 0x7f35607f8700 (LWP 10194)): Thread 9 (Thread 0x7f3561ffb700 (LWP 10195)): Thread 8 (Thread 0x7f35627fc700 (LWP 10196)): Thread 7 (Thread 0x7f356bbe7700 (LWP 10197)): Thread 6 (Thread 0x7f3563fff700 (LWP 10198)): Thread 5 (Thread 0x7f35637fe700 (LWP 10199)): Thread 4 (Thread 0x7f3562ffd700 (LWP 10200)): Thread 3 (Thread 0x7f35617fa700 (LWP 10201)): Thread 2 (Thread 0x7f3560ff9700 (LWP 10202)): Thread 1 (Thread 0x7f357d807780 (LWP 9968)): output from perf top -p ~/.mpv/config contains |
Tried to hack-fix it, might or might not work. Seriously, use In fact, I'm going to rename |
The hack-fix seems to work. I can't trigger the problem anymore. |
When playing back a dvd iso as "mpv --dvd-device=disc.iso dvd://1" seeking causes playback to end. Seeking works fine on the first track with dvd://0. When playing a range of titels like dvd://1-99 seeking will automatically jump to the start of the next title.
This problem existed before the dvd://1 -> dvd://0 change.
I'm using mpv-build at --master.
Playing with -v -v this is the output generated when attempting to seek:
The text was updated successfully, but these errors were encountered: