Answers.Body: <p>Assuming both MKVs are rips of NTSC DVDs, these are the commands you need:</p>
  
  <p><strong>For 4:3 video</strong></p>
  
  <pre><code>ffmpeg -i "input43.mkv" -vf "scale=640x480,setsar=1,pad=854:480:107:0" [etc..]
  </code></pre>
  
  <p><strong>For 16:9 video</strong></p>
  
  <pre><code>ffmpeg -i "input169.mkv" -vf "scale=854x480,setsar=1" [etc..]
  </code></pre>
  
  <p>(Note H.264, the codec you are likely using, needs dimensions to be even, so specifying <code>853</code> as width will lead to ffmpeg feeding <code>854</code> pixels to the encoder and then auto-setting a funky SAR.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-07T04:38:24.733Z
Answers.LastActivityDate: 2016-01-07T04:38:24.733Z
Answers.UserDisplayName: Gyan
Body: <p>I'm confusing myself over how the video filters work, particularly how they work together, I think.  I have two MKVs, pulled from DVD, that are respectively 16:9 and 4:3.  What I would like to do is ultimately combine them (mkvmerge widescreen.mkv + fullscreen.mkv) and to do that I need matching display aspect ratios.</p>
  
  <p>So I would like to pillarbox the 4:3 video as I encode it, and then hopefully append it to the 16:9 video.  I've tried a number of filters to accomplish this, and the closest I was able to get was a slightly wider than expected video, otherwise pillarboxed properly.</p>
  
  <pre><code>ffmpeg -i fullscreen.mkv 4:3 -vf "pad=853:480:66:0,scale=720x480,setdar=16:9" [etc.]
  </code></pre>
  
  <p>The pixel dimensions are 720x480, the display dimensions are 853x480, and the two MKVs can be successfully merged (after reencoding the widescreen.mkv to the same video codec, but without video filters).</p>
  
  <p>However, the resulting display of the fullscreen video is pillarboxed, yet slightly horizontally stretched.  In 1:1 pixels it measures 720px across, not 640.</p>
  
  <p>I figure I'm doing the math wrong, or misunderstanding how the filters are supposed to operate, or something simple, but my understanding of ffmpeg video filters is basically nothing.</p>
  
Tags: <ffmpeg><filter><aspect><non-square-pixels>
Title: ffmpeg: pillarbox 4:3 to 16:9
UserDisplayName: drukepple
ThreadText: # ffmpeg: pillarbox 4:3 to 16:9
  
  (Asked by: username_0 on 2016-01-07)
  
  I'm confusing myself over how the video filters work, particularly how they work together, I think. I have two MKVs, pulled from DVD, that are respectively 16:9 and 4:3. What I would like to do is ultimately combine them (mkvmerge widescreen.mkv + fullscreen.mkv) and to do that I need matching display aspect ratios.
  
  So I would like to pillarbox the 4:3 video as I encode it, and then hopefully append it to the 16:9 video. I've tried a number of filters to accomplish this, and the closest I was able to get was a slightly wider than expected video, otherwise pillarboxed properly.
  
  ```
  ffmpeg -i fullscreen.mkv 4:3 -vf "pad=853:480:66:0,scale=720x480,setdar=16:9" [etc.]
  
  ```
  
  The pixel dimensions are 720x480, the display dimensions are 853x480, and the two MKVs can be successfully merged (after reencoding the widescreen.mkv to the same video codec, but without video filters).
  
  However, the resulting display of the fullscreen video is pillarboxed, yet slightly horizontally stretched. In 1:1 pixels it measures 720px across, not 640.
  
  I figure I'm doing the math wrong, or misunderstanding how the filters are supposed to operate, or something simple, but my understanding of ffmpeg video filters is basically nothing.
  
  **Tags:** ffmpeg, filter, aspect, non-square-pixels
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-07. Score: 1 | Accepted answer
  
  Assuming both MKVs are rips of NTSC DVDs, these are the commands you need:
  
  **For 4:3 video**
  
  ```
  ffmpeg -i "input43.mkv" -vf "scale=640x480,setsar=1,pad=854:480:107:0" [etc..]
  
  ```
  
  **For 16:9 video**
  
  ```
  ffmpeg -i "input169.mkv" -vf "scale=854x480,setsar=1" [etc..]
  
  ```
  
  (Note H.264, the codec you are likely using, needs dimensions to be even, so specifying `853` as width will lead to ffmpeg feeding `854` pixels to the encoder and then auto-setting a funky SAR.
  
  
  ---
  
  