FFMPEG has become very popular for so long time as a tool that can help us manipulate, convert, or configure video and audio data. We can resize our video, convert a file into a different container, change the bitrate, embed subtitles, or even stream real-time video. These are a few examples of its utilization.
Converting file into a different container
For example, we want to convert an MKV file into MP4 without changing its codec.
ffmpeg -i input.mkv -codec copy output.mp4
Or, we want to convert an MP4 file into Webm with some customizations.
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 28 -b:v 0 -b:a 128k -c:a libopus output.webm
Change video size
We can resize a video width and height too.
ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4
We can set the width or height to "-1" to keep the origin ratio. Note that some codecs require a size that can be divided by 2 to be successful.
ffmpeg -i input.mp4 -vf scale=1280:-1 output.mp4
Insert subtitles
We can attach a subtitle file to a video container.
ffmpeg -i input.mp4 -i input.srt -c copy -c:s mov_text output.mp4
Extracting subtitles from multi-track video
If a video file is attached with subtitles, we can generate the ".srt" file from it too.
ffmpeg -i input.mkv -map 0:s:0 subs.srt
Embed subtitles
We can also append the subtitle texts into video frames directly.
ffmpeg -i input.mp4 -vf subtitles=input.srt output.mp4
Download Live Stream Video
We can download live steam video from its manifest file and convert it to MP4.
ffmpeg -i http://source.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4
Comments
Post a Comment