Install ffmpeg
brew install ffmpeg
at MacOs.sudo apt install ffmpeg
ffmpeg -version
to check the version.- It provides 3 commands
Convert between different video formats
- just specify the input video file, and the output video file with correct suffix, ffmpeg automatically selects the correct codecs.
- ffmpeg supports conversion for most video types: avi, rmvb, mp4, webm, mkv, mpg, flv, dv, mpeg (used by dvd player)
ffmpeg -codecs
to list all supported files.
Convert video to audio
Add Text Subtitles to a Video
Create gif from video
ffmpeg -i input.mp4 hide_banner output.gif
- the file would be huge
Mix video and audio
Extract part of the video
- -ss
-t - Start: where you want the video to start splitting. The format used is hours:minutes:seconds (00:00:00).
- Duration: the total duration of the video you want to split. The format used is hours:minutes:seconds (00:00:00).
Contact multiple videos
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output
Selecting your codecs for conversion
- -c:a audio_codec
- -c:v video_codec
- -c:a copy, -c:v copy, -c:av:copy
- use same audio, video or both codec
Reduce the size of the video
- -s “size”: set video resolution size (Width x Height)
- -b: set the bitrate
- -r: sets the framerate
- Use
ffmpeg -i input.mp4
to get info about the video
We can use ffplay command to test the effect.
Crop a video
- the format of crop: width:height:left:top.
- -vf means video filter
Resize a video
- -vf “scale=300:-1”
- scale=width:height
- -1 tells ffmpeg to automagically calculate
Rotate a video
- -vf “rotate=90”
ffmpeg -i input.mp4 -vf "rotate=90" -c:a copy out.mp4
Extract images from video
- -r fps: Set frame rate (default 25)
ffmpeg -i input.mp4 image%d.jpg
: this will generate a lot of images
Convert images into a video
ffmpeg -f image2 -i image%d.jpg output.mp4
Add images to audio
Option Lists
- -vn disables the video
- -acodec copy allows to copy the audio stream without touching it
- -an: disables audio
- -s “size”: set video resolution size (Width x Height)
More Tips about ffmpeg
Online Tools
https://file-converter-online.com/ https://rmvb-to-mp4.file-converter-online.com/