<p>This should work universally.</p>

<pre><code>ffmpeg -i in.avi -y -pix_fmt yuv420p -an -qscale 1 -vcodec libx264 -vf setsar=1,crop=in_w:in_h-64:0:64 out.mp4
</code></pre>

CC BY-SA 3.0
2015-10-10T20:23:43.223Z
@user255406 libx264 ignores `-qscale`. [Use `-crf` instead](https://trac.ffmpeg.org/wiki/Encode/H.264).
llogan
CC BY-SA 3.0
2017-11-27T02:43:37.767Z
It looks like in some cases you can simply use `setsar=` or even just `setsar`
Zombo
CC BY-SA 3.0
2015-10-10T19:01:52.593Z
2015-10-10T19:09:43.127Z
2015-10-10T19:09:43.127Z
Gyan
<p>ffmpeg accepts only <strong>one</strong> video filter (marked as -vf)
you should merge all the video filters you want into one, comma separated string:</p>
<p><code>ffmpeg ... -vf setsar=1,crop=in_w:in_h-64:0:64 out.mp4</code></p>

CC BY-SA 4.0
2020-10-04T13:22:18.513Z
2020-10-04T13:22:18.513Z
orgoro
<p>I have a heterogenous set of videos (codecs, dimensions, size) that I would like to crop off the top using ffmpeg.  I've used this code successfully for year without any trouble (example here crops off 64px):</p>

<pre><code>ffmpeg -i in.avi -y -pix_fmt yuv420p -an -qscale 1 -vcodec libx264 -vf crop=in_w:in_h-64:0:64 out.mp4
</code></pre>

<p>However, I've now run into a case that it does <em>not</em> work correctly, and I suspect it has something to do with SAR and DAR.  I have a clip that shows pixel dimensions of 960x720 [SAR 960:720 DAR 16:9], original looks close to this:</p>

<p><a href="https://i.sstatic.net/iFbzl.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iFbzl.png" alt="original"></a></p>

<p>When I use the above command, I end up with a video that ffprobe/ffmpeg says is 960x656 [SAR 4:3 DAR 80:41], but when I view it on a web browser or quicktime it is displayed as 1280x656:</p>

<p><a href="https://i.sstatic.net/T1mdJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/T1mdJ.png" alt="output"></a></p>

<p>How can I modify the command to account for this use case, without breaking the cropping of all other clips?  Here's what I've unsuccessfully tried:</p>

<pre><code>ffmpeg -i in.avi -y -pix_fmt yuv420p -an -qscale 1 -vcodec libx264 -vf scale=960:656,setsar=1 -vf crop=in_w:in_h-64:0:64 out.mp4
ffmpeg -i in.avi -y -pix_fmt yuv420p -an -qscale 1 -vcodec libx264 -vf setsar=sar=0 -vf setdar=dar=0 -vf crop=in_w:in_h-64:0:64 out.mp4
</code></pre>

CC BY-SA 3.0
2015-10-10T17:24:43.230Z
Here's an archive of the input and output files I'm getting. https://www.ultrasoundoftheweek.com/give/uploads/clips.zip
user255406
CC BY-SA 4.0
2021-06-15T21:18:01.540Z
"Keep in mind that the sample aspect ratio set by the setsar filter may be changed by later filters in the filterchain, e.g. if another "setsar" or a "setdar" filter is applied." - so the correct order is needed and as said by @orgoro possibly try to do not separate filters and instead do: -vf "filter1=...,filter2=...,filter3"
16851556
<ffmpeg><aspect>
ffmpeg cropped video changes aspect ratio
user255406
# ffmpeg cropped video changes aspect ratio

(Asked by: username_0 on 2015-10-10)

I have a heterogenous set of videos (codecs, dimensions, size) that I would like to crop off the top using ffmpeg.  I've used this code successfully for year without any trouble (example here crops off 64px):
ffmpeg -i in.avi -y -pix_fmt yuv420p -an -qscale 1 -vcodec libx264 -vf crop=in_w:in_h-64:0:64 out.mp4

However, I've now run into a case that it does not work correctly, and I suspect it has something to do with SAR and DAR.  I have a clip that shows pixel dimensions of 960x720 [SAR 960:720 DAR 16:9], original looks close to this:

When I use the above command, I end up with a video that ffprobe/ffmpeg says is 960x656 [SAR 4:3 DAR 80:41], but when I view it on a web browser or quicktime it is displayed as 1280x656:

How can I modify the command to account for this use case, without breaking the cropping of all other clips?  Here's what I've unsuccessfully tried:
ffmpeg -i in.avi -y -pix_fmt yuv420p -an -qscale 1 -vcodec libx264 -vf scale=960:656,setsar=1 -vf crop=in_w:in_h-64:0:64 out.mp4
ffmpeg -i in.avi -y -pix_fmt yuv420p -an -qscale 1 -vcodec libx264 -vf setsar=sar=0 -vf setdar=dar=0 -vf crop=in_w:in_h-64:0:64 out.mp4

**Tags:** ffmpeg, aspect

> **Comments:**
> **username_0**: Here's an archive of the input and output files I'm getting. https://www.ultrasoundoftheweek.com/give/uploads/clips.zip  
> **username_1**: "Keep in mind that the sample aspect ratio set by the setsar filter may be changed by later filters in the filterchain, e.g. if another "setsar" or a "setdar" filter is applied." - so the correct order is needed and as said by @username_5 possibly try to do not separate filters and instead do: -vf "filter1=...,filter2=...,filter3"  

---

## 2 answers

### Answer by username_2 on 2015-10-10. Score: 1 | Accepted answer

This should work universally.
ffmpeg -i in.avi -y -pix_fmt yuv420p -an -qscale 1 -vcodec libx264 -vf setsar=1,crop=in_w:in_h-64:0:64 out.mp4

> **Comments:**
> **username_3**: @username_0 libx264 ignores `-qscale`. [Use `-crf` instead](https://trac.ffmpeg.org/wiki/Encode/H.264).  
> **username_4**: It looks like in some cases you can simply use `setsar=` or even just `setsar`  

---

### Answer by username_5 on 2020-10-04. Score: 0

ffmpeg accepts only **one** video filter (marked as -vf)
you should merge all the video filters you want into one, comma separated string:

`ffmpeg ... -vf setsar=1,crop=in_w:in_h-64:0:64 out.mp4`


---

