Today, we show how to move a video around (left to right, up and down, diagonal) / pan a video using ffmpeg. In this video, the concept behind “moving” a video with ffmpeg is to repeatedly custom crop a larger video to suit a smaller visible frame. All parameters can be customized to move a video right to left, left to right, up to down, down to up...
Another method to pan / move a video around using the "overlay" filter can be found here:
• How to pan a static video | Dynamic v...
EXAMPLES
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
❶ Horizontal move: left - right
→ ffmpeg -i input.mp4 -vf "crop=in_w*0.90:in_h*0.90:(in_w*0.10)/10*t:108,scale=1920:1080" output01.mp4
with:
-i input.mp4 = Reads file «input.mp4» and …
*-vf = … and applies video filters (vf)…
crop = … starting by cutting (crop) a rectangular piece of the video…
in_w*0.90:in_h*0.90 = … that is 90% the size of the original video… (The ffmpeg Guy "Note, in_w = video input width, in_h = video input height")
(in_w*0.10)/10*t = … starting to cut at position x = 0 for t = 0, x = 192 for t = 1, x = 384 at t = 2, ... x = 1920 for t = 10, i. e. moving by 1% video width every (t) seconds…
108 = Cut position on the y axis is constant at 108
scale=1920:1080 = Scales now the cut video (90% of the original size) back to 1920x1080…
output01.mp4 = … and outputs the result to file «output01.mp4»
Note: It kinda works, but the overlay shows a jittery movement (similar to when zooming into a picture with ffmpeg). This will be solved in our next example.
❷ Vertical move: up - down - up (with jitter fix)
→ ffmpeg -i input.mp4 -vf "scale=iw*10:ih*10,crop=in_w*0.90:in_h*0.90:1920:'if(lt(t,5),in_h*0.10/5*t,1080-in_h*0.10/5*(t-5))',scale=hd1080" output02.mp4
with:
-i input.mp4 = Reads file «input.mp4» and …
-vf = … and applies video filters (vf)…
scale=iw*10:ih*10 = … the video is first scaled up to 19200x10800…
crop= = … then a rectangular piece of the video is cut (crop)…
in_w*0.90:in_h*0.90 = … that is 90% the size of the scaled up video.
1920 = Cut position on the x axis is constant at 1920.
'if(lt(t,5),in_h*0.10/5*t,1080-in_h*0.10/5*(t-5))' = Cut position on the y axis starts at 0 then: increases by 2% video height for the first 5 (t) seconds, decreases by 2% video height for the last 5 (t) seconds. The ffmpeg Guy "Note that lt is is "lower than", so if(lt(t,5)... means "if t lower than 5, then...")
scale=hd1080 = The video is then scaled down to 1920x1080 (hd1080)…
output02.mp4 = … and outputs the result to file «output02.mp4»
❸ Diagonal move: top left - bottom right - top left (with jitter fix)
→ ffmpeg -i input.mp4 -vf "scale=iw*10:ih*10,crop=in_w*0.90:in_h*0.90:'if(lt(t,5),in_w*0.10/5*t,1920-in_w*0.10/5*(t-5))':'if(lt(t,5),in_h*0.10/5*t,1080-in_h*0.10/5*(t-5))',scale=hd1080" output03.mp4
with:
-i input.mp4 = Reads file «input.mp4» and …
-vf = … and applies video filters (vf)…
scale=iw*10:ih*10 = … the video is first scaled up to 19200x10800…
crop = … then a rectangular piece of the video is cut (crop)…
in_w*0.90:in_h*0.90 = … that is 90% the size of the scaled up video.
'if(lt(t,5),in_w*0.10/5*t,1920-in_w*0.10/5*(t-5))' = Cut position on the x axis starts at 0 then: increases by 2% video width for the first 5 (t) seconds, decreases by 2% video width for the last 5 (t) seconds.
'if(lt(t,5),in_h*0.10/5*t,1080-in_h*0.10/5*(t-5))' = Cut position on the y axis starts at 0 then: increases by 2% video height for the first 5 (t) seconds, decreases by 2% video height for the last 5 (t) seconds.
scale=hd1080 = The video is then scaled down to 1920x1080 (hd1080)…
output03.mp4 = … and outputs the result to file «output03.mp4»
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
→ Catch up with the FFMPEG guy Channel
• ALL THE VIDEOS FROM THE CHANNEL
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
MUSIC
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
→ Hanging Out - Bruno E.
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
An FFMPEG question?
Ask the FFMPEG guy
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
Watch video How to move a video around | up | down | left | right | Pan a video method 2 online without registration, duration hours minute second in high quality. This video was added by user The FFMPEG guy 19 September 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,257 once and liked it 23 people.