

Useful FFmpeg commands for video editing
source link: https://blog.shadura.me/2020/08/16/useful-ffmpeg-commands/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Useful FFmpeg commands for video editing
Sun 16 August 2020 By Andrej ShaduraAs a response to Antonio Terceiro’s blog post, I’m publishing some FFmpeg commands I’ve been using recently.
Embedding subtitles
Sometimes you have a video with subtitles in multiple languages and you don’t want to clutter the directory with a lot of similarly-named files — or maybe you want to be able to easily transfer the video and subtitles at once. In this case, it may be useful to embed to subtitles directly into the video container file.
ffmpeg -i video.mp4 -i video.eng.srt -map 0:v -map 0:a -c copy -map 1 \ -c:s:0 mov_text -metadata:s:s:0 language="eng" video-out.mp4
This commands recodes the subtitle file into a format appropriate for the MP4 container and embeds it with a metadata element telling the video player what language it is in. You can add multiple subtitles at once, or you can also transcode the audio to AAC while doing so (I found that a lot of Android devices can’t play Ogg Vorbis streams):
ffmpeg -i video.mp4 -i video.deu.srt -i video.eng.srt -map 0:v -map 0:a \ -c:v copy -c:a aac -map 1 -c:s:0 mov_text -metadata:s:s:0 language="deu" \ -map 2 -c:s:1 mov_text -metadata:s:s:1 language="eng" video-out.mp4
‘Hard’ subtitles
Sometimes you need to play the video with subtitles on devices not supporting them. In that case, it may be useful to ‘hardcode’ the subtitles directly into the video stream:
ffmpeg -i video.mp4 -vf subtitles=video.eng.srt video-out.mp4
Unfortunately, if you also want to apply more transformations to the video, it starts getting tricky, the -vf
option is no longer enough:
ffmpeg -i video.mp4 -i overlay.jpg -filter:a "volume=10" \ -filter_complex '[0:v][1:v]overlay[outv];[outv]subtitles=video.eng.srt' \ video-out.mp4
This command adds an overlay to the video stream (in my case I overlaid a full frame over the original video offering some explanations), increases the volume ten times and adds hard subtitles.
P.S. You can see the practical application of the above in this video with a head of one of the electoral commissions in Belarus forcing the members of the staff to manipulate the voting results. I transcribed the video in both Russian and English and encoded the English subtitles into the video.
Recommend
-
26
Often times, there is a need to check the size of the sub-directories or files in a project, on a live or development server, or just at our local machine. Here is a list of useful commands that you can leverage...
-
5
Git useful commands, code management Reading Time: 6 minutes Hi all. In this blog, we will continue to explore some of the useful git commands. These commands would help when we are working on a remote shared re...
-
6
Some useful MySQL/MariaDB commands to create and provide access to a database. ...
-
9
Useful PostgreSQL Queries and Commands · GitHub Instantly share code, notes, and snippets. Useful PostgreSQL Queries and Commands ...
-
9
Useful Windows 8 Narrator commands18 July 2012Сообщение для российских читателейWindows 8 introduces several improvements to Narrator, its built in speech capability. Like VoiceOver in the early days, there is much t...
-
3
Programming Language Theory • System ProgrammingNOTE: useful nix commandsEmail: [email protected]:
-
12
In addition to Harvard's fantastic list, we list some other convenient SLURM commands. Delay an enqueued job from runnin...
-
7
Imagic: AI Image Editing from Text CommandsImagic: AI Image Editing from Text CommandsOctober 24th 2022 6 min by
-
4
A useful guide to FFmpeg [LWN.net] User: Password: | |
-
11
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK