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.31k stars 10.03k forks source link

[Viki] ffmpeg embed subtitles error #17421

Open ghost opened 6 years ago

ghost commented 6 years ago

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2018.09.01. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

Before submitting an issue make sure you have:

What is the purpose of your issue?


The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


~/Downloads/youtube-dl --write-sub --sub-format srt --sub-lang en --embed-subs 'https://www.viki.com/videos/1026409v-my-love-from-the-star-episode-1' -v
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--write-sub', u'--sub-format', u'srt', u'--sub-lang', u'en', u'--embed-subs', u'https://www.viki.com/videos/1026409v-my-love-from-the-star-episode-1', u'-v']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.09.01
[debug] Python version 2.7.13 (CPython) - Linux-4.9.0-3-amd64-x86_64-with-debian-9.1
[debug] exe versions: ffmpeg 3.2.7-1, ffprobe 3.2.7-1
[debug] Proxy map: {}
[viki] 1026409v: Downloading video JSON
[viki] 1026409v: Downloading video streams JSON
[debug] Default format spec: bestvideo+bestaudio/best
[info] Writing video subtitles to: My Love From the Star - Episode 1-1026409v.en.srt
[debug] Invoking downloader on u'https://v4.viki.io/1026409v/1026409v_high_480p_1708160136.mp4?e=1535939464&h=1b543edad20d7f05d2eee1ff5cd5cfec'
[download] Destination: My Love From the Star - Episode 1-1026409v.mp4
[download] 100% of 348.84MiB in 00:01
[ffmpeg] Embedding subtitles in 'My Love From the Star - Episode 1-1026409v.mp4'
[debug] ffmpeg command line: ffmpeg -y -i 'file:My Love From the Star - Episode 1-1026409v.mp4' -i 'file:My Love From the Star - Episode 1-1026409v.en.srt' -map 0 -c copy -map '-0:s' '-c:s' mov_text -map '1:0' '-metadata:s:s:0' 'language=eng' 'file:My Love From the Star - Episode 1-1026409v.temp.mp4'
ERROR:     Last message repeated 1 times
Traceback (most recent call last):
  File "/home33/megamind/Downloads/youtube-dl/youtube_dl/YoutubeDL.py", line 2047, in post_process
    files_to_delete, info = pp.run(info)
  File "/home33/megamind/Downloads/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 393, in run
    self.run_ffmpeg_multiple_files(input_files, temp_filename, opts)
  File "/home33/megamind/Downloads/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 204, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
FFmpegPostProcessorError:     Last message repeated 1 times

...
<end of log>

I'm trying to download Video from Viki it works perfectly but when i say it to embed subs it throws me the above error tried multiple files same issue persists (issue with both vtt and srt file types) I also use embed subs with Viu but it works great there only having issues with VIU

ghost commented 6 years ago

Tired using --recode-video mkv post processing option and now its able to embed the subs i dont get it MP4 files on viu can be embedded with subs without re-encoding to mkv then why not viki Thanks

Update:- tried few files re-encoding to mkv it does work while embedding subs. but even ignoring the cpu usage and time it takes there seems to be a noticeable quality difference (sometimes) also mkv encoded file has much lower bitrate (maybe i'm feeling the placebo effect due to media info)

~/Downloads/youtube-dl --write-sub --sub-format srt --sub-lang en --recode-video mkv --embed-subs 'https://www.viki.com/videos/1026409v-my-love-from-the-star-episode-1' -v
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--write-sub', u'--sub-format', u'srt', u'--sub-lang', u'en', u'--recode-video', u'mkv', u'--embed-subs', u'https://www.viki.com/videos/1026409v-my-love-from-the-star-episode-1', u'-v']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.09.01
[debug] Python version 2.7.13 (CPython) - Linux-4.9.0-3-amd64-x86_64-with-debian-9.1
[debug] exe versions: ffmpeg 3.2.7-1, ffprobe 3.2.7-1
[debug] Proxy map: {}
[viki] 1026409v: Downloading video JSON
[viki] 1026409v: Downloading video streams JSON
[debug] Default format spec: bestvideo+bestaudio/best
[info] Writing video subtitles to: My Love From the Star - Episode 1-1026409v.en.srt
[debug] Invoking downloader on u'https://v4.viki.io/1026409v/1026409v_high_480p_1708160136.mp4?e=1535943113&h=b5a50c9b392386623abc0006df6afd58'
[download] Destination: My Love From the Star - Episode 1-1026409v.mp4
[download] 100% of 348.84MiB in 00:01
[ffmpeg] Converting video from mp4 to mkv, Destination: My Love From the Star - Episode 1-1026409v.mkv
[debug] ffmpeg command line: ffmpeg -y -i 'file:My Love From the Star - Episode 1-1026409v.mp4' 'file:My Love From the Star - Episode 1-1026409v.mkv'
Deleting original file My Love From the Star - Episode 1-1026409v.mp4 (pass -k to keep)
[ffmpeg] Embedding subtitles in 'My Love From the Star - Episode 1-1026409v.mkv'
[debug] ffmpeg command line: ffmpeg -y -i 'file:My Love From the Star - Episode 1-1026409v.mkv' -i 'file:My Love From the Star - Episode 1-1026409v.en.srt' -map 0 -c copy -map '-0:s' -map '1:0' '-metadata:s:s:0' 'language=eng' 'file:My Love From the Star - Episode 1-1026409v.temp.mkv'
Deleting original file My Love From the Star - Episode 1-1026409v.en.srt (pass -k to keep)
---
Phr33d0m commented 5 years ago

I think I've found the error causing this. When we download the .mp4 file it embeds two 'RTP' (Data) streams and ffmpeg's -map 0 -c copy doesn't know how to handle those streams so it fails in merging the files.

I tried passing this to --exec:

ffmpeg -i "{}" -map 0:0 -map 0:1 -c copy "tmp-{}" && rm "{}" && mv "tmp-{}" "{}"

Which basically just leaves the audio and video streams inside the .mp4 (in which case the merging works as expected), but --exec does not execute after download (as opposed to the --help description of: Execute a command on the file after downloading) but rather it waits for the merging to run the command, so it does nothing...

Phr33d0m commented 5 years ago

I've found a dirty workaround for this. Changing the options that we pass to ffmpeg to be -map 0:0 -map 0:1 instead of just -map 0 does the trick.