Skip to content

Instantly share code, notes, and snippets.

@tru2dagame
Created July 26, 2019 09:58
Show Gist options
  • Select an option

  • Save tru2dagame/41419e176821698a762fe4d169c1f177 to your computer and use it in GitHub Desktop.

Select an option

Save tru2dagame/41419e176821698a762fe4d169c1f177 to your computer and use it in GitHub Desktop.
ffmpeg youtube-dl

Youtube-dl part

go into download folder

cd ~/Downloads/

a. download directly by default settings (Most of these are 1280x720)

youtube-dl [[youtube link]]

b. get the full video format list (There is more higher resolution in the full list, like 2K, even 4K )

youtube-dl [[youtube link]] -F
example:
youtube-dl https://www.youtube.com/watch\?v\=mpjREfvZiDs -F
[youtube] mpjREfvZiDs: Downloading webpage
[youtube] mpjREfvZiDs: Downloading video info webpage
[youtube] mpjREfvZiDs: Extracting video information
[info] Available formats for mpjREfvZiDs:
format code  extension  resolution note
249          webm       audio only DASH audio   55k , opus @ 50k, 3.54MiB
250          webm       audio only DASH audio   73k , opus @ 70k, 4.57MiB
140          m4a        audio only DASH audio  128k , m4a_dash container, mp4a.40.2@128k, 8.80MiB
...
...
...
137          mp4        1920x1080  1080p 1670k , avc1.640028, 30fps, video only, 60.56MiB
248          webm       1920x1080  1080p 2294k , vp9, 30fps, video only, 83.52MiB
264          mp4        2560x1440  1440p 3449k , avc1.640032, 30fps, video only, 127.21MiB
271          webm       2560x1440  1440p 7917k , vp9, 30fps, video only, 248.34MiB
313          webm       3840x2160  2160p 17657k , vp9, 30fps, video only, 983.97MiB
43           webm       640x360    medium , vp8.0, vorbis@128k
18           mp4        640x360    medium , avc1.42001E, mp4a.40.2@ 96k
22           mp4        1280x720   hd720 , avc1.64001F, mp4a.40.2@192k (best)

Download the best video resolution and best audio files

youtube-dl https://www.youtube.com/watch\?v\=mpjREfvZiDs -f 313
youtube-dl https://www.youtube.com/watch\?v\=mpjREfvZiDs -f 140

Combine video and audio file

merge video and audio together

ffmpeg -i file.mp4 -i file.m4a -c:v copy -c:a copy combined.mp4

some helps for ffmpeg

add ass subtitle to the video
ffmpeg -i SHD.mp4 -vf ass=UAP-AC-SHD-2.ass UAP-AC-SHD-subtitles.mp4
convert webm to mp4
ffmpeg -i input_file.webm output_file.mp4
convert mp4 to mov
ffmpeg -i input_file.mp4 -acodec copy -vcodec copy -f mov output_file.mov
convert mov to mp4
ffmpeg -i input_file.mov -vcodec copy -acodec copy output_file.mp4

Install

brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid

brew install youtube-dl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment