Answers.Body: <p>In order to maintain the aspect ratio of the source movie through FFMpeg's scaler, you have to specify a scale with an unknown:</p>
  
  <pre><code>ffmpeg -i input.mp4 -an -vcodec libx264 -profile:v main \
    -pass 2 -vf scale=-1:180 -pix_fmt (etc...)
  </code></pre>
  
  <p>The "-1" will tell the scaler to make the output 180px high, and however many pixels wide the output must be to preserve it's original aspect ratio.</p>
  
  <p>This would give you movies with the old aspect ratio, you need a way of forcing the original movie into an arbitrary rectangle.  The <a href="https://trac.ffmpeg.org/wiki/Scaling%20(resizing)%20with%20ffmpeg" rel="nofollow">documentation</a> give an example of how you do this:</p>
  
  <pre><code>ffmpeg -i input.mp4 -vf scale="'if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'"  
  </code></pre>
  
  <p>This example will create a movie that is 320x240, and preserves the original pixel aspect ratio, whatever that may be.  The output will be positioned against the upper-left corner (I think) so you'll have to do a filter to repo it.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-21T05:19:22.250Z
Answers.LastActivityDate: 2015-03-21T05:19:22.250Z
Answers.UserDisplayName: iluvcapra
Body: <p>We have videos in row format (.mov) that are 4:3 (768x576) and 5:4 (720x576). We have a recommended preset for streaming over DASH to HTML5 and Silverlight players (this is the second pass):</p>
  
  <pre><code>ffmpeg -i input.mp4 -an -vcodec libx264 -profile:v main -pass 2 \
  -vf scale=320:180 -pix_fmt yuv420p -g 75 -keyint_min 25 -b:v 384k \
  -maxrate 384k -bufsize 384k -passlogfile passlogfile_fp output_320x180_384.mp4 
  </code></pre>
  
  <p>with 5 more, but different resolution and bitrate:</p>
  
  <ul>
  <li>480:270 -b:v 700k</li>
  <li>800:450 -b:v 1300k</li>
  <li>960:540 -b:v 1300k</li>
  <li>1280:720 -b:v 3500k</li>
  <li>1920:1080 -b:v 5000k</li>
  </ul>
  
  <p>With the 4:3 source videos we are happy with the result - the image doesn't get stretched, but players add black border to fit the width. Although we are not sure if this preset is suitable for these source videos.</p>
  
  <p>With the 5:4 we are not really happy, because the image is stretched for 16:9 display. How can we achieve the same effect as with the 4:3 source videos? Are these presets suitable at all for these video formats or should we be looking for something else?</p>
  
  <p>Appreciate your help. Our knowledge about encoding is pretty limited. </p>
  
Tags: <ffmpeg><streaming><presets><scale>
Title: Best presets to scale legacy 4:3 and 5:4 videos using ffmpeg
UserDisplayName: Gorgi Rankovski
ThreadText: # Best presets to scale legacy 4:3 and 5:4 videos using ffmpeg
  
  (Asked by: username_0 on 2015-03-12)
  
  We have videos in row format (.mov) that are 4:3 (768x576) and 5:4 (720x576). We have a recommended preset for streaming over DASH to HTML5 and Silverlight players (this is the second pass):
  
  ```
  ffmpeg -i input.mp4 -an -vcodec libx264 -profile:v main -pass 2 \
  -vf scale=320:180 -pix_fmt yuv420p -g 75 -keyint_min 25 -b:v 384k \
  -maxrate 384k -bufsize 384k -passlogfile passlogfile_fp output_320x180_384.mp4 
  
  ```
  
  with 5 more, but different resolution and bitrate:
  
  * 480:270 -b:v 700k
  * 800:450 -b:v 1300k
  * 960:540 -b:v 1300k
  * 1280:720 -b:v 3500k
  * 1920:1080 -b:v 5000k
  
  With the 4:3 source videos we are happy with the result - the image doesn't get stretched, but players add black border to fit the width. Although we are not sure if this preset is suitable for these source videos.
  
  With the 5:4 we are not really happy, because the image is stretched for 16:9 display. How can we achieve the same effect as with the 4:3 source videos? Are these presets suitable at all for these video formats or should we be looking for something else?
  
  Appreciate your help. Our knowledge about encoding is pretty limited.
  
  **Tags:** ffmpeg, streaming, presets, scale
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-03-21. Score: 2
  
  In order to maintain the aspect ratio of the source movie through FFMpeg's scaler, you have to specify a scale with an unknown:
  
  ```
  ffmpeg -i input.mp4 -an -vcodec libx264 -profile:v main \
    -pass 2 -vf scale=-1:180 -pix_fmt (etc...)
  
  ```
  
  The "-1" will tell the scaler to make the output 180px high, and however many pixels wide the output must be to preserve it's original aspect ratio.
  
  This would give you movies with the old aspect ratio, you need a way of forcing the original movie into an arbitrary rectangle. The [documentation](https://trac.ffmpeg.org/wiki/Scaling%20(resizing)%20with%20ffmpeg) give an example of how you do this:
  
  ```
  ffmpeg -i input.mp4 -vf scale="'if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'"  
  
  ```
  
  This example will create a movie that is 320x240, and preserves the original pixel aspect ratio, whatever that may be. The output will be positioned against the upper-left corner (I think) so you'll have to do a filter to repo it.
  
  
  ---
  
  