TheAMM / mpv_thumbnail_script

A Lua script to show preview thumbnails in mpv's OSC seekbar, sans external dependencies
GNU General Public License v3.0
679 stars 68 forks source link

Thumbnailing failed on some youtube DASH videos #8

Closed zaza42 closed 6 years ago

zaza42 commented 6 years ago

When mpv opens DASH and audio streams separately or only the DASH stream, thumbnailing is failed with this message:

$ mpv --ytdl-format=135 https://www.youtube.com/watch?v=oM36vTQOkP0
Playing: https://www.youtube.com/watch?v=oM36vTQOkP0
 (+) Video --vid=1 (*) (h264 642x480)
VO: [opengl] 642x480 yuv420p
V: 00:00:00 / 00:19:26 (0%) DS: 2.500/0 Cache:  4s
[mpv_thumbnail_script_client_osc] Creating /dev/shm/DC-1_runtime/cache/mpv_thumbnails/watchvoM36vTQOkP0-0 
V: 00:00:00 / 00:19:26 (0%) DS: 2.333/0 Cache:  4s
[mpv_thumbnail_script_server] Thumbnailing command failed! 
[mpv_thumbnail_script_server] init 
[mpv_thumbnail_script_server]  
[mpv_thumbnail_script_server] Debug log: /dev/shm/DC-1_runtime/cache/mpv_thumbnails/watchvoM36vTQOkP0-0/000000.bgra.log 
[mpv_thumbnail_script_server] Output file missing! /dev/shm/DC-1_runtime/cache/mpv_thumbnails/watchvoM36vTQOkP0-0/000000.bgra 

The log file is completely missing. When using --ytdl-format=18 the thumbnailing is ok.

Not all videos are failing, but I can't see the differences between them. For example this works:

$ mpv --ytdl-format=135 https://www.youtube.com/watch?v=7rG7wPCcxmw                                                                                                    
Playing: https://www.youtube.com/watch?v=7rG7wPCcxmw
 (+) Video --vid=1 (*) (h264 854x480 25.000fps)
 (+) Subs  --sid=1 --slang=en 'vtt' (webvtt) (external)
VO: [opengl] 854x480 yuv420p
V: 00:00:00 / 00:11:22 (0%) DS: 2.500/0 Cache:  9s+0KB
[mpv_thumbnail_script_client_osc] Creating /dev/shm/DC-1_runtime/cache/mpv_thumbnails/watchv7rG7wPCcxmw-0 
V: 00:00:08 / 00:11:22 (1%) DS: 2.400/1 Cache: 80s+21MB
TheAMM commented 6 years ago

oM36vTQOkP0 creates an edl:// (a... virtual file which can join several sources together) way too long to pass in a command line argument. I get 145451 bytes of it. 7rG7wPCcxmw is reasonably sized.

TheAMM commented 6 years ago

Hmh. I thought I could use a playlist to bypass the limit but mpv can only handle lines up to 8K characters long. Sadly I'll have to allow mpv pass the original url through ytdl again. It'll really slow down the process, but eh.

TheAMM commented 6 years ago

Fixed in 40cadfc9c7deeaabe103ea1a6741ddd540c3e03f.

zaza42 commented 6 years ago

Thx for the fast response again!

zaza42 commented 6 years ago

Hmm... Have you looked at the -a parameter of youtube-dl?

       -a, --batch-file FILE
              File containing URLs to download ('-' for stdin)

You can pass the url from file or stdin, and it doesn't have length limit.

TheAMM commented 6 years ago

The edl:// is not for youtube-dl, it's for mpv. I don't call ytdl itself ever, and even if stdin was the solution, it's not because it's a pain to try to pipe stuff in a cross-platform manner (because mpv doesn't open a shell).

The real solution is to have a script setup a pre-hook and let the script read the playlist with no character limits, but that's not a clean solution yet (workers should not pre-hook because there can be multiple, and the osc-client pre-hooking feels wrong and having a third script just to pre-hook the playlist is stupid).

zaza42 commented 6 years ago

or you can make a patch for mpv, or ask for a feature/changing in code.

TheAMM commented 6 years ago

150 kilobytes of a media path is ridiculous. It's not fair to expect mpv to parse playlist entries that long, and I have features I'd already want in that they're not really interested in - a patch to read up to and over 150 kilobyte lines would be scoffed at - there's just no reason to expect entries that long, especially so since this can be fixed with the hook script. Plus then the functionality of the script would depend on the mpv version. Not all users have a cronjob for daily mpv-build sessions.