[FFmpeg-user] Questions about using CROP filter to pan a jpeg image
Bram van Oosterhout
adriaanbram0712 at gmail.com
Fri Sep 27 14:37:34 EEST 2024
Hi,
I am using ffmpeg to pan left to right over a panorama image using the
crop filter.
I have spent a few days experimenting and got to the solution below.
The numbers are calculated externally. That was easier than retyping
the the ffmpeg formulas
1. scale the image to the desired height, maintaining the aspect ratio
ffmpeg -i IMG_8048.JPG -vf "scale=-1:1080" -y /tmp/On6Ub.JPG
2. the pan across the image using the crop filter with:
ffmpeg -framerate 100 -loop 1 -i /tmp/On6Ub.JPG \
-vf "crop=1920:ih:960*t:0" -t 8 -y outfilecrop.mp4
Step 1 improves the speed of the video creation considerably.
Step 2 uses a high-ish framerate to avoid the jitter reported on the
web. Increasing the image size and then scaling back, as various post
recommend as a remedy for the jitter, slows the conversion hugely.
>From 10's of seconds to multiple minutes.
Here are the details for IMG_8048:
file IMG_8048.JPG
IMG_8048.JPG: JPEG image data, Exif standard:
[TIFF image data, big-endian, direntries=10, manufacturer=Apple,
model=iPhone X, orientation=upper-left, xresolution=150,
yresolution=158, resolutionunit=2, software=16.7.7,
datetime=2024:04:11 18:46:26], baseline, precision 8, 15750x3846,
components 3
This solution works for me, but I got to it by trial and error.
[Q1] Is there a better way?
The expression for x (third parameter in crop: 960*t ) contains
a variable t.
[Q2] What is t. I am unable to find it in the documentation.
[Q3] Is t related to the framerate?
[Q4] There are other magic numbers(?) in various web posts (like: n).
Where are they documented?
In step 2 I use the parameter: -t 8. The documentation suggests that
this will limit the duration of the video to 8 seconds. But with the
settings above the video runs for 14 seconds.
[Q5] What am I missing?
[Q6] General: Is there a way to search the forum archives?
Answers gratefully accepted.
Bram
More information about the ffmpeg-user
mailing list