How to perform basic video editing tasks with ffmpeg on Linux command line?
Cutting at given start and end times
ffmpeg -i input.mp4 -ss 00:01:00 -t 00:02:00 -async 1 output.mp4
Concatenating multiple video files
Create a text file that includes the filenames to concatenate in this format:
file 'file1.mp4'
file 'file2.mp4'
file 'file3.mp4'
You can use the printf command to prepare the text file:
printf "file '%s'\n" * > files.txt
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4
Removing audio
ffmpeg -i input.mp4 -c copy -an output.mp4
Exporting audio into mp3
ffmpeg -i input.mp4 output.mp3
Adding new audio to a video ( replacing its original audio )
ffmpeg -i input_video.mp4 -i input_audio.mp3 -map 0:v -map 1:a -c:v copy -shortest output.mp4
Reducing file size without losing (much) quality
ffmpeg -i input.mp4 -vcodec libx264 -crf 24 output.mp4
Changing frame rate
ffmpeg -i input -filter:v fps=30 output.mp4
Changing width while maintaining the aspect ratio
ffmpeg -i input.mp4 -vf scale=480:-1 output.mp4
Changing height while maintaining the aspect ratio
ffmpeg -i input.mp4 -vf scale=-1:720 output.mp4
Read more here: Source link