Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Allow rendering subtitles besides simply adding a subtitle stream (was: Feature request "-f bestsubtitle") #9655
Comments
|
How to determine the "best" one among several subtitles? |
|
How to burn subtitles into video |
|
@yan12125 nails it with his comment. Why is VTT better than SRT? VTT is nice for streaming sites, except for Archive.org which requires SRT. Perhaps use |
|
There are more formats. Besides WebVTT and SRT, TTML, SMPTE-TT, SSA are also common. For videos and audios, bitrates, filesizes and resolutions are the three primary metrics. Are there comparable quantities for subtitles? It no, hard-coding order may also be acceptable.
@donizyo FYI: this is already implemented via |
|
but what about the feature download subtitle only? |
|
suppose i've downloaded a video and an audio and they are merged into a .mp4 file but i forgot to download auto generated subtitle |
|
|
just ran a test, |
|
Please post the output your command. Don't forget to add |
$ ytdl --playlist-start 29 "https://www.youtube.com/playlist?list=PLjyuVPBuorqIhlqZtoIvnAVQ3x18sNev4"
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['--verbose', '--proxy', 'http://127.0.0.1:8087/', '--socket-timeout', '1200', '--yes-playlist', '-o', '%(playlist_index)s.%(ext)s', '--user-agent', 'Mozilla/5.0 (Windows NT 6.0; rv:46.0) Gecko/20100101 Firefox/46.0', '--write-auto-sub', '--sub-format', '"srt/best"', '--embed-subs', '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '--recode-video', 'mp4', '--no-post-overwrites', '-k', '--playlist-start', '29', 'https://www.youtube.com/playlist?list=PLjyuVPBuorqIhlqZtoIvnAVQ3x18sNev4']
[debug] Encodings: locale cp936, fs mbcs, out cp936, pref cp936
[debug] youtube-dl version 2016.05.30.2
[debug] Python version 3.5.1 - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg N-80123-gd74cc61, ffprobe N-80123-gd74cc61
[debug] Proxy map: {'http': 'http://127.0.0.1:8087/', 'https': 'http://127.0.0.1:8087/'}
[youtube:playlist] PLjyuVPBuorqIhlqZtoIvnAVQ3x18sNev4: Downloading webpage
[download] Downloading playlist: Blender Video Editing (2.7X series [Current Series])
[youtube:playlist] playlist Blender Video Editing (2.7X series [Current Series]): Downloading 1 videos
[download] Downloading video 1 of 1
[youtube] XPndVNEA1JQ: Downloading webpage
[youtube] XPndVNEA1JQ: Downloading video info webpage
[youtube] XPndVNEA1JQ: Extracting video information
[youtube] XPndVNEA1JQ: Looking for automatic captions
[youtube] XPndVNEA1JQ: Downloading MPD manifest
WARNING: No subtitle format found matching ""srt/best"" for language en, using vtt
[info] Writing video subtitles to: 29.en.vtt
[debug] Invoking downloader on 'https://r1---sn-i3b7kn7z.googlevideo.com/videoplayback?id=5cf9dd54d100d494&itag=137&source=youtube&requiressl=yes&nh=IgpwcjA0LmhrZzAxKgkxMjcuMC4wLjE&mv=u&ms=au&mn=sn-i3b7kn7z&mm=31&pl=17&ratebypass=yes&mime=video/mp4&gir=yes&clen=53360738&lmt=1449224937977359&dur=461.033&key=dg_yt0&fexp=9413138,9416126,9416891,9422596,9428398,9430794,9431012,9433096,9433380,9433457,9433946,9434086,9435527,9435850,9435876,9435922,9437027,9437067,9437255,9437553,9438051,9438244&sver=3&mt=1464807759&upn=lO_NJqBAe4I&signature=5C4D4A9A530173AFD1312373E346142F983AE774.3A1E92942C7DF0869D2642AEB5D72231FB6541E8&ip=171.88.98.161&ipbits=0&expire=1464830061&sparams=ip,ipbits,expire,id,itag,source,requiressl,nh,mv,ms,mn,mm,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: 29.f137.mp4
[download] 100% of 50.89MiB in 00:42
[debug] Invoking downloader on 'https://r1---sn-i3b7kn7z.googlevideo.com/videoplayback?id=5cf9dd54d100d494&itag=140&source=youtube&requiressl=yes&nh=IgpwcjA0LmhrZzAxKgkxMjcuMC4wLjE&mv=u&ms=au&mn=sn-i3b7kn7z&mm=31&pl=17&ratebypass=yes&mime=audio/mp4&gir=yes&clen=7324094&lmt=1449224655848039&dur=461.101&key=dg_yt0&fexp=9413138,9416126,9416891,9422596,9428398,9430794,9431012,9433096,9433380,9433457,9433946,9434086,9435527,9435850,9435876,9435922,9437027,9437067,9437255,9437553,9438051,9438244&sver=3&mt=1464807759&upn=lO_NJqBAe4I&signature=9A38A0E15065F1936C3EB430BEAC74C55F12E4C7.2C91A12B3BFEC485AFDE60CB10DE8188B85FA947&ip=171.88.98.161&ipbits=0&expire=1464830061&sparams=ip,ipbits,expire,id,itag,source,requiressl,nh,mv,ms,mn,mm,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: 29.f140.m4a
[download] 100% of 6.98MiB in 00:14
[ffmpeg] Merging formats into "29.mp4"
[debug] ffmpeg command line: ffmpeg -y -i file:29.f137.mp4 -i file:29.f140.m4a -c copy -map 0:v:0 -map 1:a:0 file:29.temp.mp4
[ffmpeg] Not converting video file 29.mp4 - already is in target format mp4
[ffmpeg] Embedding subtitles in '29.mp4'
[debug] ffmpeg command line: ffmpeg -y -i file:29.mp4 -i file:29.en.vtt -map 0 -c copy -map -0:s -c:s mov_text -map 1:0 -metadata:s:s:0 language=eng file:29.temp.mp4
[download] Finished downloading playlist: Blender Video Editing (2.7X series [Current Series]) |
|
According to log vtt is embedded just fine. Post the output of |
$ ffmpeg -i 29.mp4
ffmpeg version N-80123-gd74cc61 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 24.100 / 55. 24.100
libavcodec 57. 43.100 / 57. 43.100
libavformat 57. 37.101 / 57. 37.101
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 46.100 / 6. 46.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '29.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.37.101
Duration: 00:07:44.98, start: 0.000000, bitrate: 1048 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 922 kb/s, 30 fps, 30 tbr, 90k tbn (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
Metadata:
handler_name : SubtitleHandler
At least one output file must be specified |
|
|
for now, i'm using my own burning function... (:зゝ∠) function burn_subtitle
{
# param1: video extension
ext_vid=$1
# param2: subtitle extension
ext_sub=$2
for file in *.$ext_vid; do
idx=`expr index $file "."`;
((idx-=1));
name=${file:0:$idx};
file_sub=$name"."$ext_sub;
file_out=$name"_out.mp4";
echo "[BURN] Merge $file and $file_sub into $file_out ..."
if [ ! -f $file_sub ]; then
echo "[BURN] File $file_sub not found!"
continue;
fi
ffmpeg -loglevel 0 -i $file -vf subtitles=$file_sub $file_out
done
}
and it works fine |
|
Please check against the file generated by youtube-dl but not your script. |
|
@yan12125 |
|
Could you point out the "problematic output"? Seems both youtube-dl and ffmpeg outputs are fine. |
|
@yan12125 $ ffmpeg -i 29.mp4
ffmpeg version N-80123-gd74cc61 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 24.100 / 55. 24.100
libavcodec 57. 43.100 / 57. 43.100
libavformat 57. 37.101 / 57. 37.101
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 46.100 / 6. 46.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '29.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.37.101
Duration: 00:07:44.98, start: 0.000000, bitrate: 1048 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 922 kb/s, 30 fps, 30 tbr, 90k tbn (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
Metadata:
handler_name : SubtitleHandler
At least one output file must be specifiedPART
|
|
VLC and windows media player won't work |
|
@yan12125 |
Yes.
Confirmed. VLC 2.2.3 can't recognize the embedded WebVTT subtitle. VLC nightly needed. Windows Media Player...Is it really a functional media player? :D To sum up: the current approach adds a subtitle stream. youtube-dl need some way to render the subtitle directly on the video. Is it what you want? |
|
yep, i think i'm gonna render it with |
|
When will be implemented (Hardsubs)? |

Please follow the guide below
xinto all the boxes [ ] relevant to your issue (like that [x])Make sure you are using the latest version: run
youtube-dl --versionand ensure your version is 2016.05.30.2. 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
If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:
Add
-vflag to your command line you run youtube-dl with, copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):If the purpose of this issue is a site support request please provide all kinds of example URLs support for which should be included (replace following example URLs by yours):
Description of your issue, suggested solution and other information
there are already
-fparametersbestvideoandbestaudiobut i wonder why there is nobestsuborbestsubtitleto help burn subtitles into video filesFor example:
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]+bestsubtitle[ext=vtt]/best"will burn both best audio and best subtitle into the mp4 file.
--write-auto-suboption should be automatically used ifbestsubtitleis invoked but no subtitle is availablebestsubtitleis invoked withoutbestvideoandbestaudio, download best subtitle only