How to use ffmpeg

How to get the size of a video using ffmpeg?

Command:

ffmpeg -i my_video.mp4

Output:

...
Duration: 00:00:20.83, start: 0.000000, bitrate: 18459 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1048x872, 18457 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
...

The video in this example has a width of 1048 and a hight of 872 pixels.

How to crop a video using ffmpeg?

Template:

ffmpeg -i my_video.mp4 -filter_complex "[0:v]crop=<total width>:<total height>:<offset from left>:<offset from top>[cropped]" -map "[cropped]" my_video_cropped.mp4 -y

Example:

ffmpeg -i my_video.mp4 -filter_complex "[0:v]crop=1048:500:10:20[cropped]" -map "[cropped]" my_video_cropped.mp4 -y

Input: my_video.mp4
Output: my_video_cropped.mp4

Total Width: 1048
Total Height: 500
Offset from Left:10
Offset from Top: 20

--

--