Sub topic 9
Adding a Zoom with Crop and Scale
Assume you understand basic timeline editing, video dimensions, and how to run ffmpeg commands. You also need a lecture recording in a common format such as MP4. This chapter uses a crop-and-scale method that works well for slides, screen recordings, and diagrams.
How a zoom works
A digital zoom does not move the camera. It selects a smaller rectangle from the original frame and enlarges that rectangle to the output size.
For a 1920×1080 video, cropping to 1280×720 removes the outer areas while preserving the 16:9 aspect ratio. Scaling the crop back to 1920×1080 makes the selected area fill the frame.
The crop has four values:
- Width of the selected area
- Height of the selected area
- Horizontal position of the crop's top-left corner
- Vertical position of the crop's top-left corner
For a centered crop, the positions are:
x = (iw - crop_width) / 2y = (ih - crop_height) / 2
Here, iw and ih mean the input width and height.
Implementing the zoom with FFmpeg
The following command extracts a ten-second segment beginning at 20 seconds. It crops the central region to about 1.5 times magnification and scales the crop back to 1920×1080.
ffmpeg -ss 20 -t 10 -i lecture.mp4 \
-vf "crop=iw/1.5:ih/1.5:iw/4:ih/4,scale=1920:1080" \
-c:v libx264 -c:a aac zoomed_segment.mp4The crop expression uses the input dimensions:
iw/1.5andih/1.5produce the crop width and height.iw/4andih/4place the crop at the center.scale=1920:1080restores the output dimensions.-c:v libx264re-encodes the video because the pixels changed.-c:a aacencodes the audio for the new MP4 file.
Check the source dimensions before choosing fixed output values:
ffprobe -v error -select_streams v:0 \
-show_entries stream=width,height \
-of default=noprint_wrappers=1 lecture.mp4If the source uses a different aspect ratio, calculate the crop dimensions carefully. A mismatched crop can stretch the image or add unwanted framing.
Choosing the zoom area
A centered zoom works when the important content is in the middle. For a slide with code on the right, move the crop horizontally by increasing the x value. Keep the crop inside the source frame.
Preview the result and check:
- The intended text or diagram remains visible.
- Text is readable without becoming blurry.
- The speaker or cursor is not cut off unexpectedly.
- The zoom does not make the viewer lose the surrounding context.
- Audio remains aligned with the enlarged video.
For a longer lecture, create the zoom as a short segment or use editor keyframes to change the crop over time. A fixed crop is simpler and easier to review.
Exercise
A 1920×1080 slide has important content on the right side. What should you change in the crop filter to move the zoomed area right?
Show answer
Increase the crop's third value, the x position, while keeping the crop width and height unchanged.