user1502679
user1502679

Reputation: 566

how to use crop filter twice in ffmpeg

I want to use crop filter in two different locations, for example top left + bottom right and to merge them, how can I do this?

I want to use the code once, not to make with two independent crops and merge after that.

EDIT: an image: http://alexvorn.com/wp-content/uploads/2013/07/ffmpeg-multiple-crop.png

Upvotes: 3

Views: 4764

Answers (1)

llogan
llogan

Reputation: 133803

original result
Original and resulting images.

The crop and hstack video filters in ffmpeg will achieve this:

ffmpeg -i input.mp4 -filter_complex \
"[0:0]crop=iw/2:ih/2:0:0[tl]; \
 [0:0]crop=iw/2:ih/2:iw/2:ih/2[br]; \
 [tl][br]hstack=inputs=2" \
-codec:a copy output.mp4

See the vstack filter if you prefer vertical stacking instead of horizontal stacking.

Upvotes: 8

Related Questions