ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.36k stars 10.04k forks source link

YTDL incorrectly converts ASS to mov_text by default, then exceptions out as ffmpeg errors. #23869

Closed AlexBlandin closed 4 years ago

AlexBlandin commented 4 years ago

Checklist

Verbose log

[debug] System config: []
[debug] User config: ['-f', '299+251/bestvideo+251/bestvideo+bestaudio/best', '-w', '--fixup', 'warn', '-o', 'C:\\Users\\alex\\Videos\\%(title)s.%(ext)s']
[debug] Custom config: []
[debug] Command-line args: ['--sub-lang', 'enUS', '--write-sub', '--embed-subs', '-o', 'C:\\Users\\alex\\Videos\\%(title)s.mkv', '-u', 'PRIVATE', '-p', 'PRIVATE', '-v', 'https://www.crunchyroll.com/en-gb/keep-your-hands-off-eizouken/episode-3-lets-accomplish-something-792449']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2020.01.24
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.18362
[debug] exe versions: ffmpeg git-2020-01-10-3d894db, ffprobe git-2020-01-10-3d894db
[debug] Proxy map: {}
[crunchyroll] Downloading login page
[crunchyroll] Logging in
[crunchyroll] 792449: Downloading webpage
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP-hardsub-esES information
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP-hardsub-itIT information
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP-hardsub-esLA information
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP-hardsub-enUS information
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP-hardsub-arME information
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP-hardsub-deDE information
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP-hardsub-ruRU information
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP-hardsub-ptBR information
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP information
[crunchyroll] 792449: Downloading adaptive_hls-audio-jaJP-hardsub-frFR information
[crunchyroll] 792449: Downloading media info
[info] Video subtitle enUS.ass is already present
[debug] Invoking downloader on 'https://v.vrv.co/evs/ae1d38769b8293d01526801f798e7d07/assets/e05610dd46d22b9ea6a16078de253745_3771682.mp4/index-v1-a1.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92LnZydi5jby9ldnMvYWUxZDM4NzY5YjgyOTNkMDE1MjY4MDFmNzk4ZTdkMDcvYXNzZXRzL2UwNTYxMGRkNDZkMjJiOWVhNmExNjA3OGRlMjUzNzQ1XzM3NzE2ODIubXA0LyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1ODAzMzMyODB9fX1dfQ__&Signature=LgTuu0Td0-I165Oec2yyn4snKXrvVnNPt-vm1IlGbWXZemZpwB9II472X87-mvZg6~mzmLQiVv8icovKlGd5y1bGmf8LUR0A5GLFvrjoc9VLnpOZEHgVzyyt4e5PZzVDrJJvgao5f0Ud65RfNnEW83iBOhZ~hQGSU~mURjN3vzgjsWatY92m3nMvke6VpjNAucMR-2SiAIuLLRvoo-rIhRw5ALk~yat1E3D-mm129LSlDMf6q2iYkNj8ZsvyfSAQZFprBRD45wb8yCqr8giFUHhU6BzX~IfsXqcK-3nYyYdbKXmfYz-UO~2~5FJZfDHGSOpzoCs3fdeGri2Vj0y41Q__&Key-Pair-Id=APKAJKQQ2INNHTYFB44A'
[download] Destination: C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.mkv
[debug] ffmpeg command line: ffmpeg -y -loglevel verbose -headers "Accept-Language: en-us,en;q=0.5
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3530.4 Safari/537.36
" -i "https://v.vrv.co/evs/ae1d38769b8293d01526801f798e7d07/assets/e05610dd46d22b9ea6a16078de253745_3771682.mp4/index-v1-a1.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92LnZydi5jby9ldnMvYWUxZDM4NzY5YjgyOTNkMDE1MjY4MDFmNzk4ZTdkMDcvYXNzZXRzL2UwNTYxMGRkNDZkMjJiOWVhNmExNjA3OGRlMjUzNzQ1XzM3NzE2ODIubXA0LyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1ODAzMzMyODB9fX1dfQ__&Signature=LgTuu0Td0-I165Oec2yyn4snKXrvVnNPt-vm1IlGbWXZemZpwB9II472X87-mvZg6~mzmLQiVv8icovKlGd5y1bGmf8LUR0A5GLFvrjoc9VLnpOZEHgVzyyt4e5PZzVDrJJvgao5f0Ud65RfNnEW83iBOhZ~hQGSU~mURjN3vzgjsWatY92m3nMvke6VpjNAucMR-2SiAIuLLRvoo-rIhRw5ALk~yat1E3D-mm129LSlDMf6q2iYkNj8ZsvyfSAQZFprBRD45wb8yCqr8giFUHhU6BzX~IfsXqcK-3nYyYdbKXmfYz-UO~2~5FJZfDHGSOpzoCs3fdeGri2Vj0y41Q__&Key-Pair-Id=APKAJKQQ2INNHTYFB44A" -c copy -f mp4 "-bsf:a" aac_adtstoasc "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.mkv.part"
ffmpeg version git-2020-01-10-3d894db Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20191125
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 65.103 / 58. 65.103
  libavformat    58. 35.101 / 58. 35.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 70.101 /  7. 70.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[tcp @ 000001ef1032db80] Starting connection attempt to 13.32.171.21 port 443
[tcp @ 000001ef1032db80] Successfully connected to 13.32.171.21 port 443
[hls @ 000001ef10329fc0] Skip ('#EXT-X-ALLOW-CACHE:YES')
[hls @ 000001ef10329fc0] Skip ('#EXT-X-VERSION:3')
[hls @ 000001ef10329fc0] HLS request for url 'https://v.vrv.co/evs/ae1d38769b8293d01526801f798e7d07/assets/e05610dd46d22b9ea6a16078de253745_3771682.mp4/seg-1-v1-a1.ts?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92LnZydi5jby9ldnMvYWUxZDM4NzY5YjgyOTNkMDE1MjY4MDFmNzk4ZTdkMDcvYXNzZXRzL2UwNTYxMGRkNDZkMjJiOWVhNmExNjA3OGRlMjUzNzQ1XzM3NzE2ODIubXA0LyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1ODAyNDcxMDZ9fX1dfQ__&Signature=PUdlF8oFoWukCPELvJv0EEhyddPcaIjpTHYTYPyU1C~5HkPNb3Md8qvXvoju3MaXR7NirTcMeWXr~RbrOAuTX45X~XDeUpqghzcnCle8~8Sb4HCcQxL5MJOMSsJ7WSNzJdI-XmiSbGMYeBRE0rkWDr7YQu1wJXWGDWVwFb6xlrol2Xi~bFHoDqvIyj76z5ocEh-Fjkyh~w~ZBMPIlXjwa0Y5SM-Fkn-fqmBJpEdhwxxPjN45Qn0l9HIHXxBzAuQDvKKTYBDKx4SuR5t-E~IaihiIbtzFRndvK968olWnFFpYq7P~GpAvVNyhAevNP1EPcuU0ek96PK9sViF1L2jH7g__&Key-Pair-Id=APKAJMWSQ5S7ZB3MF5VA', offset 0, playlist 0
[hls @ 000001ef10329fc0] Opening 'https://v.vrv.co/evs/ae1d38769b8293d01526801f798e7d07/assets/e05610dd46d22b9ea6a16078de253745_3771682.mp4/encryption.key?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92LnZydi5jby9ldnMvYWUxZDM4NzY5YjgyOTNkMDE1MjY4MDFmNzk4ZTdkMDcvYXNzZXRzL2UwNTYxMGRkNDZkMjJiOWVhNmExNjA3OGRlMjUzNzQ1XzM3NzE2ODIubXA0LyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1ODAyNDcxMDZ9fX1dfQ__&Signature=PUdlF8oFoWukCPELvJv0EEhyddPcaIjpTHYTYPyU1C~5HkPNb3Md8qvXvoju3MaXR7NirTcMeWXr~RbrOAuTX45X~XDeUpqghzcnCle8~8Sb4HCcQxL5MJOMSsJ7WSNzJdI-XmiSbGMYeBRE0rkWDr7YQu1wJXWGDWVwFb6xlrol2Xi~bFHoDqvIyj76z5ocEh-Fjkyh~w~ZBMPIlXjwa0Y5SM-Fkn-fqmBJpEdhwxxPjN45Qn0l9HIHXxBzAuQDvKKTYBDKx4SuR5t-E~IaihiIbtzFRndvK968olWnFFpYq7P~GpAvVNyhAevNP1EPcuU0ek96PK9sViF1L2jH7g__&Key-Pair-Id=APKAJMWSQ5S7ZB3MF5VA' for reading
[tcp @ 000001ef1032dc00] Starting connection attempt to 13.32.171.21 port 443
[tcp @ 000001ef1032dc00] Successfully connected to 13.32.171.21 port 443
[AVIOContext @ 000001ef10870680] Statistics: 16 bytes read, 0 seeks
[hls @ 000001ef10329fc0] Opening 'crypto+https://v.vrv.co/evs/ae1d38769b8293d01526801f798e7d07/assets/e05610dd46d22b9ea6a16078de253745_3771682.mp4/seg-1-v1-a1.ts?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92LnZydi5jby9ldnMvYWUxZDM4NzY5YjgyOTNkMDE1MjY4MDFmNzk4ZTdkMDcvYXNzZXRzL2UwNTYxMGRkNDZkMjJiOWVhNmExNjA3OGRlMjUzNzQ1XzM3NzE2ODIubXA0LyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1ODAyNDcxMDZ9fX1dfQ__&Signature=PUdlF8oFoWukCPELvJv0EEhyddPcaIjpTHYTYPyU1C~5HkPNb3Md8qvXvoju3MaXR7NirTcMeWXr~RbrOAuTX45X~XDeUpqghzcnCle8~8Sb4HCcQxL5MJOMSsJ7WSNzJdI-XmiSbGMYeBRE0rkWDr7YQu1wJXWGDWVwFb6xlrol2Xi~bFHoDqvIyj76z5ocEh-Fjkyh~w~ZBMPIlXjwa0Y5SM-Fkn-fqmBJpEdhwxxPjN45Qn0l9HIHXxBzAuQDvKKTYBDKx4SuR5t-E~IaihiIbtzFRndvK968olWnFFpYq7P~GpAvVNyhAevNP1EPcuU0ek96PK9sViF1L2jH7g__&Key-Pair-Id=APKAJMWSQ5S7ZB3MF5VA' for reading
[tcp @ 000001ef10822fc0] Starting connection attempt to 13.32.171.21 port 443
[tcp @ 000001ef10822fc0] Successfully connected to 13.32.171.21 port 443
[h264 @ 000001ef109b9140] Reinit context to 1920x1088, pix_fmt: yuv420p
Input #0, hls, from 'https://v.vrv.co/evs/ae1d38769b8293d01526801f798e7d07/assets/e05610dd46d22b9ea6a16078de253745_3771682.mp4/index-v1-a1.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92LnZydi5jby9ldnMvYWUxZDM4NzY5YjgyOTNkMDE1MjY4MDFmNzk4ZTdkMDcvYXNzZXRzL2UwNTYxMGRkNDZkMjJiOWVhNmExNjA3OGRlMjUzNzQ1XzM3NzE2ODIubXA0LyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1ODAzMzMyODB9fX1dfQ__&Signature=LgTuu0Td0-I165Oec2yyn4snKXrvVnNPt-vm1IlGbWXZemZpwB9II472X87-mvZg6~mzmLQiVv8icovKlGd5y1bGmf8LUR0A5GLFvrjoc9VLnpOZEHgVzyyt4e5PZzVDrJJvgao5f0Ud65RfNnEW83iBOhZ~hQGSU~mURjN3vzgjsWatY92m3nMvke6VpjNAucMR-2SiAIuLLRvoo-rIhRw5ALk~yat1E3D-mm129LSlDMf6q2iYkNj8ZsvyfSAQZFprBRD45wb8yCqr8giFUHhU6BzX~IfsXqcK-3nYyYdbKXmfYz-UO~2~5FJZfDHGSOpzoCs3fdeGri2Vj0y41Q__&Key-Pair-Id=APKAJKQQ2INNHTYFB44A':
  Duration: 00:25:00.00, start: 0.142000, bitrate: N/A
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (High), 1 reference frame ([27][0][0][0] / 0x001B), yuv420p(left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
    Metadata:
      variant_bitrate : 0
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 0
    Stream #0:2: Data: timed_id3 (ID3  / 0x20334449)
    Metadata:
      variant_bitrate : 0
Output #0, mp4, to 'file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 ÔÇô Let's Accomplish Something!.mkv.part':
  Metadata:
    encoder         : Lavf58.35.101
    Stream #0:0: Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1920x1080 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 90k tbn, 90k tbc
    Metadata:
      variant_bitrate : 0
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 0
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
...
... ... Omitted for conciseness, the video downloaded without issue
...
No more output streams to write to, finishing.
frame=35964 fps= 89 q=-1.0 Lsize= 1480419kB time=00:25:00.01 bitrate=8085.0kbits/s speed= 3.7x
video:1455895kB audio:23438kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.073414%
Input file #0 (https://v.vrv.co/evs/ae1d38769b8293d01526801f798e7d07/assets/e05610dd46d22b9ea6a16078de253745_3771682.mp4/index-v1-a1.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92LnZydi5jby9ldnMvYWUxZDM4NzY5YjgyOTNkMDE1MjY4MDFmNzk4ZTdkMDcvYXNzZXRzL2UwNTYxMGRkNDZkMjJiOWVhNmExNjA3OGRlMjUzNzQ1XzM3NzE2ODIubXA0LyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1ODAzMzMyODB9fX1dfQ__&Signature=LgTuu0Td0-I165Oec2yyn4snKXrvVnNPt-vm1IlGbWXZemZpwB9II472X87-mvZg6~mzmLQiVv8icovKlGd5y1bGmf8LUR0A5GLFvrjoc9VLnpOZEHgVzyyt4e5PZzVDrJJvgao5f0Ud65RfNnEW83iBOhZ~hQGSU~mURjN3vzgjsWatY92m3nMvke6VpjNAucMR-2SiAIuLLRvoo-rIhRw5ALk~yat1E3D-mm129LSlDMf6q2iYkNj8ZsvyfSAQZFprBRD45wb8yCqr8giFUHhU6BzX~IfsXqcK-3nYyYdbKXmfYz-UO~2~5FJZfDHGSOpzoCs3fdeGri2Vj0y41Q__&Key-Pair-Id=APKAJKQQ2INNHTYFB44A):
  Input stream #0:0 (video): 35964 packets read (1490836820 bytes);
  Input stream #0:1 (audio): 64601 packets read (24452724 bytes);
  Input stream #0:2 (data): 0 packets read (0 bytes);
  Total: 100565 packets (1515289544 bytes) demuxed
Output file #0 (file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 ÔÇô Let's Accomplish Something!.mkv.part):
  Output stream #0:0 (video): 35964 packets muxed (1490836820 bytes);
  Output stream #0:1 (audio): 64601 packets muxed (24000517 bytes);
  Total: 100565 packets (1514837337 bytes) muxed
[AVIOContext @ 000001ef10329980] Statistics: 28 seeks, 5803 writeouts
[AVIOContext @ 000001ef108707c0] Statistics: 121488 bytes read, 0 seeks
[ffmpeg] Downloaded 1515949436 bytes
[download] 100% of 1.41GiB in 06:46
[ffmpeg] Embedding subtitles in 'C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.mkv'
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.mkv" -i "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.mkv.enUS.ass" -map 0 -c copy -map "-0:s" -map "-0:d" "-c:s" mov_text -map "1:0" "-metadata:s:s:0" "language=eng" "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.temp.mkv"
ERROR:   Stream #1:0 -> #0:2 (ass (ssa) -> mov_text (native))
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpw0w300z1\build\youtube_dl\YoutubeDL.py", line 2064, in post_process
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpw0w300z1\build\youtube_dl\postprocessor\ffmpeg.py", line 426, in run
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpw0w300z1\build\youtube_dl\postprocessor\ffmpeg.py", line 235, in run_ffmpeg_multiple_files
youtube_dl.postprocessor.ffmpeg.FFmpegPostProcessorError:   Stream #1:0 -> #0:2 (ass (ssa) -> mov_text (native))

Description

ERROR:    Stream #1:0 -> #0:2 (ass (ssa) -> mov_text (native))

I was doing some testing and noticed the above error (in particular, the testing was all -q so I had to recreate it for the log and as described below).

I had been wanting to weigh in on how to force to a specific container when --merge-output-format (incorrectly, imho) decides not to merge, such as when subtitles are lossily converted. Personally, I think that when ytdl embeds subtitles it should do it losslessly, and so elevating to a .mkv when given --merge-output-format mkv is reasonable, especially given how .mp4 currently only converts to timed text -- which has serious accessibility problems, especially given content with multiple subtitles in different places on screen at once. At the very least, testing different ways of doing this would allow me to figure out how I should do such a thing should I ever need it myself (given how recoding the entire video is recommended by some, but is entirely unnecessary and can drop the bitrate, I felt I needed to find at least one good way to do this without problem).

In principle, simply setting the extension with -o allows you to at least always have it as, say, an .mkv, but that also means you can waste time if it does not need merging, which is why I support the above interpretation of --merge-output-format as including subtitle conversion as part of how it chooses whether it should merge to the given format, presuming the user has specified it all correctly lest face errors.

A simpler log (-q -v) should suffice for much of the explanation here:

[debug] System config: []
[debug] User config: ['-f', '299+251/bestvideo+251/bestvideo+bestaudio/best', '-w', '--fixup', 'warn', '-o', 'C:\\Users\\alex\\Videos\\%(title)s.%(ext)s']
[debug] Custom config: []
[debug] Command-line args: ['--sub-lang', 'enUS', '--write-sub', '--embed-subs', '-o', 'C:\\Users\\alex\\Videos\\%(title)s.mkv', '-u', 'PRIVATE', '-p', 'PRIVATE', '-q', '-v', 'https://www.crunchyroll.com/en-gb/keep-your-hands-off-eizouken/episode-3-lets-accomplish-something-792449']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2020.01.24
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.18362
[debug] exe versions: ffmpeg git-2020-01-10-3d894db, ffprobe git-2020-01-10-3d894db
[debug] Proxy map: {}
[debug] Invoking downloader on 'https://v.vrv.co/evs/ae1d38769b8293d01526801f798e7d07/assets/e05610dd46d22b9ea6a16078de253745_3771682.mp4/index-v1-a1.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92LnZydi5jby9ldnMvYWUxZDM4NzY5YjgyOTNkMDE1MjY4MDFmNzk4ZTdkMDcvYXNzZXRzL2UwNTYxMGRkNDZkMjJiOWVhNmExNjA3OGRlMjUzNzQ1XzM3NzE2ODIubXA0LyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1ODAzMzU3MzR9fX1dfQ__&Signature=MAjlWzyTgaOJ~V0vt75jmwDf70zR3qhjoalBIVc5DfoBDkZV4108kvOeOxln9j2zAxVKpCGA-Z4BbgFOsv6WIWyt11H1RyfcoJ9MfTa-pxJFQ2-I5UzcwECRSqW3~01Twq7iFl08Gt3s6xTNNpJXDVVk9yk5hXId9YFEkYP~kkYjOL~smEQsmtePVdTa7Xx7CJxl2bITl~HhzNXs8c01Huadyh1-XiYIAHbf2-fIEM-z9rXRvqRCuFH6WHsjYbfHALr75u8PSRKv7wF9GeKDwhJkk7MJlPbwdO1-YUwnlrIZeHMrNXbtOMLkZdJXbNRcWBw7xyoeH8yF8Sp8S4XM3w__&Key-Pair-Id=APKAJKQQ2INNHTYFB44A'
ERROR:   Stream #1:0 -> #0:2 (ass (ssa) -> mov_text (native))
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpw0w300z1\build\youtube_dl\YoutubeDL.py", line 2064, in post_process
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpw0w300z1\build\youtube_dl\postprocessor\ffmpeg.py", line 426, in run
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpw0w300z1\build\youtube_dl\postprocessor\ffmpeg.py", line 235, in run_ffmpeg_multiple_files
youtube_dl.postprocessor.ffmpeg.FFmpegPostProcessorError:   Stream #1:0 -> #0:2 (ass (ssa) -> mov_text (native))

Though we do need to include this from the verbose log:

[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.mkv" -i "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.mkv.enUS.ass" -map 0 -c copy -map "-0:s" -map "-0:d" "-c:s" mov_text -map "1:0" "-metadata:s:s:0" "language=eng" "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.temp.mkv"

So, given a resonably typical setup (the user config simply deals with good YT & Twitch handling), the command lines are what we would expect for one hoping to embed subtitles. The simpler log is useful since the CR extractor is very noisy, but we do need some of the full verbosity (a quiet mode to deal with the fallback downloader as used on CR would be useful, but that's neither here nor there) as before.

The specific switches with this also overwrite the -o to always have the extension .mkv, meant to demonstrate one way of forcing a container. In theory, this should not be a problem, and we would expect the subtitles to simply be copied in (given they are in a supported format), however the most important detail to note is that the subtitles are merged with:

"-c:s" mov_text

Which, given that they are .ass subtitles merging into an .mkv, means something is clearly wrong. Fortunately, as ffmpeg errors out, ytdl exits early, and so never cleans the files up, meaning we can in principle recover from this and embed, but that also means that there are .temp files strewn around the directory, and have to use more effort in performing both the embedding and the cleanup externally to ytdl, which we would obviously rather avoid.

It would be natural to think that, given how no subtitle conversion was specified, by default it would simply embed the given format -- particularly when it fits in a possible container (if it were to either merge with --merge-output-format or is supported by the original container).

If we are able to preserve the subtitle file whilst still being able to clean up (ie, without a full -k, or without doing it twice, once as --write-sub and the other just the video), that would at least allow a relatively simple --exec to embed it, which may need to be included in the documentation.

Of course, improving the subtitle embedding is obviously much more user-friendly. If the source provides .ass or some other format, then most users would probably prefer it over something on the level of srt.

Hopefully this discussion can help bring attention to (and resolve some of) the problems in other issues, like #17968, #21343, and #21344. In particular, beyond pushing for improved subtitle embedding, this should highlight that we can change container through -o, but that we may want to have some other mechanic for dealing with containers (especially in the context of correct subtitle embedding).

Ideally, we would not want to lead to conflicts with existing configs or scripts, so I am a proponent for extending --merge-output-format and having it consider subtitle embedding in the choice of whether to merge or not. Alternatively, one option is specifying a preferred container, or allowing it to fall back to a more compatible container if something would be incompatible or require lossy conversion, perhaps defaulting to .mkv but allowing the user to override on its own, akin to a second level of --merge-output-format that the existing option could itself fall back upon.

Hopefully, updating ytdl to not simply use -c:s mov_text by default will help with embedding multiple subtitles of varying formats into a given container.

Also, subtitle embedding needs to be noted in the docs as forcibly converting to mov_text / "timed text" by default until this is resolved.

Subtitles are easily neglected, but are important to many users for many different reasons. Thankfully, a lot of the heavy lifting can be done by ffmpeg, especially when using containers such as .mkv. Given how many have problems with the default setup of subtitle embedding in ytdl (given it repeatedly appearing in the issues) it seems worthy of calling the defaults at least somewhat flawed, and the attempt to forcibly convert to mov_text being a clear bug (since it can lead to ytdl crashing), especially as the lossy conversion would likely not be what the user wanted unless they specifically said so with --convert-subs.

dstftw commented 4 years ago

You not allowed to hardcode the ext in output template in the first place. Putting .mkv in output template will not produce mkv but just the original media file named with mkv extension.

AlexBlandin commented 4 years ago

Still a valid problem with --merge-output-format not respecting subtitles and the listed problems with lossy embedding, so closing and marking this as invalid is disingenuous. The listed problem is that it goes to mov_text, when it shouldn't. Granted, the exception is due to ytdl not noting the intended container by hardcoding, which you say is not allowed, though that seems a little bizarre to me.

Calling with --merge-output-format mkv, it still goes to .mp4 and does not merge into .mkv, despite the problems with lossy subtitle embedding as I described.

For the sake of testing, simply replacing "-c:s" mov_text with "-c:s" copy in the ffmpeg command works, even given an mp4 hardcoded to mkv, as below:

ffmpeg -y -loglevel "repeat+info" -i "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.mkv" -i "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.mkv.enUS.ass" -map 0 -c copy -map "-0:s" -map "-0:d" "-c:s" copy -map "1:0" "-metadata:s:s:0" "language=eng" "file:C:\Users\alex\Videos\Keep Your Hands Off Eizouken! Episode 3 – Let's Accomplish Something!.temp.mkv"

This was sufficient as ffmpeg simply encodes the merged output correctly. So regardless of how (as I said, I support using --merge-output-format mkv) ytdl needs to recognise it should be losslessly merging the video and subtitle files into an .mkv, which to me seems like the exact thing --merge-output-format exists for.

AlexBlandin commented 4 years ago

In addition, going over https://github.com/ytdl-org/youtube-dl/blob/51c7f40c83a12f9dc0fce0b9e5102a0c13467b6a/README.md there does not appear to be anything that says you should not hardcode the extension in the output template.

gw711 commented 4 years ago

DId anyone ever figure out how to use youtube-dl to get an mkv file that maintains the ass subtitle format when downloading CR? I've had a nightmare attempting to workaround this limitation

AlexBlandin commented 4 years ago

Currently your only robust option is to keep the files with -k or do a "subtitle run", then merge into an .mkv.

Using switches like the above are viable for individual videos and their subtitles, but you'd probably want something a little extra for, say, doing an entire series at once. Using the built in switch --exec to run a script that does this might be easiest, allowing you to bake in the subtitles.

An alternative as a user, though your milage may vary, is to not embed the subtitles. Some players (or configurations/options) will load local subtitles properly, but this is dependent on your setup, and adds extra hassle/clutter to your filesystem.

gw711 commented 4 years ago

Yeah what's I've settled on is youtube-dl downloading the video and subtitle files, and using --exec to run a powershell script to ffmpeg the video and subtitles into a single file, and also delete the inputs.