This wiki-page tries to cover the basics for editing videos. You will learn how to download a video with youtube-dl, how to cut it with ffmpeg and how to add subtitles. For further instructions please go to the documentation page from ffmpeg. Any contribution to this wiki page is highly appreciated and please also keep in mind that I only tested this with my Linux System and it might not work well on other systems.
Download a Video
For this you can use youtube-dl. Youtube-dl is available in the most package-managers like: apt, dnf or pacman. To install youtube-dl, first search for the package and then install it in your package manager:
$ apt-cache search youtube-dl $ apt install somethingWithYoutube-dl
After you have installed youtube-dl it is ready for use. You can download any video with the video link. For example: $ youtbe-dl -F linkToVideo #shows you the available formats.
A possible output could look like this:
[youtube] Wf9bvwPlzgs: Downloading webpage [youtube] Wf9bvwPlzgs: Downloading video info webpage [info] Available formats for Wf9bvwPlzgs: format code extension resolution note 249 webm audio only tiny 54k , opus @ 50k (48000Hz), 13.39MiB 250 webm audio only tiny 66k , opus @ 70k (48000Hz), 16.56MiB ... 22 mp4 1280x720 720p 820k , avc1.64001F, mp4a.40.2@192k (44100Hz) (best)
For choosing the best quality you can type: $ youtube-dl -f 22 linkToVideo
Now the download will start and the video will be saved to the current folder you are in. If you are unsure of which one this is type: $ pwd #This will tell you your current working directory
For editing videos you can use ffmpeg - ffmpeg video converter. You can download this package following the same procedure as described with youtube-dl. ffmpeg is a very useful and mighty tool. To get an overview you can type:
$ man ffmepg #Opens the man-page
$ ffmpeg --help #Shows the help. To better read it pipe it to less by adding a |less ($ ffmpeg --help |less)
The displayed information can give you a short overview on what ffmpeg is able to do.
Format a video
$ ffmepg -i input.avi output.mp4
Cut a video
$ ffmpeg -i input.mp4 -ss 00:00:00.0 -c copy -t 01:00:17.0 output.mp4 The first timestamp is the starting point and the second one is the duration of the sequence you want to cut. So in the case above our video would end after 1 hour and 17 seconds.
For this you first need to create a subtitles file.
- Open your Editor (like vim, gedit or atom)
Go to the Menu -> Save as -> choose the folder you have the video in -> Name.srt
A subtitles file looks like this:
0 00:00:04,00 --> 00:00:09,99 Hmhm, tock tock, hmhm 1 00:00:10,00 --> 00:00:15,44 Hello and welcome! 2 00:00:15,48 --> 00:00:21,99 more text .... 3 00:00:38,05 --> 00:00:43,79 Thank you for listening and good bye.
Now to add the subtitles file to the video there are different options.
For an avi Video:
$ ffmpeg -i input.avi -vf subtitles=subtitle.srt output.avi
For mp4 you can do it like this:
$ ffmpeg -i input.mp4 -i xyz.srt -c copy -c:s mov_text output.mp4
If your subtitles file was correct you now have an output.mp4 with subtitles.
If you want to add subtitles to one of the youtube videos you can follow those steps:
- 1) Login to the fsfe-youtube channel.
2) Go to the Video -> click on "Settings" -> Subtitles/CC -> Add subtitles/cc -> Add new subtitles or cc -> choose language -> upload a file -> choose srt file
3) To enforce the subtitles: Go to "YouTube Studio" -> Videos (on the right side) -> mark the video where you want to enforce the subtitles -> Edit -> Tags -> type: yt:cc=on -> update video