0% found this document useful (0 votes)
99 views

Ffmpeg Commands

The document contains several examples of using ffmpeg to edit video files. Specifically, it shows how to: 1. Trim sections of video and audio, change playback speed of audio, and concatenate sections back together. 2. Add overlays like images, gifs, and text onto video. 3. Change encoding settings and output format/container. 4. Get metadata like video dimensions from a file. 5. Add fading and other effects between trimmed sections.

Uploaded by

Tilak Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views

Ffmpeg Commands

The document contains several examples of using ffmpeg to edit video files. Specifically, it shows how to: 1. Trim sections of video and audio, change playback speed of audio, and concatenate sections back together. 2. Add overlays like images, gifs, and text onto video. 3. Change encoding settings and output format/container. 4. Get metadata like video dimensions from a file. 5. Add fading and other effects between trimmed sections.

Uploaded by

Tilak Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

ffmpeg -i ram.

mp4 -filter_complex [0:v]trim=0:7,setpts=PTS-STARTPTS[v1];


[0:v]trim=7:12,setpts=2*(PTS-STARTPTS)[v2];[0:v]trim=12,setpts=PTS-STARTPTS[v3];
[0:a]atrim=0:7,asetpts=PTS-STARTPTS[a1];[0:a]atrim=7:12,asetpts=PTS-
STARTPTS,atempo=0.5[a2];[0:a]atrim=12,asetpts=PTS-STARTPTS[a3];[v1][a1][v2][a2][v3]
[a3]concat=n=3:v=1:a=1 -b:v 2097k -r 60 -vcodec mpeg4 ram1.mp4

//with -map [v] -map[a]


ffmpeg -i ram.mp4 -filter_complex [0:v]trim=0:7,setpts=PTS-STARTPTS[v1];
[0:v]trim=7:12,setpts=2*(PTS-STARTPTS)[v2];[0:v]trim=12,setpts=PTS-STARTPTS[v3];
[0:a]atrim=0:7,asetpts=PTS-STARTPTS[a1];[0:a]atrim=7:12,asetpts=PTS-
STARTPTS,atempo=0.5[a2];[0:a]atrim=12,asetpts=PTS-STARTPTS[a3];[v1][a1][v2][a2][v3]
[a3]concat=n=3:v=1:a=1[v][a] -map [v] -map [a] -b:v 2097k -r 60 -vcodec mpeg4
ram1.mp4

//reverse a part of video


ffmpeg -i ram.mp4 -filter_complex [0:v]trim=0:12,setpts=PTS-STARTPTS[v1];
[0:v]trim=7:12,reverse,setpts=PTS-STARTPTS[v2];[0:v]trim=7,setpts=PTS-STARTPTS[v3];
[0:a]atrim=0:12,asetpts=PTS-STARTPTS[a1];[0:a]atrim=7:12,asetpts=PTS-STARTPTS[a2];
[0:a]atrim=7,asetpts=PTS-STARTPTS[a3];[v1][a1][v2][a2][v3][a3]concat=n=3:v=1:a=1[v]
[a] -map [v] -map [a] -b:v 2097k -r 60 -vcodec mpeg4 ram1.mp4

ffmpeg -i ram.mp4 -filter_complex [0:v]trim=0:3,setpts=PTS-STARTPTS[v1];


[0:v]trim=3:7,fade=t=in:st=0:d=2,fade=t=out:st=2:d=2,setpts=PTS-STARTPTS[v2];
[0:v]trim=7,setpts=PTS-STARTPTS[v3];[0:a]atrim=0:3,asetpts=PTS-STARTPTS[a1];
[0:a]atrim=3:7,asetpts=PTS-STARTPTS[a2];[0:a]atrim=7,asetpts=PTS-STARTPTS[a3];[v1]
[a1][v2][a2][v3][a3]concat=n=3:v=1:a=1 -b:v 2097k -r 60 -vcodec mpeg4 ram1.mp4
-vf fade=t=in:st=3:d=5,fade=t=out:st=

//concate video of different framerates in .mkv format


ffmpeg -i ram.mp4 -i ram1.mp4 -filter_complex [0:v:0][0:a:0][1:v:0]
[1:a:0]concat=n=2:v=1:a=1[outv][outa] -map [outv] -map [outa] output.mkv

//to fast the process


-c:v libx264 -preset ultrafast

//gif,png etc overlay


ffmpeg -i ram.mp4 -i light.png -filter_complex [1:v]scale=320:394[ovr1],[0:v]
[ovr1]overlay=0:0:enable='between(t,0,16)' -c:a copy ram1.mp4
ffmpeg -i ram.mp4 -i 1.png -filter_complex overlay=(main_w-overlay_w)/2:(main_h-
overlay_h)/2:enable='between(t,0,7)' -c:a copy ram1.mp4
//for gif
ffmpeg -i ram.mp4 -ignore_loop 0 -i glitter.gif -filter_complex
[1:v]scale=320:394[ovr1],[0:v][ovr1]overlay=0:0:shortest=1:enable='between(t,0,16)'
-c:a copy ram1.mp4

//get width and height of video or image


ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of json
ram1.mp4

//perfect textoverlay
ffmpeg -y -i ram.mp4 -vf drawtext="fontsize=30:fontfile=cute.ttf:text='jai shree
ram'":x=w-tw-10:y=h-th-10 -c:v libx264 -preset ultrafast ram1.mp4
//for adding text
var POSITION_BOTTOM_RIGHT = "x=w-tw-10:y=h-th-10"
var POSITION_TOP_RIGHT = "x=w-tw-10:y=10"
var POSITION_TOP_LEFT = "x=10:y=10"
var POSITION_BOTTOM_LEFT = "x=10:h-th-10"
var POSITION_CENTER_BOTTOM = "x=(main_w/2-text_w/2):y=main_h-(text_h*2)"
var POSITION_CENTER_ALLIGN = "x=(w-text_w)/2: y=(h-text_h)/3"

You might also like