<p>Apple compressor can do all of this in the GUI.  If you need to use the command line, I think you'll find the relevant information <a href="http://help.apple.com/compressor/mac/4.0/en/compressor/usermanual/index.html#chapter=C%26section=1%26tasks=true" rel="nofollow">here</a>.</p>

CC BY-SA 3.0
2015-11-13T18:07:20.417Z
2015-11-13T18:07:20.417Z
Jason Conrad
<p><a href="http://avisynth.nl/index.php/Main_Page" rel="nofollow">Avisynth</a> is a powerful frameserver for Windows with which you can write small scriptlets that dictate how you want to manipulate your video. You can do simple transforms such as scaling, cropping, adding borders, resizing, resampling, deinterlacing, etc. If you are comfortable with writing code then it can be very powerful, but there is a bit of a learning curve in getting to know how to use it. As far as I know there is no GUI for it.</p>

<p>There is also a port to Linux OSes called <a href="https://github.com/avxsynth/avxsynth/wiki" rel="nofollow">avxsynth</a>, which I haven't used.</p>

<p>It processes the frames all at once and then you feed the output of the synth to a compressor such as xvideo or ffmpeg.</p>

CC BY-SA 3.0
2015-11-13T20:28:15.703Z
2015-11-13T20:28:15.703Z
Octopus
<p>ffmpeg will do it. You can either compile it from source, available <a href="https://ffmpeg.org/download.html">here</a>. Or more likely, download a precompiled binary for Macs from <a href="http://ffmpegmac.net/">here</a>. I don't use Macs so I can't vouch for the binary source.</p>

<p>You will have to use the trim, crop and scale filters in a filterchain to accomplish what you want. </p>

<p>The actual corresponding command for your pseudo command would be</p>

<pre><code>ffmpeg -i input -vf "trim=20:40, setpts=PTS-STARTPTS, crop="'if(gte(a*sar,4/3),4*ih/3*sar,iw)':'if(gte(a*sar,4/3),ih,3*iw*sar/4)'", scale=320x240, setsar=1" -c:v libx264 -an output.mp4
</code></pre>

<p>You can find the (terse) explanation for all the parameters at the ffmpeg <a href="https://ffmpeg.org/ffmpeg-all.html">documentation</a> site, but here's a quick run-through, in order:</p>

<p><strong>-i input</strong> - Specify the input file.</p>

<p><strong>-vf</strong> - this indicates a video filter follows, or a chain of them (separated by commas). If there are multiple filters specified in sequence, then each filter in a chain works on the output generated by the previous filter in the chain. The first filter works, of course, on the original input.</p>

<p><strong>trim=20:40</strong> - trims the video by retaining from the 21st to the 40th second</p>

<p><strong>setpts=PTS-STARTPTS</strong> - video is a sequence of images displayed in time, so the frames of a video stream have timestamps associated with them for playback purposes. PTS is <strong>p</strong>resentation <strong>t</strong>ime<strong>s</strong>tamp. This clause generates new timestamps for the trimmed video stream so that the first frame of the trimmed stream has PTS of 0 (seconds) and all subsequent frames are accordingly offset as well (I've simplified a bit here).</p>

<p><strong>crop="'if(gte(a*sar,4/3),4*ih/3*sar,iw)':'if(gte(a*sar,4/3),ih,3*iw*sar/4)'"</strong> - in short, this crops the input video to 4:3, but based on the input video's effective display ratio, so that the cropped image doesn't contain any blank padding. Video can contain "non-square" pixels so that a 100x100 image with pixel aspect (SAR) 2.5 will effectively display as 250x100 and SAR 0.5 will display as 50x100. My expression evaluates the effective input ratio and sets the output crop window accordingly.</p>

<p><strong>scale=320x240</strong> - scale to the stated resolution</p>

<p><strong>setsar=1</strong> - the crop and scale filters effectively produced a square pixel output, so the SAR metadata should be set as 1 to overwrite the original SAR so that players don't distort the image during playback.</p>

<p><strong>-c:v libx264</strong> - this says, use x264 to encode the video stream. There are many parameters that can be specified in addition , but by itself, it will use the default settings.</p>

<p><strong>-an</strong> - leave audio out of the output. If you want to leave the corresponding audio in. replace this by</p>

<pre><code>-af "atrim=20:40, asetpts=PTS-STARTPTS" -c:a aac -strict -2
</code></pre>

CC BY-SA 3.0
2015-11-13T19:21:13.470Z
I get this error: [AVFilterGraph @ 0x7fd560f00820] No such filter: '4/3)'
Error opening filters!
Harry
CC BY-SA 3.0
2015-11-13T19:26:11.533Z
Sounds like '/' may not be allowed on Macs. Replace 4/3 with 1.333
Gyan
CC BY-SA 3.0
2015-11-13T19:27:43.413Z
And 4 * ih / 3 * sar with 1.333*ih   and  3 * iw * sar / 4 with 0.75 * iw * sar
Gyan
CC BY-SA 3.0
2015-11-13T19:43:03.910Z
Thank you, is there a way to get trim to accept minutes and not just seconds?
Harry
CC BY-SA 3.0
2015-11-13T19:47:13.200Z
setpts=PTS-STARTPTS doesn't seem like it's enough to get the correct metadata for the video file. For example I'm trimming a 20 minute video to 20 seconds but the seekbar still shows 20 minute long video.
Harry
CC BY-SA 3.0
2015-11-13T19:51:22.273Z
Looks like another quirk of the Mac version :)  Add -fflags +genpts just before the output filename. See https://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax for specifying in larger subdivisions
Gyan
CC BY-SA 3.0
2015-11-13T21:30:38.590Z
-fflags +genpts doesn't give an error but doesn't seem to do anything to fix the issue, could it be something else?
Harry
CC BY-SA 3.0
2015-11-13T23:16:23.830Z
It would probably be easier to use all single quotes for the filter string, i.e. `-vf 'trim=20:40, setpts=PTS-STARTPTS, crop=if(gte(a*sar,4/3),4*ih/3*sar,iw):if(gte(a*sar,4/3),ih,3*iw*sar/4), scale=320x240, setsar=1'`. Alas, I can't test this myself just now.
Ilmari Karonen
CC BY-SA 3.0
2015-11-14T05:26:12.923Z
Harry, you are supplying something for the audio - either -an or -af , right?
Gyan
CC BY-SA 3.0
2015-11-14T12:01:36.353Z
Homebrew is another good way to get ffmpeg for macs. It's like apt-get for osx. http://brew.sh/
stib
CC BY-SA 3.0
2015-11-13T18:51:33.863Z
2015-11-13T19:04:39.527Z
2015-11-13T19:04:39.527Z
Gyan
<p>Is there an app that can Cut, crop, and resize video in 1 encode like imagemagick for video?</p>

<p>Looking for something that accepts a command like this:</p>

<pre><code>videoapp cut 0:20 0:40 crop 4:3 resize 240 320
</code></pre>

<p>Outputs as h.264 mp4.</p>

<p>I have a mac with the mac video apps and can get any app that's recommended. Thanks.</p>

<final-cut-pro-x>
Is there an app that can Cut, crop, and resize video in 1 encode like imagemagick for video?
Harry
# Is there an app that can Cut, crop, and resize video in 1 encode like imagemagick for video?

(Asked by: username_0 on 2015-11-13)

Is there an app that can Cut, crop, and resize video in 1 encode like imagemagick for video?
Looking for something that accepts a command like this:
videoapp cut 0:20 0:40 crop 4:3 resize 240 320

Outputs as h.264 mp4.
I have a mac with the mac video apps and can get any app that's recommended. Thanks.

**Tags:** final-cut-pro-x


---

## 3 answers

### Answer by username_3 on 2015-11-13. Score: 6 | Accepted answer

ffmpeg will do it. You can either compile it from source, available here. Or more likely, download a precompiled binary for Macs from here. I don't use Macs so I can't vouch for the binary source.
You will have to use the trim, crop and scale filters in a filterchain to accomplish what you want. 
The actual corresponding command for your pseudo command would be
ffmpeg -i input -vf "trim=20:40, setpts=PTS-STARTPTS, crop="'if(gte(a*sar,4/3),4*ih/3*sar,iw)':'if(gte(a*sar,4/3),ih,3*iw*sar/4)'", scale=320x240, setsar=1" -c:v libx264 -an output.mp4

You can find the (terse) explanation for all the parameters at the ffmpeg documentation site, but here's a quick run-through, in order:
-i input - Specify the input file.
-vf - this indicates a video filter follows, or a chain of them (separated by commas). If there are multiple filters specified in sequence, then each filter in a chain works on the output generated by the previous filter in the chain. The first filter works, of course, on the original input.
trim=20:40 - trims the video by retaining from the 21st to the 40th second
setpts=PTS-STARTPTS - video is a sequence of images displayed in time, so the frames of a video stream have timestamps associated with them for playback purposes. PTS is presentation timestamp. This clause generates new timestamps for the trimmed video stream so that the first frame of the trimmed stream has PTS of 0 (seconds) and all subsequent frames are accordingly offset as well (I've simplified a bit here).
crop="'if(gte(a*sar,4/3),4*ih/3*sar,iw)':'if(gte(a*sar,4/3),ih,3*iw*sar/4)'" - in short, this crops the input video to 4:3, but based on the input video's effective display ratio, so that the cropped image doesn't contain any blank padding. Video can contain "non-square" pixels so that a 100x100 image with pixel aspect (SAR) 2.5 will effectively display as 250x100 and SAR 0.5 will display as 50x100. My expression evaluates the effective input ratio and sets the output crop window accordingly.
scale=320x240 - scale to the stated resolution
setsar=1 - the crop and scale filters effectively produced a square pixel output, so the SAR metadata should be set as 1 to overwrite the original SAR so that players don't distort the image during playback.
-c:v libx264 - this says, use x264 to encode the video stream. There are many parameters that can be specified in addition , but by itself, it will use the default settings.
-an - leave audio out of the output. If you want to leave the corresponding audio in. replace this by
-af "atrim=20:40, asetpts=PTS-STARTPTS" -c:a aac -strict -2

> **Comments:**
> **username_0**: I get this error: [AVFilterGraph @ 0x7fd560f00820] No such filter: '4/3)' Error opening filters!  
> **username_3**: Sounds like '/' may not be allowed on Macs. Replace 4/3 with 1.333  
> **username_3**: And 4 * ih / 3 * sar with 1.333*ih   and  3 * iw * sar / 4 with 0.75 * iw * sar  
> **username_0**: Thank you, is there a way to get trim to accept minutes and not just seconds?  
> **username_0**: setpts=PTS-STARTPTS doesn't seem like it's enough to get the correct metadata for the video file. For example I'm trimming a 20 minute video to 20 seconds but the seekbar still shows 20 minute long video.  
> **username_3**: Looks like another quirk of the Mac version :)  Add -fflags +genpts just before the output filename. See https://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax for specifying in larger subdivisions  
> **username_0**: -fflags +genpts doesn't give an error but doesn't seem to do anything to fix the issue, could it be something else?  
> **username_4**: It would probably be easier to use all single quotes for the filter string, i.e. `-vf 'trim=20:40, setpts=PTS-STARTPTS, crop=if(gte(a*sar,4/3),4*ih/3*sar,iw):if(gte(a*sar,4/3),ih,3*iw*sar/4), scale=320x240, setsar=1'`. Alas, I can't test this myself just now.  
> **username_3**: username_0, you are supplying something for the audio - either -an or -af , right?  
> **username_5**: Homebrew is another good way to get ffmpeg for macs. It's like apt-get for osx. http://brew.sh/  

---

### Answer by username_1 on 2015-11-13. Score: 1

Apple compressor can do all of this in the GUI. If you need to use the command line, I think you'll find the relevant information [here](http://help.apple.com/compressor/mac/4.0/en/compressor/usermanual/index.html#chapter=C%26section=1%26tasks=true).


---

### Answer by username_2 on 2015-11-13. Score: 0

[Avisynth](http://avisynth.nl/index.php/Main_Page) is a powerful frameserver for Windows with which you can write small scriptlets that dictate how you want to manipulate your video. You can do simple transforms such as scaling, cropping, adding borders, resizing, resampling, deinterlacing, etc. If you are comfortable with writing code then it can be very powerful, but there is a bit of a learning curve in getting to know how to use it. As far as I know there is no GUI for it.

There is also a port to Linux OSes called [avxsynth](https://github.com/avxsynth/avxsynth/wiki), which I haven't used.

It processes the frames all at once and then you feed the output of the synth to a compressor such as xvideo or ffmpeg.


---

