Learning how to crop video using FFmpeg gives you precise control over what viewers see without relying on a visual editor. Whether you need to remove black bars, cut out unwanted edges, prepare a vertical clip, or focus attention on a subject, FFmpeg can handle the job from the command line.
Cropping changes the visible frame, not the duration of the video. It is different from trimming, which removes time from the beginning or end. With the right crop values, you can create a cleaner composition while keeping the important action in view.
This guide explains the crop filter, the values it needs, useful command patterns, common errors, and ways to check your results. You will also learn how dimensions, aspect ratios, and encoding choices affect a cropped export.
FFmpeg crops video through its crop filter. The filter takes four main values: the output width, output height, horizontal starting position, and vertical starting position. In simple terms, you tell FFmpeg how large the new frame should be and where that frame begins inside the original video.
A crop is usually written as crop=width:height:x:y. If a source is 1920 by 1080 pixels and you want to remove 100 pixels from both the left and right edges, the new width becomes 1720. The starting x position becomes 100, while the height and y position can remain unchanged.
The common command pattern uses an input file, the video filter option, and an output file. For example, you would apply the crop filter during conversion and let FFmpeg re-encode the altered video stream. Audio can often be copied because cropping does not change it.
Before choosing values, inspect the original dimensions and decide what must stay visible. A crop that looks mathematically correct can still cut off a face, subtitle, logo, or important action. Previewing a short test export is usually faster than guessing repeatedly.
Cropping normally requires video re-encoding, because the pixels in every frame are being changed. The output quality therefore depends on the chosen encoder settings. Use a suitable modern video codec and a sensible quality setting so the crop does not introduce unnecessary compression artifacts.
How Does FFmpeg Video Cropping Work?
Identify The Source Frame
Start by finding the video’s width and height. These dimensions define the coordinate system used by the crop filter. The upper-left corner is position zero, zero, and all crop measurements are counted in pixels from that point. Knowing the source size prevents impossible crop values and makes aspect-ratio planning much easier.
Choose The Output Width
The crop width is the number of pixels that remain across the new video. It must fit within the source frame after the horizontal offset is included. For predictable encoding, especially with common pixel formats, an even width is a practical choice because many codecs process image data in pairs of pixels.
Choose The Output Height
The crop height is the number of pixels that remain from top to bottom. Select it according to the platform, composition, and content you want to preserve. An even height is generally safest for broad compatibility. If you are removing letterboxing, measure only the active picture area rather than guessing from the screen shape.
Set The Horizontal Position
The x value determines how far from the left edge the crop begins. An x value of zero keeps the left side of the source frame, while a larger value shifts the visible region to the right. Centered crops can be calculated by subtracting the crop width from the input width and dividing the result by two.
Set The Vertical Position
The y value determines how far down from the top edge the crop begins. Use it to remove top overlays, bottom black bars, or distracting objects near an edge. A centered vertical crop follows the same logic as a centered horizontal crop, using the source height and desired crop height.
Apply The Crop Filter
Add the crop expression through FFmpeg’s video filter option. The filter processes every video frame and creates a new visible frame with the requested dimensions and position. Because the picture is transformed, FFmpeg must encode the video again. The original file remains unchanged when you write to a new output name.
Review The Export Carefully
After exporting, watch the result from beginning to end or at least sample several points across the timeline. Movement can make a crop that looked fine on one frame fail later. Check subtitles, lower-thirds, scene changes, and shots with people near the edge before treating the crop settings as final.
Key Choices When Cropping Video With FFmpeg
1. Aspect ratio should match the intended viewing format. A square, widescreen, vertical, or custom crop should be chosen deliberately instead of forcing a familiar ratio onto every source.
2. Subject placement matters more than symmetry. Centering a crop is convenient, but the most important person or object may be positioned off center in the original shot.
3. Pixel dimensions affect output quality. Cropping cannot add detail, so avoid making a tiny remaining area serve as a large high-resolution export unless some loss of sharpness is acceptable.
4. Codec compatibility benefits from even dimensions. Odd values can work in some cases, but even width and height values reduce the chance of encoder errors or playback issues.
5. Audio handling is separate from visual cropping. Since the soundtrack is not visually altered, it can often remain unchanged while the video stream is processed.
Benefits Of Cropping Video With FFmpeg
- Precise Control: You can remove exactly the pixels you do not need instead of relying on approximate drag-and-drop handles in an editor.
- Repeatable Results: Once you have a working crop expression, you can apply the same framing to many similarly sized videos with consistent results.
- Efficient Batch Work: Command-line processing is especially useful when a project contains many clips that require identical removal of borders, overlays, or camera edges.
- Flexible Framing: FFmpeg lets you prepare one source for different destinations, such as a vertical social clip, a square preview, or a tighter widescreen version.
- No Project File Required: The crop settings can be stored in a command or script, making the workflow simple to document and repeat later.
- Useful Filter Combinations: Cropping can be combined with scaling, padding, rotation, subtitles, and other filters when a video needs several technical adjustments.
- Reliable Automation: For predictable source footage, calculated crop values make automated production pipelines more dependable and reduce manual editing time.
Common FFmpeg Crop Mistakes To Avoid
Guessing Dimensions Without Testing
A rough estimate may leave a thin black edge or remove part of the picture. Export a short sample first and inspect it at normal size. If the source has static borders, use careful measurements or a detection workflow rather than changing values randomly until the result seems close enough.
Confusing Crop Order
The crop filter expects width, height, x, and y in that order. Mixing up the output size with the starting position can produce an unexpected frame or an invalid request. Write down the source dimensions and calculate each value separately before building the final filter expression.
Ignoring Moving Subjects
A fixed crop does not follow a person, product, or camera movement. A shot may look excellent at the opening frame and become unusable later when the subject moves toward an edge. Review the full shot and consider a less aggressive crop if the composition changes over time.
Using Odd Dimensions Carelessly
Some encoders and pixel formats expect dimensions divisible by two. An odd crop width or height can trigger errors, automatic adjustments, or compatibility problems. When exact pixel precision is not essential, round the final crop dimensions to nearby even numbers and test the resulting file.
Expecting Cropping To Improve Detail
Cropping removes pixels; it does not restore quality or create extra resolution. Enlarging the cropped result can make the remaining picture appear softer or more compressed. Keep realistic expectations and use a crop that preserves enough of the original frame for the required delivery size.
Forgetting Encoding Quality
Even a correct crop can look poor if the output is heavily compressed. Choose a quality-focused encoding setting appropriate for the material and avoid repeated exports whenever possible. Re-encoding an already compressed video multiple times can gradually make blockiness, banding, and noise more visible.
Overlooking Text And Graphics
Captions, watermarks, lower-thirds, and on-screen controls often sit close to a frame edge. A crop that removes unwanted border detail may also cut vital text. Check frames with titles and subtitles separately, especially when the video uses different layouts across scenes.
Cropping video with FFmpeg is a straightforward way to improve framing, remove unwanted edges, and adapt footage for different screen formats. The essential idea is simple: choose the output width and height, then set the horizontal and vertical starting point.
The best results come from measuring carefully, keeping important content inside the new frame, and testing a short export before processing a full video. Even dimensions and sensible encoding settings also help produce dependable, compatible files.
Once you are comfortable with the crop filter, it becomes an efficient part of a larger FFmpeg workflow. Use it thoughtfully, review the finished picture, and let the needs of the video determine the final framing.
FAQs About FFmpeg Video Cropping
Can FFmpeg crop a video without re-encoding it?
No. Cropping changes the pixels in every frame, so the video stream must be re-encoded. Audio does not need to be re-encoded if it is otherwise unchanged, but the visual portion requires processing to create the new frame dimensions and composition.
What Do Width Height X And Y Mean In The Crop Filter?
Width and height describe the size of the new visible frame. The x value is the distance from the original left edge to the new frame, and y is the distance from the original top edge. All four values are normally measured in pixels.
How Can I Crop A Video From The Center?
To center a crop, calculate the unused horizontal space and divide it by two for x. Do the same with unused vertical space for y. This creates a balanced crop, although a centered frame is not always best when the subject is positioned off center.
Why Does FFmpeg Reject My Crop Dimensions?
The requested width, height, and offsets may extend beyond the original frame, or the encoder may not accept the chosen pixel dimensions. Confirm that width plus x and height plus y remain inside the source frame. Then try even output dimensions if compatibility is an issue.
Can I Remove Black Bars With FFmpeg Cropping?
Yes. Cropping is commonly used to remove letterbox or pillarbox bars when they are part of the encoded image. Measure the active picture area carefully and crop only the unused border. Always inspect several scenes because some videos change aspect ratio during playback.
Should I Crop Before Or After Scaling A Video?
Cropping before scaling is usually preferable because it removes unwanted pixels before FFmpeg resizes the remaining picture. This can preserve a cleaner composition and avoid spending processing effort on pixels you plan to discard. The ideal order can vary when a specific final dimension is required.
