Search code examples
ffmpegcrop

FFMPEG - crop and pad a video (keep 3840x1920 but with black borders)


I am trying to crop a video so that I can remove a chunk of the content from the sides of a 360-degree video file using FFmpeg.

I used the following command and it does part of the job:

ffmpeg -i testVideo.mp4 -vf crop=3072:1920:384:0,pad=3840:1920:384:0 output.mp4

This will remove the sides of the video and that was initially exactly what I wanted (A). Now I'm wondering if it is possible to crop in the same way but to keep the top third of video. As such, A is what I have, B is what I want.:

enter image description here

I thought I could simply do this:

ffmpeg -i testVideo.mp4 -vf crop=3072:1920:384:640,pad=3840:1920:384:640 output.mp4

But that doesn't seem to work.

Any input would be very helpful.


Solution

  • Use the drawbox filter to fill cropped portion with default colour black.

    ffmpeg -i testVideo.mp4 -vf drawbox=w=384:h=1280:x=0:y=640:t=fill,drawbox=w=384:h=1280:x=3840-384:y=640:t=fill -c:a copy output.mp4
    

    The first filter acts on the left side, and the 2nd on the right.