Answers.Body: <p>For a H264 stream, use the h264_metadata bitstream filter</p>
  
  <pre><code>ffmpeg -i in.mp4 -c copy -bsf:v "h264_metadata=sample_aspect_ratio=4/3" out.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-02T17:11:58.170Z
Answers.Text: that did it, thanks !
Answers.UserDisplayName: wuppi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-28T09:24:31.593Z
Answers.LastActivityDate: 2020-02-28T09:24:31.593Z
Answers.UserDisplayName: Gyan
Answers.Body: <p>If you want to change the Sample Aspect Ratio (aka Pixel Aspect Ratio) without reencoding use <strong>mkvmerge</strong> or <strong>mp4box</strong>:</p>
  
  <p>mkvmerge</p>
  
  <pre><code>mkvmerge -o "out.mp4" --aspect-ratio-factor 0:4/3 "in.mp4"
  </code></pre>
  
  <p>mp4box</p>
  
  <pre><code>mp4box -add in.mp4 -par 1=4:3 out.mp4
  </code></pre>
  
  <p>In <code>ffmpeg</code> you <strong>cannot</strong> combine a filter with <code>-c copy</code> ...</p>
  
  <pre><code>ffmpeg -i in.mp4 -vf setsar=sar=4/3 -map 0 -c copy out.mp4
  </code></pre>
  
  <p>because</p>
  
  <pre><code>Filtering and streamcopy cannot be used together.
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-28T08:40:47.100Z
Answers.LastActivityDate: 2020-02-28T10:43:14.573Z
Answers.LastEditDate: 2020-02-28T10:43:14.573Z
Answers.UserDisplayName: drake7
Body: <p>I have the following issue: I have a video file (h264) that plays with the correct aspect ratio in mplayer. However, if I load it into Intel's Computer Vision Annotation Tool, or if I re-encode the video using openCV, the aspect ratio is no longer correct. </p>
  
  <p>"ffprobe -i" on the original file gives</p>
  
  <blockquote>
    <p>1440x1080 [SAR 4:3 DAR 16:9]</p>
  </blockquote>
  
  <p>whereas for the re-encoded file I get</p>
  
  <blockquote>
    <p>1440x1080 [SAR 1:1 DAR 4:3]</p>
  </blockquote>
  
  <p>I have other video files with</p>
  
  <blockquote>
    <p>1920x1080 [SAR 1:1 DAR 16:9]</p>
  </blockquote>
  
  <p>that do not cause this issue.</p>
  
  <p>Do I just have to modify the SAR in the header or is the problem more complicated? I would like to preserve the codec if possible.</p>
  
Tags: <codec><aspect><ffprobe>
Title: How to make video play with correct aspect ratio
UserDisplayName: painfulenglish
ThreadText: # How to make video play with correct aspect ratio
  
  (Asked by: username_0 on 2020-02-27)
  
  I have the following issue: I have a video file (h264) that plays with the correct aspect ratio in mplayer. However, if I load it into Intel's Computer Vision Annotation Tool, or if I re-encode the video using openCV, the aspect ratio is no longer correct.
  
  "ffprobe -i" on the original file gives
  
  > 1440x1080 [SAR 4:3 DAR 16:9]
  
  whereas for the re-encoded file I get
  
  > 1440x1080 [SAR 1:1 DAR 4:3]
  
  I have other video files with
  
  > 1920x1080 [SAR 1:1 DAR 16:9]
  
  that do not cause this issue.
  
  Do I just have to modify the SAR in the header or is the problem more complicated? I would like to preserve the codec if possible.
  
  **Tags:** codec, aspect, ffprobe
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-02-28. Score: 4
  
  For a H264 stream, use the h264\_metadata bitstream filter
  
  ```
  ffmpeg -i in.mp4 -c copy -bsf:v "h264_metadata=sample_aspect_ratio=4/3" out.mp4
  
  ```
  
  > **Comments:**
  > **username_2**: that did it, thanks !  
  
  ---
  
  ### Answer by username_3 on 2020-02-28. Score: 2
  
  If you want to change the Sample Aspect Ratio (aka Pixel Aspect Ratio) without reencoding use **mkvmerge** or **mp4box**:
  
  mkvmerge
  
  ```
  mkvmerge -o "out.mp4" --aspect-ratio-factor 0:4/3 "in.mp4"
  
  ```
  
  mp4box
  
  ```
  mp4box -add in.mp4 -par 1=4:3 out.mp4
  
  ```
  
  In `ffmpeg` you **cannot** combine a filter with `-c copy` ...
  
  ```
  ffmpeg -i in.mp4 -vf setsar=sar=4/3 -map 0 -c copy out.mp4
  
  ```
  
  because
  
  ```
  Filtering and streamcopy cannot be used together.
  
  ```
  
  
  ---
  
  