Fix Blank Corners After Rotating Video in FFmpeg

Rotating a video at an arbitrary angle in FFmpeg using the rotate filter often creates empty black triangular corners because the rectangular frame twists away from the boundary of the canvas. This guide explains the primary methods for managing these blank areas, including changing the background fill color, making the background transparent, cropping out the black borders, and filling the surrounding space with a blurred version of the video.

1. Change the Fill Color or Make It Transparent

By default, the rotate filter fills the unoccupied areas with black. You can change this background using the fillcolor (or c) parameter.

To fill the blank areas with a specific solid color (like white):

ffmpeg -i input.mp4 -vf "rotate=15*PI/180:c=white:ow=rotw(15*PI/180):oh=roth(15*PI/180)" -c:a copy output.mp4

To create a transparent background (useful when creating an overlay for another video), set the color to none and use a format that supports an alpha channel, such as Apple ProRes 4444 or QuickTime Animation:

ffmpeg -i input.mp4 -vf "rotate=15*PI/180:c=none:ow=rotw(15*PI/180):oh=roth(15*PI/180)" -c:v prores_ks -profile:v 4444 -c:a copy output.mov

Note: ow=rotw(...) and oh=roth(...) dynamically resize the output canvas so the video corners do not get clipped.

2. Crop to Eliminate the Blank Areas

If you want to keep only the rotated image without any borders, you must crop the canvas into the largest rectangle that fits entirely within the rotated content.

To rotate the video, zoom in to eliminate the borders, and crop back to the original aspect ratio:

ffmpeg -i input.mp4 -vf "rotate=15*PI/180:ow=rotw(15*PI/180):oh=roth(15*PI/180),crop=iw*0.75:ih*0.75" -c:a copy output.mp4

Adjust the crop multiplier (e.g., 0.75) based on your rotation angle. Smaller rotation angles require less cropping to remove the black edges.

If you want to keep the original frame dimensions without changing canvas size, you can zoom into the video before rotating:

ffmpeg -i input.mp4 -vf "scale=1.3*iw:-1,rotate=15*PI/180:ow=iw:oh=ih,crop=iw/1.3:ih/1.3" -c:a copy output.mp4

3. Fill the Blank Areas with a Blurred Background

A popular aesthetic solution is to place the rotated video on top of a scaled-up, heavily blurred version of itself. This eliminates harsh black borders without cropping out any parts of the rotated footage.

You can achieve this using the filter_complex pipeline:

ffmpeg -i input.mp4 -filter_complex "\
[0:v]scale=iw*1.5:ih*1.5,boxblur=25:5[bg]; \
[0:v]rotate=15*PI/180:c=none:ow=rotw(15*PI/180):oh=roth(15*PI/180)[fg]; \
[bg][fg]overlay=(W-w)/2:(H-h)/2:shortest=1" \
-c:a copy output.mp4
  • scale=iw*1.5:ih*1.5 zooms into the background stream to ensure it covers the canvas.
  • boxblur=25:5 applies a smooth, deep blur to the enlarged background.
  • rotate=15*PI/180:c=none:... rotates the foreground footage and makes the outer corners transparent.
  • overlay=(W-w)/2:(H-h)/2 centers the rotated foreground directly over the blurred background.