<p>If you had just 4:3 and 16:9 videos, I would suggest:</p>

<pre><code>ffmpeg -i input.mov -filter:v 'scale=-1:768,crop=1024:ih' \
-c:v libx264 -crf 23 -preset veryfast output.mp4
</code></pre>

<p>That would scale a video to a height of 768, scaling the width to keep the aspect ratio; and then it crops the width to 1024, keeping the height at 768. The fact that you are using 1:1 videos as well complicates things: a 3000x3000 video would get scaled to 768x768, and then ffmpeg would try to crop it to 1024x768, which obviously wouldn't work, since crops can be no bigger than the input...</p>

<p>The only way I can think of getting this to work would be to crop <em>all</em> of the videos, which you stated wouldn't be a problem. This will crop the output width to be the same as the input height, and the output height to be 3/4 of the input height; and then it will scale the video down to a height of 768, keeping the aspect ratio with the width:</p>

<pre><code>ffmpeg -i input.mov -filter:v 'crop=ih:3/4*ih,scale=-1:768' \
-c:v libx264 -crf 23 -preset veryfast output.mp4
</code></pre>

<p>This will only work if the original files have a height of 1024 or more. Note that x264 only accepts an even width or height, which can cause problems (but shouldn't in this case).</p>

<p>To convert every .mov in a directory, you can use a for loop:</p>

<pre><code>for f in *.mov; \
do ffmpeg -i "$f" -filter:v 'crop=ih:3/4*ih,scale=-1:768' \
-c:v libx264 -crf 23 -preset veryfast "${f/%mov/mp4}"; \
done
</code></pre>

<p>To do so recursively, you can use <code>find</code>:</p>

<pre><code>find . -type f -name *.mov -exec bash -c \
'ffmpeg -i "$0" -filter:v "crop=ih:3/4*ih,scale=-1:768" \
-c:v libx264 -crf 23 -preset veryfast "${0/%mov/mp4}"' {} \;
</code></pre>

<p>All of this will require a recent version of ffmpeg.</p>

CC BY-SA 4.0
2013-01-15T22:12:57.467Z
2019-02-11T18:59:24.627Z
2019-02-11T18:59:24.627Z
evilsoup
<p>I am trying to prepare a collection of ~120 video clips to be played in VLC Player and projected on a low-res (1024x768) projector during a DIY electronic music event.  The source clips are all super hi-res abstract visuals in .mov format, about 4GB each.  They are of various aspect ratios.  Some are 4:3, others are 16:9, others are 1:1 (square) etc.</p>

<p>I would like to crop / scale all of the clips to 1024x768 while maintaining their respective original aspect ratios.   And, I would like to do so <em>without</em> letterboxing them and leaving black bars either at the top/bottom or left/right.  Basically what I would like to do is to reduce them to the point where they entirely fill the 1024x768 screen, and no smaller.  I believe that is essentially a "pan and scan" technique?</p>

<p>(It doesn't matter if part of the image is removed in the process - they're just spinning geometric shapes and such.)  </p>

<p>Is there some way I can resize all ~120 videos in batch using a single FFMPEG command?  Or, is there another tool for Windows or Linux that would work?  I don't really care what output format - just something that VLC can play without getting choppy.</p>

<video><software><conversion><ffmpeg>
Batch resize videos with "pan and scan" cropping
Derrick Miller
# Batch resize videos with "pan and scan" cropping

(Asked by: username_0 on 2012-11-14)

I am trying to prepare a collection of ~120 video clips to be played in VLC Player and projected on a low-res (1024x768) projector during a DIY electronic music event. The source clips are all super hi-res abstract visuals in .mov format, about 4GB each. They are of various aspect ratios. Some are 4:3, others are 16:9, others are 1:1 (square) etc.

I would like to crop / scale all of the clips to 1024x768 while maintaining their respective original aspect ratios. And, I would like to do so *without* letterboxing them and leaving black bars either at the top/bottom or left/right. Basically what I would like to do is to reduce them to the point where they entirely fill the 1024x768 screen, and no smaller. I believe that is essentially a "pan and scan" technique?

(It doesn't matter if part of the image is removed in the process - they're just spinning geometric shapes and such.)

Is there some way I can resize all ~120 videos in batch using a single FFMPEG command? Or, is there another tool for Windows or Linux that would work? I don't really care what output format - just something that VLC can play without getting choppy.

**Tags:** video, software, conversion, ffmpeg


---

## 1 answers

### Answer by username_1 on 2013-01-15. Score: 3

If you had just 4:3 and 16:9 videos, I would suggest:
ffmpeg -i input.mov -filter:v 'scale=-1:768,crop=1024:ih' \
-c:v libx264 -crf 23 -preset veryfast output.mp4

That would scale a video to a height of 768, scaling the width to keep the aspect ratio; and then it crops the width to 1024, keeping the height at 768. The fact that you are using 1:1 videos as well complicates things: a 3000x3000 video would get scaled to 768x768, and then ffmpeg would try to crop it to 1024x768, which obviously wouldn't work, since crops can be no bigger than the input...
The only way I can think of getting this to work would be to crop all of the videos, which you stated wouldn't be a problem. This will crop the output width to be the same as the input height, and the output height to be 3/4 of the input height; and then it will scale the video down to a height of 768, keeping the aspect ratio with the width:
ffmpeg -i input.mov -filter:v 'crop=ih:3/4*ih,scale=-1:768' \
-c:v libx264 -crf 23 -preset veryfast output.mp4

This will only work if the original files have a height of 1024 or more. Note that x264 only accepts an even width or height, which can cause problems (but shouldn't in this case).
To convert every .mov in a directory, you can use a for loop:
for f in *.mov; \
do ffmpeg -i "$f" -filter:v 'crop=ih:3/4*ih,scale=-1:768' \
-c:v libx264 -crf 23 -preset veryfast "${f/%mov/mp4}"; \
done

To do so recursively, you can use find:
find . -type f -name *.mov -exec bash -c \
'ffmpeg -i "$0" -filter:v "crop=ih:3/4*ih,scale=-1:768" \
-c:v libx264 -crf 23 -preset veryfast "${0/%mov/mp4}"' {} \;

All of this will require a recent version of ffmpeg.


---

