PDA

View Full Version : Recommendations for encoding PAL/NTSC to 1:1 PAR?


Aylwin
18th January 2008, 10:47
I'm currently backing up my DVDs to H.264/MKV for playback on a media player connected to a widescreen TV and/or 720p display. The output from the media player is PAL (576i) or NTSC (480i) depending on the source (MKV file). Also, the media player can't handle anamorphic encodes or non-square pixels so it needs 1:1 PAR.

The discussion from this thread (http://forum.doom9.org/showthread.php?p=1088431#1088431) got me wondering:
What are the best dimensions to use when encoding PAL/NTSC source to H.264/MKV with 1:1 PAR for playback on a TV?

Using my fuzzy logic, my idea is to keep the height and adjust the width accordingly. And so I end up with the following:

PAL (720 x 576)
4:3 - 768 x 576
16:9 - 1024 x 576
2.35:1 - 1024 x 435 (576 minus black bars)

NTSC (720 x 480)
4:3 - 640 x 480
16:9 - 853 x 480
2.35:1 - 853 x 362 (480 minus black bars)

My reasoning for this is that the media player only needs to deal with the width (by compressing or stretching it back to 720) while leaving the height as is. Hopefully, this means that there's as little resizing as possible.

Is my logic correct? If not, why? What dimensions would be better? Remember, these files are not for playback on a computer monitor. The playback output will be PAL or NTSC signals.

All comments are welcome. I use AutoMKV (http://forum.doom9.org/showthread.php?t=113811) and would appreciate recommendations on filter settings, etc.

valnar
18th January 2008, 12:22
I'm still poking around with this concept too, as you know. The big question is does 853x give you all the original pixels from the DVD without losing any? Upscaling is better than downscaling.

I haven't the time to do this today, but a good way of testing this theory is to compress AVIA or some other DVD with detailed sharpness patterns. See if it looks like the original with the same clarity. This of course assumes a good quality encode (CRF18,20) with a good resizer.

Robert

Wishbringer
18th January 2008, 12:42
You if you have a 720p display = 1280x720, i would suggest to keep height and stretch width as you descriped.
Otherwise you would loose details when shrinking height.
<= this is only meant for your details in resulting media file, not for display!

Because now it depends how your mediaplayer handles that file:
720p Flatscreen (1280x720): 16:9 file at 1024x576 would be resized to 1280x720 by player and/or tv
<= all details are still there
widescreen pal (720x576): i dont know if your player sends an signal to tv to display 720x576 at 16:9 or if it internally reduces to 720x4yy at square pixel or 4:3 and then sends video without signaling to tv
<= so there could be a loss in quality in resizing height, even if you encoded it right. But that would then always happen...

nm
18th January 2008, 12:43
I'm currently backing up my DVDs to H.264/MKV for playback on a media player connected to a widescreen TV and/or 720p display. The output from the media player is PAL (576i) or NTSC (480i) depending on the source (MKV file). Also, the media player can't handle anamorphic encodes or non-square pixels so it needs 1:1 PAR.
Just curious, what is this device that can play H.264 in a Matroska container, but doesn't handle anamorphic aspect ratios?

valnar
18th January 2008, 13:05
Just curious, what is this device that can play H.264 in a Matroska container, but doesn't handle anamorphic aspect ratios?

The SageTV HD Extender, although that can possibly be fixed in software.

Robert

Aylwin
18th January 2008, 13:14
...a good way of testing this theory is to compress AVIA or some other DVD with detailed sharpness patterns. See if it looks like the original with the same clarity. This of course assumes a good quality encode (CRF18,20) with a good resizer.
Good idea. Not sure when I'll have time to do this though. :( So I'll just wait for you. ;)

Because now it depends how your mediaplayer handles that file:
720p Flatscreen (1280x720): 16:9 file at 1024x576 would be resized to 1280x720 by player and/or tv
<= all details are still there
widescreen pal (720x576): i dont know if your player sends an signal to tv to display 720x576 at 16:9 or if it internally reduces to 720x4yy at square pixel or 4:3...
Good point. I'm not entirely sure how the media player handles the files. What I do know though is that the output is anamorphic PAL (720x576)/NTSC (720x480) because that's what I configure the media player to do. Upscaling to 720p (1280x720) is done externally.

So what I'm after is the ideal encoding resolution of PAL/NTSC source which will be used for PAL/NTSC output.

Just curious, what is this device that can play H.264 in a Matroska container, but doesn't handle anamorphic aspect ratios?
There are a few devices out now that can handle MKV. I use the "older" TViX M-4100SH (http://www.tvix.co.kr/Eng/products/4100sh.aspx). Sadly, it doesn't handle anamorphic encodes. So if I encode an anamorphic PAL DVD to 720x576 with a DAR of 16/9, the media player will simply output a 5/4 image (720/576) with black bars on the side. I've already informed TViX about this bug but they don't seem interested in fixing it.

Anyway, I think it's better to encode with 1:1 PAR for better compatibility.

nm
18th January 2008, 13:45
There are a few devices out now that can handle MKV. I use the "older" TViX M-4100SH (http://www.tvix.co.kr/Eng/products/4100sh.aspx). Sadly, it doesn't handle anamorphic encodes. So if I encode an anamorphic PAL DVD to 720x576 with a DAR of 16/9, the media player will simply output a 5/4 image (720/576) with black bars on the side. I've already informed TViX about this bug but they don't seem interested in fixing it.
Have you tried signaling the aspect ratio both in the H.264 elementary stream and in Matroska headers? How about using MP4 instead of Matroska?

Anyway, I think it's better to encode with 1:1 PAR for better compatibility.
Perhaps, but non-square pixel aspect ratios are also pretty standard stuff considering that these devices are designed for playing back DVD rips.

delacroixp
18th January 2008, 15:31
I'm still poking around with this concept too, as you know.
The big question is does 853x give you all the original pixels from the DVD without losing any?
Upscaling is better than downscaling.

I haven't the time to do this today, but a good way of testing this theory is to compress AVIA or some other DVD with detailed sharpness patterns.
See if it looks like the original with the same clarity.
This of course assumes a good quality encode (CRF18,20) with a good resizer.

Pixels are only half the battle... bitrate is the other half (1080 HD without any bitrate is meaningless).
If quality is your overiding concern... then maximising the pixels should be followed with a high or very high quality bitrate... at least Q18... possibly even Q17.
It doesn't make sense to go overboard on the pixels... but to then mess up the whole system by skimping on a low bitrate like Q20.


:):devil::D
Pascal

Aylwin
19th January 2008, 09:08
Have you tried signaling the aspect ratio both in the H.264 elementary stream and in Matroska headers?
How do I do this? I'm a newbie and I mostly just use AutoMKV. Maybe I could ask the author if AutoMKV is implemented this way. If not, maybe I could request it as a new feature?

By the way, can MP4 handle multiple audio streams? Anyway,
I prefer to use MKV since it can also embed subtitles.

Perhaps, but non-square pixel aspect ratios are also pretty standard stuff considering that these devices are designed for playing back DVD rips.
I'm not sure about other formats (Xvid/AVI, MP4, etc.). Maybe those files playback correctly. But MKV support on media players is still very new. The first chip I know of that officially supports MKV is the Sigma Designs SMP8634/8635. So far, only a handful of media players use this chip. My media player uses an older chip and MKV support was implemented entirely by software.

Pixels are only half the battle... bitrate is the other half...
True but I wouldn't place equal importance on the two. Or at least, I would like to figure out the pixels first before worrying about bitrate.

If the dimensions are wrong then there'll be too much resizing (both horizontal and vertical) going on from the source to the encoded file, to the player, to the display device. And every time we resize, quality is affected.

buzzqw
19th January 2008, 09:15
How do I do this? I'm a newbie and I mostly just use AutoMKV. Maybe I could ask the author if AutoMKV is implemented this way. If not, maybe I could request it as a new feature?

on the 0.95 branch the ar signaling is both done on raw h264 and when muxing in mkv or mp4

By the way, can MP4 handle multiple audio streams? Anyway,
yes, of course.. just not ac3..

I prefer to use MKV since it can also embed subtitles

mp4 support idx/sub and srt (iirc..)

BHH

valnar
19th January 2008, 13:55
on the 0.95 branch the ar signaling is both done on raw h264 and when muxing in mkv or mp4


Buzz,
Does AutoMKV uses "--engage keep_bitstream_ar_info" for MKVmerge? I wonder if that may help.

Robert

buzzqw
19th January 2008, 15:35
no

since raw h264 don't keep the signal when importing into mkv (that's why i force signal in mkv/mp4)

BHH

facialz
29th February 2008, 17:23
In cases of sample aspect ratio (SAR) > 1 the simplest way to keep original resolution at minimal pixel count (hence, file size) is to remove black stripes and not to resize. So the display aspect ratio (DAR) should change to that of the content while the original SAR should be left intact.

To archive content of DAR ~2.4:

1) For PAL 16/9 (image 720/576):

1a) crop to 720/432. Keep target SAR=16/11, set new target DAR = 80/33, or

1b) crop to 704/432. Keep target SAR=16/11, set new target DAR = 64/27.


2) For NTSC 16/9 (image 720/480):

2a) crop to 720/360. Keep target SAR = 40/33, set new target DAR = 80/33, or

2b) crop to 704/360. Keep target SAR = 40/33, set new target DAR = 64/27.

Note that 360 is not divisible by 16 so this cropped format is only as efficient as 704/368.


mp4box and mkvmerge support anamorphically encoded video. mp4box allows specifying the SAR while mkvmerge allows specifying the DAR. So encoding to either .mp4 or .mkv should be without problem.