Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T18:07:20.417Z
Answers.LastActivityDate: 2015-11-13T18:07:20.417Z
Answers.UserDisplayName: Jason Conrad
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T20:28:15.703Z
Answers.LastActivityDate: 2015-11-13T20:28:15.703Z
Answers.UserDisplayName: Octopus
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T19:21:13.470Z
Answers.Text: I get this error: [AVFilterGraph @ 0x7fd560f00820] No such filter: '4/3)'
  Error opening filters!
Answers.UserDisplayName: Harry
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T19:26:11.533Z
Answers.Text: Sounds like '/' may not be allowed on Macs. Replace 4/3 with 1.333
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T19:27:43.413Z
Answers.Text: And 4 * ih / 3 * sar with 1.333*ih   and  3 * iw * sar / 4 with 0.75 * iw * sar
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T19:43:03.910Z
Answers.Text: Thank you, is there a way to get trim to accept minutes and not just seconds?
Answers.UserDisplayName: Harry
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T19:47:13.200Z
Answers.Text: 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.
Answers.UserDisplayName: Harry
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T19:51:22.273Z
Answers.Text: 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
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T21:30:38.590Z
Answers.Text: -fflags +genpts doesn't give an error but doesn't seem to do anything to fix the issue, could it be something else?
Answers.UserDisplayName: Harry
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T23:16:23.830Z
Answers.Text: 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.
Answers.UserDisplayName: Ilmari Karonen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-14T05:26:12.923Z
Answers.Text: Harry, you are supplying something for the audio - either -an or -af , right?
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-14T12:01:36.353Z
Answers.Text: Homebrew is another good way to get ffmpeg for macs. It's like apt-get for osx. http://brew.sh/
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T18:51:33.863Z
Answers.LastActivityDate: 2015-11-13T19:04:39.527Z
Answers.LastEditDate: 2015-11-13T19:04:39.527Z
Answers.UserDisplayName: Gyan
Body: <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>
  
Tags: <final-cut-pro-x>
Title: Is there an app that can Cut, crop, and resize video in 1 encode like imagemagick for video?
UserDisplayName: Harry
ThreadText: # 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](https://ffmpeg.org/download.html). Or more likely, download a precompiled binary for Macs from [here](http://ffmpegmac.net/). 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](https://ffmpeg.org/ffmpeg-all.html) 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 **p**resentation **t**ime**s**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).
  
  **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.
  
  
  ---
  
  