Thursday 22 February 2018

FFMPEG commands - Most common commands

FFMPEG commands - Most common commands used

Question: How to combine two mp4 video files?
ffmpeg -i video1.mp4 -i video2.mp4  -filter_complex concat=n=2:v=1:a=1 -f mp4 -y finalvideo.mp4



Question: How to combine three mp4 video files?
ffmpeg -i video1.mp4 -i video2.mp4   -i video3.mp4 -filter_complex concat=n=2:v=1:a=1 -f mp4 -y finalvideo.mp4



Question: How to combine four mp4 video files?
ffmpeg -i video1.mp4 -i video2.mp4   -i video3.mp4 -filter_complex concat=n=2:v=1:a=1 -f mp4 -y finalvideo.mp4



Question: How to combine two video file (and disable video)?
ffmpeg -i video1.mp4 -i video2.mp4  -filter_complex concat=n=2:v=1:a=1 -f mp4 -vn -y finalvideo.mp4



Question: How to combine two video file (and disable audio)?
ffmpeg -i video1.mp4 -i video2.mp4  -filter_complex concat=n=2:v=1:a=1 -f mp4 -an -y finalvideo.mp4



Question: What are the different -filter_complex options used in ffmpeg?
concat means use the media concatenate.
n means total count of input files.
v means has video? use 0 = no video, 1 = contains video.
a means has audio? use 0 = no audio, 1 = contain audio.
-f means force set file format (to see all supported formats, use ffmpeg -formats)
-vn means disable video 
-an means disable audio 
-y means overwrite output files



Question: How to trim first 10 seconds from the audio using ffmpeg?
ffmpeg -i input_aac.mp4 -ss 10  -acodec copy output_aac.mp4



Question: How to capture the audio between 10 to 30 audio (20 seconds audio)?
ffmpeg -ss 10 -t 20 -i file.mp3 -y output.mp3

-ss 10 - Start at 0 seconds
-t 20 - Capture 20 seconds (from 0, so 0:10 - 0:30).
-y : force output file to overwrite.



Question: How to the rescaling the video with specified size 320:240?
ffmpeg -i input.mp4 -vf scale=320:240 output.mp4



Question: How to the rescaling the image with specified size 320:240?
ffmpeg -i input.jpg -vf scale=320:240 output_320x240.jpg



Question: How to the rescaling the image with specified width size 320 with keeping the Aspect Ratio?
ffmpeg -i input.jpg -vf scale=320:-1 output_320xauto.jpg