How to use ffmpeg

How to get the size of a video using ffmpeg?


ffmpeg -i my_video.mp4


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?


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


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



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store