I have the following code to convert HDV video to a web ready mp4:

ffmpeg -i hdv-input.m2t -crf 28 -c:a aac -b:a 80k -ac 1 -strict -2 -movflags +faststart h-264-out.mp4

The problem is that there is nowhere in this command to specify pixel aspect ratio. If you are not aware, HDV video files are 1440x1080, but the pixels are not square. When decoded for display, the pixels are stretched to make a full 1920x1080. This is called anamorphic video, and it is something that should definitely be avoided if producing for end users.

I honestly don't know if the mp4's I'm making with the above command are being produced with square pixels, but I want to make sure they are. What are the correct parameters I need to add to this command to ensure square pixels in my output mp4? Do I also have to set resolution, and how do I do that? It seems like there should be a -c:v command as well, but I don't really know.

1 Answer 1


You can use a combo of the scale and setsar filters.

ffmpeg -i hdv-input.m2t -vf "scale=iw*sar:ih,setsar=1" -crf 28 -c:a aac -b:a 80k -ac 1 -movflags +faststart h-264-out.mp4

The scaler width to set to current width x sample/pixel aspect. If it's already 1, it amounts to new width = old width. I've added a setsar afterwards to ensure the output SAR is 1.

For MP4 format, default video codec is H.264. If that's what you want, no need to explicitly set c:v.

(For bitrates < 128k, libfdk_aac is better than the native AAC encoder.)

-strict -2 is not needed for using native AAC encoder if your ffmpeg is from after Dec 2015.

  • 1
    So this command will output square pixels, but at the same resolution size as the input?
    – user3643
    Mar 9, 2017 at 20:33
  • 1
    At the same display resolution as the input.
    – Gyan
    Mar 10, 2017 at 4:58
  • I think you need "... setsar=1:1,setdar=16:9 ..." - See: video.stackexchange.com/questions/9947/… .
    – Rob
    Mar 10, 2017 at 17:15
  • All setdar does is alter the SAR so that the resultant video when displayed has width = DAR x height. For the OP's use case, setdar would be redundant. For other videos, it would force display to be 16:9,
    – Gyan
    Mar 10, 2017 at 17:36
  • 1
    Due to license incompatibility, binaries cannot be distributed with that library included. You'll have to compile ffmpeg yourself with that library. I use this script to autocompile ffmpeg. First run will take 4-5 hours on an i7. Further runs, 2 hours or so.
    – Gyan
    Mar 20, 2017 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.