Sunday, September 20, 2020

Commands useful along with Youtube-dl

The following is to download a only a particular part of a video from YouTube 

ffmpeg -i $(youtube-dl -f 22 --get-url https://www.youtube.com/watch?v=cmne_rokrs4) -ss 00:10:10 -to 00:12:52 -c:v copy -c:a copy happy.mp4

Or you can download all the video first and then cut some parts following the instructions here.

If you want to concatenate MP4 videos (you can prepare an script):

echo file input1.mp4 >  mylist.txt

echo file input2.mp4 >>  mylist.txt

ffmpeg -f concat -i mylist.txt -c copy output.mp4

To list all subs for a video:

youtube-dl --list-subs URL

To download all subs, but not the video:

youtube-dl --all-subs --skip-download URL

Or you can only download one subtitle

youtube-dl --write-sub --sub-lang en --skip-download URL

Or  for downloading the automatically generated subtitles

youtube-dl --write-auto-sub --skip-download URL

If you want to convert the subtitles do:

ffmpeg -i input.vtt output.srt

The following is to convert videos to a higher speed. For instance, if you want to multiply by 1.15, the command is:

ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.87*PTS[v];[0:a]atempo=1.15[a]" -map "[v]" -map "[a]" output.mkv

#The "setpts" corresponds to the inversed speed (in this case 100/1.25 = 0.8)

#while the "atempo" corresponds to the desired direct speed of the video.

#Those values are proportionally inversed.

#For a 25% higher speed output video the values

#would be "setpts=0.8*PTS" and "atempo=1.25"

100/1.25 = 0.8

References: