About
The crop filter
once you have installed it, you can use the crop filter to crop your video.
the crop is a filter that accepts the parameters such as the following
- w, out_w: the width of the output video.
- h, out_h: The height of the output video
- x: The horizontal position, in the input video, of the left edge of the output video.
- y: The vertical position, in the input video, of the top edge of the output video.
- … more see the documentation 2)
How to
How to crop towards the center ?
By default, ffmpeg will crop towards the center if the positions of the output egde are not given.
Crop the central input area with size 100×100:
- crop option by position
ffmpeg -i "input.mp4" -vf crop=100:100 "output.mp4"
- crop option by name
ffmpeg -i "input.mp4" -vf crop=w=100:h=100 "output.mp4"
How to crop an area at a position ?
Crop area with size 100×100 at position (12,34). 3)
- crop option by position
ffmpeg -i "input.mp4" -vf crop=100:100:12:34 "output.mp4"
- crop option by name
ffmpeg -i "input.mp4" -vf crop=w=100:h=100:x=12:y=34 "output.mp4"
How to crop the black areas ?
The standard procedure to eliminate these black areas is to run first the cropdetect filter 4) and then run the crop filter.
Example: 5) Find video area surrounded by black borders
ffmpeg -i file.mp4 -vf cropdetect,metadata=mode=print -f null -
A human eye give a better result quicker to detect the border.
This wiki page gives another alternative