Author Topic: Question on Anamorphic Encoding  (Read 447 times)

Offline Phobicpanda

  • Member
  • Posts: 35
Question on Anamorphic Encoding
« on: December 02, 2012, 03:31:18 PM »
What is the best way or most used way to do anamorphic encoding?

Crop and then set 4/3 or 16/9 in mkvmerge?

Or is there a certain way to do this with x264's --sar?

I even sometimes see people doing 720x480 anamorphic 4:3 or 16:9.

I'm just curious as I can not really find anything online that helps me with this.

Also, I sometimes see that Blu-Ray encodes are sometimes not 1920x1080/1440x1080/1280x720/960x720. Is this because when you crop that you leave the resolution as is and do not mess with the aspect ratio?

Online Duki3003

  • Admin
  • Member
  • Posts: 4420

Offline kureshii

  • Former Staff
  • Member
  • Posts: 4485
  • May typeset edited light novels if asked nicely.
Re: Question on Anamorphic Encoding
« Reply #2 on: December 03, 2012, 01:49:11 AM »
What is the best way or most used way to do anamorphic encoding?

Crop and then set 4/3 or 16/9 in mkvmerge?

Or is there a certain way to do this with x264's --sar?
There really isn't a quick and easy way to answer this, aside from posting a link without any explanation, as demonstrated above.

If you're encoding only for software playback (in mplayer/MPC/VLC/etc), either method will work, and you don't really need to worry about it (provided you give the correct SAR/DAR numbers of course).

But if you want this to work on hardware devices/players, you'll first have to know how they handle the video. Some make it really difficult for you to tweak how video display ends up, and in general not all hardware will do this the same way. Truly MKV-compliant players should pull the DAR info from the mkv container (as set by mkvmerge), while most other players will pull the SAR/PAR from the video stream (as set via x264 --sar). Setting AR in the video stream will probably work better on hardware players in general, although in my experience encoding to mkv directly from x264 seems to set both.

Also, I sometimes see that Blu-Ray encodes are sometimes not 1920x1080/1440x1080/1280x720/960x720. Is this because when you crop that you leave the resolution as is and do not mess with the aspect ratio?

Yes. If you do not crop to scale, you will not end up with the same aspect ratio. For example, if you take off 10 pixels vertically and 10 pixels horizontally from a 16:9 video, the resulting video will not be 16:9. You'll have to recalculate the DAR in such cases.

Offline Phobicpanda

  • Member
  • Posts: 35
Re: Question on Anamorphic Encoding
« Reply #3 on: December 03, 2012, 03:00:04 AM »
What is the best way or most used way to do anamorphic encoding?

Crop and then set 4/3 or 16/9 in mkvmerge?

Or is there a certain way to do this with x264's --sar?
There really isn't a quick and easy way to answer this, aside from posting a link without any explanation, as demonstrated above.

If you're encoding only for software playback (in mplayer/MPC/VLC/etc), either method will work, and you don't really need to worry about it (provided you give the correct SAR/DAR numbers of course).

But if you want this to work on hardware devices/players, you'll first have to know how they handle the video. Some make it really difficult for you to tweak how video display ends up, and in general not all hardware will do this the same way. Truly MKV-compliant players should pull the DAR info from the mkv container (as set by mkvmerge), while most other players will pull the SAR/PAR from the video stream (as set via x264 --sar). Setting AR in the video stream will probably work better on hardware players in general, although in my experience encoding to mkv directly from x264 seems to set both.

Also, I sometimes see that Blu-Ray encodes are sometimes not 1920x1080/1440x1080/1280x720/960x720. Is this because when you crop that you leave the resolution as is and do not mess with the aspect ratio?

Yes. If you do not crop to scale, you will not end up with the same aspect ratio. For example, if you take off 10 pixels vertically and 10 pixels horizontally from a 16:9 video, the resulting video will not be 16:9. You'll have to recalculate the DAR in such cases.

Thank you! One last question though. How do I determine what the correct numbers are for --sar

Offline kureshii

  • Former Staff
  • Member
  • Posts: 4485
  • May typeset edited light novels if asked nicely.
Re: Question on Anamorphic Encoding
« Reply #4 on: December 03, 2012, 03:49:50 AM »
Thank you! One last question though. How do I determine what the correct numbers are for --sar
If you know your video source, you can get the PAR (note that x264’s --sar option refers to sample aspect ratio a.k.a. pixel aspect ratio/PAR, not storage aspect ratio) from a list of PARs of standard video formats. This is the best and technically correct way to do it.

However, if you suspect that the source was incorrectly mastered, or you are doing some x264 testing etc, you will have to calculate the PAR yourself using the formula

frame AR × pixel AR = display AR

frame AR = pixel dimensions of your source
pixel AR = what you feed to x264 --sar
display AR = final desired resolution

(I’ve replaced “SAR” in the wiki link with “Frame AR” to avoid confusion, since that SAR refers to storage AR.)

If it sounds confusing, I offer my regrets but it’s just not easy to summarise years of video standards extension and evolution, and differences between them. If you have some old, arcane, broken source and are trying to figure out the correct fAR/pAR/dAR, you have my sympathies.

Offline Temuthril

  • Member
  • Posts: 1140
Re: Question on Anamorphic Encoding
« Reply #5 on: December 03, 2012, 11:51:27 AM »

Offline Phobicpanda

  • Member
  • Posts: 35
Re: Question on Anamorphic Encoding
« Reply #6 on: December 03, 2012, 12:09:34 PM »
Thanks! This answered my question.