<p>To crop before scaling <code>INPUTVIDEO.MP4</code>:</p>

<pre><code>ffmpeg -y -loop 1 -i backgroundimage.png -i INPUTVIDEO.MP4 -filter_complex "[1]crop=1728:970:96:54,scale=1612:906[inner];[0][inner]overlay=154:170:shortest=1[out]" -map "[out]" -map 1:a -c:a copy -b:v 2000k OUTPUT.MP4
</code></pre>

CC BY-SA 4.0
2020-04-17T22:17:07.533Z
That was perfect - Thank you llogan!
Dot Matrix
CC BY-SA 4.0
2020-04-17T20:51:47.203Z
2020-04-17T20:51:47.203Z
llogan
<p>Any ideas on the proper syntax to get crop to work with resizing and overlay all in one go?</p>

<p>The crop parameters are <code>crop=1728:970:96:54</code> and I'm trying to work them into:</p>

<pre><code>ffmpeg -loop 1 -i backgroundimage.png -i INPUTVIDEO.MP4 -filter_complex "[1]scale=1612:906[inner]overlay=154:170:shortest=1[out]" -map "[out]" -map 1:a -c:a copy -y -b:v 2000k -b:a 192K OUTPUT.MP4
</code></pre>

CC BY-SA 4.0
2020-04-17T18:11:31.263Z
Which input do you want to crop? backgroundimage.png or INPUTVIDEO.MP4. Where in the filtergraph should the crop occur? In other words, in which order should it occur? (Not immediately after crop obviously due to the crop being larger than the scale parameters.)
llogan
CC BY-SA 4.0
2020-04-17T20:10:53.370Z
INPUTVIDEO.MP4 needs to be cropped. This example is taking INPUTVIDEO.MP4 and shrinking it down and placing it on top of the backgroundimage.png. Unfortunately, I need to crop according to the settings shown INPUTVIDEO.MP4 before dropping it onto the background.

I realize the scaling will have to change to something else which I can figure out afterwards - it was just the ability to crop, resize and overlay in one go that I was wondering about. Thanks!
Dot Matrix
<ffmpeg>
FFMPEG - How to use crop, scale and overlay all in one go?
Dot Matrix
# FFMPEG - How to use crop, scale and overlay all in one go?

(Asked by: username_0 on 2020-04-17)

Any ideas on the proper syntax to get crop to work with resizing and overlay all in one go?
The crop parameters are crop=1728:970:96:54 and I'm trying to work them into:
ffmpeg -loop 1 -i backgroundimage.png -i INPUTVIDEO.MP4 -filter_complex "[1]scale=1612:906[inner]overlay=154:170:shortest=1[out]" -map "[out]" -map 1:a -c:a copy -y -b:v 2000k -b:a 192K OUTPUT.MP4

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Which input do you want to crop? backgroundimage.png or INPUTVIDEO.MP4. Where in the filtergraph should the crop occur? In other words, in which order should it occur? (Not immediately after crop obviously due to the crop being larger than the scale parameters.)  
> **username_0**: INPUTVIDEO.MP4 needs to be cropped. This example is taking INPUTVIDEO.MP4 and shrinking it down and placing it on top of the backgroundimage.png. Unfortunately, I need to crop according to the settings shown INPUTVIDEO.MP4 before dropping it onto the background.  I realize the scaling will have to change to something else which I can figure out afterwards - it was just the ability to crop, resize and overlay in one go that I was wondering about. Thanks!  

---

## 1 answers

### Answer by username_1 on 2020-04-17. Score: 3

To crop before scaling INPUTVIDEO.MP4:
ffmpeg -y -loop 1 -i backgroundimage.png -i INPUTVIDEO.MP4 -filter_complex "[1]crop=1728:970:96:54,scale=1612:906[inner];[0][inner]overlay=154:170:shortest=1[out]" -map "[out]" -map 1:a -c:a copy -b:v 2000k OUTPUT.MP4

> **Comments:**
> **username_0**: That was perfect - Thank you username_1!  

---

