since 0.15.0, can't cycle through subtitle tracks if one is unsupported #3446

Closed
sumyungguy opened this Issue Aug 22, 2016 · 4 comments

Projects

None yet

2 participants

@sumyungguy
sumyungguy commented Aug 22, 2016 edited

mpv version and platform

0.19.0 OS X. Also tested on Windows 7, it doesn't work there either.

Also tested with the following OS X builds from ChrisK's site:
2015-12-13 git-f24ba54 and earlier - problem not present, works as expected
2015-12-20 git-31c2949 - can't test, mpv crashes
2016-01-01 git-de0523b and later - problem is present, can't select second subtitle track

Reproduction steps

Playing mpg files recorded by "EyeTV" application, off air from DVB in Europe. The files have two embedded subtitle tracks for hearing impaired people. The first is "teletext" subtitles and the second is DVB subtitles.

In mpv 0.14.0 and earlier, I could cycle to the DVB subtitles and display them. Initially the subtitle icon in the controller shows -/2. Clicking on it cycles to 1/2 and displays "Subtitle Track: 1/2 [lang]" which is the teletext track, which doesn't display anything because it's not supported. Clicking again cycles to '2/2', and shows "Subtitle Track: 2/2 [lang]", and the DVB subtitles would display correctly. Continuing to click or press j would cycle repeatedly through the subtitle tracks.

Expected behavior

As above.

Actual behavior

In mpv 0.15.0 and later, including 0.19.0, clicking the controller icon shows "Subtitle Track: 1/2 [lang]", but the icon continues to show -/2. Continuing to click just keeps showing the same thing. No subtitles are displayed. Pressing the j key does the same, except that the message shows "Subtitles: no".

It seems that when it fails to open a subtitle decoder for the teletext track, it's setting the subtitle index back to 0 (none). Attempting to cycle to the next track just goes to 1, fails and goes back to 0 again. It's not possible to cycle past it.

However, if I press shift-j, for reverse cycle, the second DVB subtitle track can be reached, and displays correctly.

Log files

In 0.14.0, the log shows:

[   8.665][i][cplayer]  (+) Video --vid=1 (mpeg2video)
[   8.665][i][cplayer]  (+) Audio --aid=1 --alang=deu (mp2)
[   8.665][i][cplayer]      Audio --aid=2 --alang=mis (mp2)
[   8.665][i][cplayer]  (+) Subs  --sid=1 --slang=deu (dvb_teletext)
[   8.665][i][cplayer]      Subs  --sid=2 --slang=deu (dvb_subtitle)
[   8.666][v][vd] Container reported FPS: 25.000000
[   8.667][v][vd] Codec list:
[   8.667][v][vd]     lavc:mpeg2video - MPEG-2 video
[   8.667][v][vd]     lavc:mpegvideo (mpeg2video) - MPEG-1 video
[   8.667][v][vd] Opening video decoder lavc:mpeg2video
[   8.667][v][vd] Probing 'videotoolbox'...
[   8.667][v][vd] Trying hardware decoding.
[   8.667][v][vd] Selected video codec: MPEG-2 video [lavc:mpeg2video]
[   8.669][v][ad] Codec list:
[   8.669][v][ad]     lavc:mp2 - MP2 (MPEG audio layer 2)
[   8.669][v][ad]     lavc:mp2float (mp2) - MP2 (MPEG audio layer 2)
[   8.669][v][ad] Opening audio decoder lavc:mp2
[   8.669][v][ad] Requesting 1 threads for decoding.
[   8.669][v][ad] Selected audio codec: MP2 (MPEG audio layer 2) [lavc:mp2]
(font setup stuff deleted)
[   8.671][e][sub] Could not find subtitle decoder for format 'dvb_teletext'.
[   8.671][v][cplayer] Starting playback...
[...]

(...cycle to second subtitle track...)
[  15.187][v][cplayer] Run command: set, flags=0, args=[sub, 2]
[  15.187][v][sub] Subtitle filter chain: lavc (dvb_subtitle)
[  15.187][i][cplayer] Track switched:
[  15.187][i][cplayer]  (+) Video --vid=1 (mpeg2video)
[  15.187][i][cplayer]  (+) Audio --aid=1 --alang=deu (mp2)
[  15.187][i][cplayer]      Audio --aid=2 --alang=mis (mp2)
[  15.187][i][cplayer]      Subs  --sid=1 --slang=deu (dvb_teletext)
[  15.187][i][cplayer]  (+) Subs  --sid=2 --slang=deu (dvb_subtitle)

While in 0.19.0, it shows:

[  14.966][i][cplayer]  (+) Video --vid=1 (mpeg2video)
[  14.966][i][cplayer]  (+) Audio --aid=1 --alang=deu (mp2)
[  14.966][i][cplayer]      Audio --aid=2 --alang=mis (mp2)
[  14.966][i][cplayer]  (+) Subs  --sid=1 --slang=deu (dvb_teletext)
[  14.966][i][cplayer]      Subs  --sid=2 --slang=deu (dvb_subtitle)
[  14.968][v][vd] Container reported FPS: 25.000000
[  14.969][v][vd] Codec list:
[  14.969][v][vd]     lavc:mpeg2video - MPEG-2 video
[  14.969][v][vd]     lavc:mpegvideo (mpeg2video) - MPEG-1 video
[  14.969][v][vd] Opening video decoder lavc:mpeg2video
[  14.969][v][vd] Probing 'videotoolbox'...
[  14.969][v][vd] Trying hardware decoding.
[  14.969][v][vd] Selected video codec: MPEG-2 video [lavc:mpeg2video]
[  14.973][v][ad] Codec list:
[  14.973][v][ad]     lavc:mp2 - MP2 (MPEG audio layer 2)
[  14.973][v][ad]     lavc:mp2float (mp2) - MP2 (MPEG audio layer 2)
[  14.973][v][ad]     lavc:mp2_at (mp2) - mp2 (AudioToolbox)
[  14.973][v][ad] Opening audio decoder lavc:mp2
[  14.973][v][ad] Requesting 1 threads for decoding.
[  14.973][v][ad] Selected audio codec: MP2 (MPEG audio layer 2) [lavc:mp2]
(I think here it gets set back to "none")
[  14.973][f][sub/ass] Could not open libavcodec subtitle converter
[  14.973][e][sub] Could not find subtitle decoder for format 'dvb_teletext'.
[  14.973][v][cplayer] Starting playback...
[...]

(...when clicking icon to cycle, args should be [sub, 2] but are [sub, 1])
[  20.316][v][cplayer] Run command: set, flags=0, args=[sub, 1]
[  20.316][f][sub/ass] Could not open libavcodec subtitle converter
[  20.316][e][sub] Could not find subtitle decoder for format 'dvb_teletext'.
[  20.316][i][cplayer] Track switched:
[  20.316][i][cplayer]  (+) Video --vid=1 (mpeg2video)
[  20.316][i][cplayer]  (+) Audio --aid=1 --alang=deu (mp2)
[  20.316][i][cplayer]      Audio --aid=2 --alang=mis (mp2)
[  20.316][i][cplayer]      Subs  --sid=1 --slang=deu (dvb_teletext)
[  20.316][i][cplayer]      Subs  --sid=2 --slang=deu (dvb_subtitle)
[  20.316][v][cplayer] Set property: sid="1" -> 1
[  20.316][v][cplayer] Set property: sub=1 -> 1

Full logs and samples available on request. Thanks...

@wm4
Member
wm4 commented Aug 26, 2016

The change in behavior is actually a bug fix. That you can't skip non-working tracks when cycling is simply because it chooses a track to enable, and then enables it. If it fails, it'll deselect the track. Then next time you cycle it restarts from the first stream.

@wm4 wm4 added the feature request label Aug 26, 2016
@sumyungguy
sumyungguy commented Sep 3, 2016 edited

The way I'd expect it to work, would be to see an error message, eg. "Could not find subtitle decoder for format 'dvb_teletext'", but for the track to remain selected, so that you could continue on and select the next one.

If that's not possible, maybe when cycling, if a track fails to enable, it could try the next available one?

Anyway, as I was writing the bug report, I figured out that cycling backwards instead works, so I guess that's good enough for me...

@wm4
Member
wm4 commented Sep 3, 2016

but for the track to remain selected,

That'd be kind of weird and could have all sorts of unintended consequences (which is why I preferred to "fix" it).

if a track fails to enable, it could try the next available one?

Also doesn't really fit into how the code works. It could happen that it fails at a much later point in time, which would make getting this consistent really hard. But I guess I could look into whether it'd work well enough for subs.

@wm4 wm4 added a commit that closed this issue Sep 3, 2016
@wm4 wm4 command: try selecting the next track if track switching fails
This affects the "cycle" command. If we switched to the next track, and
it failed to initialize, we just deselected everything.

Change it so that if initialization fails early (typically decoder
selection), we try to continue with the track after that. (Even if
nothing can be selected, the loop will terminate when trying to select
nothing.

Fixes #3446.
590caeb
@wm4 wm4 closed this in 590caeb Sep 3, 2016
@wm4
Member
wm4 commented Sep 3, 2016

Turned out simpler than expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment