Skip to content

Instantly share code, notes, and snippets.

@dreness dreness/ytdl-hfr-mux.txt
Last active Aug 29, 2015

Embed
What would you like to do?
The magic youtube-dl incantation to prefer high frame-rate content and mux the separate audio and video into a single file.
# list the available formats for a youtube URL.
bash-3.2$ youtube-dl -F 'https://www.youtube.com/watch?v=NlFU2wM-f8g'
[youtube] NlFU2wM-f8g: Downloading webpage
[youtube] NlFU2wM-f8g: Extracting video information
[youtube] NlFU2wM-f8g: Downloading DASH manifest
[info] Available formats for NlFU2wM-f8g:
format code extension resolution note
140 m4a audio only DASH audio 129k , m4a_dash container, aac @128k (44100Hz), 5.35MiB (worst)
141 m4a audio only DASH audio 255k , m4a_dash container, aac @256k (44100Hz), 10.62MiB
160 mp4 230x144 DASH video 112k , 15fps, video only, 4.34MiB
133 mp4 384x240 DASH video 275k , 30fps, video only, 10.22MiB
134 mp4 576x360 DASH video 348k , 30fps, video only, 7.92MiB
135 mp4 768x480 DASH video 701k , 30fps, video only, 16.99MiB
136 mp4 1152x720 DASH video 1437k , 30fps, video only, 36.61MiB
298 mp4 1152x720 DASH video 2142k , h264, 60fps, video only, 49.32MiB
137 mp4 1728x1080 DASH video 2859k , 30fps, video only, 76.88MiB
299 mp4 1728x1080 DASH video 4612k , h264, 60fps, video only, 104.16MiB
264 mp4 1920x1440 DASH video 5790k , 30fps, video only, 139.80MiB
17 3gp 176x144
36 3gp 320x240
5 flv 400x240
43 webm 640x360
18 mp4 640x360
22 mp4 1280x720 (best)
# Prefer 1080 HFR (high frame rate) video + bestaudio, then 720 HFR video + best audio,
and then fall back to the default, which is the one Youtube tags 'best', which is
usually the best *muxed* file and is very commonly 1280x720 mp4. DASH stores audio and
video in separate files, however iOS isn't quite ready for that yet, so we ask youtube-dl
to mux the audio and video into one output file (using the "v_format+a_format" args to
the -f option below). The reason I don't just say bestvideo+bestaudio is because bestvideo
would be 1440p30, and I'd much rather have 1080p60.
bash-3.2$ youtube-dl -f 299+bestaudio/298+bestaudio 'https://www.youtube.com/watch?v=NlFU2wM-f8g'
[youtube] NlFU2wM-f8g: Downloading webpage
[youtube] NlFU2wM-f8g: Extracting video information
[youtube] NlFU2wM-f8g: Downloading DASH manifest
[download] Destination: Bandicam Banana Phone and discrete audio tracks-NlFU2wM-f8g.f299.mp4
[download] 100% of 104.16MiB in 00:17
[download] Destination: Bandicam Banana Phone and discrete audio tracks-NlFU2wM-f8g.f141.m4a
[download] 100% of 10.62MiB in 00:01
[ffmpeg] Merging formats into "Bandicam Banana Phone and discrete audio tracks-NlFU2wM-f8g.mp4"
# Look at the streams in the output file. There are two streams!
bash-3.2$ ffprobe "Bandicam Banana Phone and discrete audio tracks-NlFU2wM-f8g.mp4" 2>&1 | grep Stream
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1728x1080 [SAR 1:1 DAR 8:5], 2497 kb/s, 60 fps, 60 tbr, 90k tbn, 120 tbc (default)
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 253 kb/s (default)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.