I want to crop an area from an input video, then rotate this area 90 degrees four times. The output video should look like this:

This is a before image:

This is an after image:

Thanks in advance!
I want to crop an area from an input video, then rotate this area 90 degrees four times. The output video should look like this:

This is a before image:

This is an after image:

Thanks in advance!
ffmpeg
ffmpeg -i video.mkv -loop 1 -i mask.png -filter_complex \
"[1:v]alphaextract,split[a1][a2]; \
[0:v][a1]alphamerge,transpose=1[e]; \
[0:v][a2]alphamerge,transpose=2[w]; \
[0:v]vflip,hflip[s]; \
[0:v]pad=ih*2:ih*2:x=(ow-iw)/2[n]; \
[n][s]overlay=W/2-w/2:W/2[bg]; \
[bg][e]overlay=W/2:H/2-h/2[bg2]; \
[bg2][w]overlay=0:H/2-h/2" \
-codec:a copy output.mkv
alphaextract and alphamerge for the alpha componentsplit to make multiple copies of the alpha componenttranspose/vflip/hflip or whatever combination of similar filters you preferpad to make the background "canvas"overlay to place each video on the canvasUse a recent ffmpeg. Either download a Linux build of ffmpeg or follow a step-by-step guide to compile ffmpeg.
You will need to make an image that contains an alpha mask. It needs to be the same frame size as your video input, so if video.mkv is 1920x1080, then mask.png also needs to be 1920x1080. You can download the alpha mask from this example.
split was used because filter graphs must have unique edges, meaning every label connects two "nodes" or filter. So you have to split the output of any filter if you want to send its output to two places.
The black background color of the pad filter is visible in the corners. The crop filter can be used to remove it if you prefer.
The audio is stream copied instead of being re-encoded.
See the FFmpeg and x264 Encoding Guide for additional information on controlling the output quality.