Log in

View Full Version : DVD --> H264 + AAC + MKV Help


Eretria-chan
25th May 2007, 01:29
I don't have much experience so I thought I'd ask...
I'm trying to backup a DVD with x264, AAC into MKV. I'm trying to get near perfect or perfect DVD quality w/ 5 channel audio (Dolby Digital or DDS I believe; I could use either maybe?).
I've made a copy of the DVD on disc and stored it on my HD.
The movie is anamorphic widescreen and aspect ratio 2.35:1. Source 720x576 (PAL DVD). Apparently, it's also progressive as far as I can see... I've tried playing and encoding the VOB files directly without any need for deinterlacing...

What I've tried so far is cut a small sample (3 minutes) of the first part of the movie, cropped it to 704x426 (I think?) and then resized it to 704x432 (so both are mod16). Also used a temporal cleaner.
In order: crop, temporal deinterlacer, resize. Is that right? I'd rather resize very little than crop the picture. It really doesn't bother me if it's slightly "squashed" out.
Now, I'm planning on encoding it in 704x432 and then setting widthxheight of video to 1024x432 after the encode. I'm figuring this saves bits. Or is this a big no-no? Maybe I should resize it to its correct size before encoding?
Then it's the encoding story. As I don't really know either mencoder or x264, I'll just use Bencos to do the encoding. The question is whether to use Low, Normal or High quality and what bitrate to use. I was figuring maybe some metric test like PSNR could help a little? I don't know how to measure it...
As far as bitrate goes, 2000 looks very good. Maybe I could lower it to around 1000 or am I pushing it there?
All encodes and filtering and stuff has been done with lossless (Huffyuv). Space is not that much of an issue, but encoding time is rather boring, so rather the lossless be faster than better compression. When it comes to the real thing of doing the real movie encode, it's the reverse--better compression even if it takes longer.
And last there's also the how to convert AC3 5ch --> AAC 5ch. I know there is or was a guide around here somewhere, but when I tried it, it just wouldn't work.

I'd appreciate any help.

JarrettH
25th May 2007, 07:18
Some tidbits out of order:p

- If you go with MKV you can use original audio like AC3 and DTS. MKV will let you use AAC too (lossy), but you'd be better off doing MP4 if you went that route. You can shave at least 40% off your AC3 file if you make it AAC 5.1

- I don't know how you're going to be playing it after, but I would avoid resizing. Your player will do that for you and it just creates artificial detail. ffdshow can resize video in numerous ways too (or call up some avisynth). Cropping it will save bits (5-10% off your video size)

- Lossless x264 will create a gigantic video file. Try 1800+ kbps that's where it begins to be perceptually lossless IMO. Of course it depends on your source

- MeGUI is very popular for x264 encoding. You can start off with one of the profiles: HQ-Slower is likely the best quality/speed and HQ-Slowest has marginal gains. There's a few guides around for x264 and you can modify a few settings in HQ-Slower yourself to make it even better. Experiment with the profile CQ-Lossless too, I've never used it. You can encode your AAC with Nero's encoder through MeGUI
http://gabextreme.googlepages.com/DeathTheSheep_x264_VfW_guide.html
http://www.avidemux.org/admWiki/index.php?title=H264

There's still a few steps you need to do like loading your VOBs into DGIndex and creating a project file before you can use MeGUI, but more on that when you decide how to make it. :)

Awatef
25th May 2007, 11:28
I second Jarett on the resizing thing.
I would rather keep a little bit black bars if it has to be mod16 at any cost, or crop a little bit more to get 424 which is mod8.

I second Jarett on the sound thing too.
As far as I can tell, size is not a big issue for you, so I would rather keep the original AC3 track. DTS is to be avoided as it is much bigger than AC3 and doesn't bring some substantial quality increase if at all!

As for the bitrate, the absolute minimum to get acceptable quality with x264 is 0.1 bit/pixel, so 0.2 bit/pixel or higher should get you near-transparent quality, say at least 1493kbps for 704x424@25fps (depends on the compressibility of your source of course).
If your movie is 1h40 or less, you will be able to achieve at least 1500kbps average bitrate with a 448kbps AC3 track with a size of 1400MB (so called 2-CD rip).

By the way, you don't have to encode to Huffyuv first. You may be losing more time like this. If you wanna make sure, time the huffyuv + 2 x264 passes, and then time direct 2 x264 passes to see which is faster (using a 5 minutes sample for example)

As for the MKV muxing, don't specify any resolution. Just specify the aspect ratio, which would be 2.35 here.

Eretria-chan
25th May 2007, 11:49
- If you go with MKV you can use original audio like AC3 and DTS. MKV will let you use AAC too (lossy), but you'd be better off doing MP4 if you went that route. You can shave at least 40% off your AC3 file if you make it AAC 5.1
I don't like AC3... big and clumsy :p I'd rather like AAC for maximum compression.

- I don't know how you're going to be playing it after, but I would avoid resizing. Your player will do that for you and it just creates artificial detail. ffdshow can resize video in numerous ways too (or call up some avisynth). Cropping it will save bits (5-10% off your video size)
So I should just encode it as anamorphic and then set the correct aspect ratio in the resulting file so the player will strech it to correct aspect ratio?

- Lossless x264 will create a gigantic video file. Try 1800+ kbps that's where it begins to be perceptually lossless IMO. Of course it depends on your source
Of course, I'm not planning on using lossless for the final file. I just use it when creating an intermidiete file, like after using some filters.

If your movie is 1h40 or less, you will be able to achieve at least 1500kbps average bitrate with a 448kbps AC3 track with a size of 1400MB (so called 2-CD rip).
Just as a note, I'm not aiming for X-CD backup. I'm going to get ax much compression as possible with little or no loss in quality and then store the movie, among others, on DVD discs.

By the way, you don't have to encode to Huffyuv first. You may be losing more time like this. If you wanna make sure, time the huffyuv + 2 x264 passes, and then time direct 2 x264 passes to see which is faster (using a 5 minutes sample for example)
Yeah... I know, but I have to somehow add filters and process the source before encoding it and since x264 isn't VFW (well, the one that does exist is out of date), I have to make a lossless encode first before the real encode... unless someone has a better suggestion.

Any ideas on the PSNR topic? Don't have much experience with MeGUI...
The clip looks almost perfect @ 2000, which may be a little much, so it's hard to notice any difference between Low and High quality. I'll try lower bitrates, though.

Awatef
25th May 2007, 13:46
I'd like to clear a point about AAC: there is HE-AAC and LC-AAC. HE-AAC is the one that achieves much higher compression rates than AC3 (you can go as low as 160kbps for 5.1) and for that it sounds like crap in my ears, it's just too artificial, artefacts are clearly hearable.
LC-AAC is the better sounding option, but to achieve acceptable quality, you'll have to go 320kbps for 5.1. You guessed right, not big of a saving compared to AC3 which consumes only 64 to 128kbps more, so better stay by the original AC3 track and make sure you get optimum quality ;)

As for the CD count, I figured out that you're most probably going to burn on DVD-R, but it is good to leave the option of burning on CDs. It will look bad if you wanna burn on CDs and your rip is 1470MB: that's wasting one CD for 70MB.
And generally, going beyond 1400MB is not worth it IMHO, because you could just go ahead and burn a regular DVD-Video instead. The whole point behind DivX and co. is to get as many movies on a disc as possible, and it would be a waste to put less than 3 movies on a DVD-R if you're going the MPEG-4 route (unless you have extra long movies like Lord of the Rings of course, these count as 2-in-1 movies for me :D)
Anyway, whatever your likings, there are limits that shouldn't be crossed, the bit per pixel rule will give you an idea about what you should be expecting from this or that bitrate depending on your resolution choices.

As for the filters, yes, you missed something real important: AviSynth! I thought you were already using it, but it seems like you don't. You put all your parameters in the avs script, and load it in MeGUI and proceed directly to AVC encoding without worrying about a temporary intermediate file.

Eretria-chan
25th May 2007, 14:05
I'd like to clear a point about AAC: there is HE-AAC and LC-AAC. HE-AAC is the one that achieves much higher compression rates than AC3 (you can go as low as 160kbps for 5.1) and for that it sounds like crap in my ears, it's just too artificial, artefacts are clearly hearable.
LC-AAC is the better sounding option, but to achieve acceptable quality, you'll have to go 320kbps for 5.1. You guessed right, not big of a saving compared to AC3 which consumes only 64 to 128kbps more, so better stay by the original AC3 track and make sure you get optimum quality ;)
I don't know about that... HE-AAC+PS @ 32 kbps sound perfectly fine to me (stereo). Heck, even 24 kbps sounds fine, though sometimes (especially movies), it just quite isn't enough. From doing the math, 80 - 96 kbps HE-AAC+PS fits for 5.1. I don't know since I've never been able to do it before, but I suppose that's a moot point since I can do hearing tests...

As for the CD count, I figured out that you're most probably going to burn on DVD-R, but it is good to leave the option of burning on CDs. It will look bad if you wanna burn on CDs and your rip is 1470MB: that's wasting one CD for 70MB.
And generally, going beyond 1400MB is not worth it IMHO, because you could just go ahead and burn a regular DVD-Video instead. The whole point behind DivX and co. is to get as many movies on a disc as possible, and it would be a waste to put less than 3 movies on a DVD-R if you're going the MPEG-4 route (unless you have extra long movies like Lord of the Rings of course, these count as 2-in-1 movies for me :D)
Anyway, whatever your likings, there are limits that shouldn't be crossed, the bit per pixel rule will give you an idea about what you should be expecting from this or that bitrate depending on your resolution choices.
Of course... the movie is about 02:25 in length. So for the given resolution of 704x432@25, what would 0.1 bit/pixel or 0.2 bit/pixel be in bitrate?
I'm just trying to get as much compression as possible. It's going to be stored on the Hard Disk until it's turn to cross the line to the DVD comes. And it's going to be accompanied with other video as well, so more compression for me!

As for the filters, yes, you missed something real important: AviSynth! I thought you were already using it, but it seems like you don't. You put all your parameters in the avs script, and load it in MeGUI and proceed directly to AVC encoding without worrying about a temporary intermediate file.

Not very good at it... VirtualDubMod is so much easier - that's why I've been using it.

Anyhow, MeGUI seems to work for me at the moment and I'm doing some video tests using the HQ profiles.
I just tried HQ-Insane vs HQ-Slow and got this result...

Insane @ 1000:
x264 [info]: SSIM Mean Y:0.9840167
x264 [info]: PSNR Mean Y:49.002 U:51.692 V:51.403 Avg:48.905 Global:45.869

Slow @ 1000:
x264 [info]: SSIM Mean Y:0.9831478
x264 [info]: PSNR Mean Y:48.796 U:51.567 V:51.170 Avg:48.730 Global:45.527

I haven't actually watched the produced clips yet. I'm also having trouble with encoding the audio...
The supposed "guide" (Help->Guide) isn't working either.

Avisynth script be megui:
# Set DAR in encoder to 5 : 3. The following line is for automatic signalling
global MeGUI_darx = 5
global MeGUI_dary = 3
DirectShowSource("I:\VIDEO_TS\VTS_01_1.VOB",fps=25,audio=false)
#deinterlace
crop( 8, 76, -8, -76)

BilinearResize(720,432) # Bilinear (Soft)
#denoise

There's no temporal filter and I don't know what resizing method to use either.
I can't re-encode the audio from DTS to AAC either:

Error:
MeGUI.AviSynthException: Script error: syntax error
(, line 1, column 47)
at MeGUI.AviSynthClip..ctor(String func, String arg, AviSynthColorspace forceColorspace, AviSynthScriptEnvironment env)
at MeGUI.AviSynthAudioEncoder.encode()

I used "Keep original channels", HE-AAC+PS @ 80 kbps.

Awatef
25th May 2007, 14:35
Seems like you didn't understand how I got 1493kbps up there.
It's very easy: you multiply all numbers you have and divide by 1000!
(704 x 424 x 25 x 0.2) / 1000 = 1492.48
If you don't go below that bitrate, you should get near-transparent quality.

As for avisynth: good news! MeGUI makes an avs script automatically for you ;)
Bicubic resizing is a good choice btw.

Finally, about HE-AAC: you must have real crappy speakers for 32kbps stereo to sound good for you!! HE-AAC is a priviliged codec for 1-CD rips of extra long movies, but for a quality rip like the one you're doing, it's like putting a 3-cylinder motor on a Porsche and wonder why it doesn't sound like a Porsche!
Your approach is not logical IMHO.

Eretria-chan
25th May 2007, 14:38
Seems like you didn't understand how I got 1493kbps up there.
It's very easy: you multiply all numbers you have and divide by 1000!
(704 x 424 x 25 x 0.2) / 1000 = 1492.48
If you don't go below that bitrate, you should get near-transparent quality.
I see... terrfiic. I'll try!

Finally, about HE-AAC: you must have real crappy speakers for 32kbps stereo to sound good for you!! HE-AAC is a priviliged codec for 1-CD rips of extra long movies, but for a quality rip like the one you're doing, it's like putting a 3-cylinder motor on a Porsche and wonder why it doesn't sound like a Porsche!
Your approach is not logical IMHO.

No, the speakers are pretty good... but everyone has a different way of interpreting sound I guess, because it sounds perfectly fine to me! ;)

Awatef
25th May 2007, 14:44
...because it sounds perfectly fine to me! ;)

VE~RY STRANGE!

Eretria-chan
25th May 2007, 14:48
Still, I wonder, does these small gaps in the numbers mean a lot of quality loss/gain?

Insane @ 1000:
x264 [info]: SSIM Mean Y:0.9840167
x264 [info]: PSNR Mean Y:49.002 U:51.692 V:51.403 Avg:48.905 Global:45.869

Slow @ 1000:
x264 [info]: SSIM Mean Y:0.9831478
x264 [info]: PSNR Mean Y:48.796 U:51.567 V:51.170 Avg:48.730 Global:45.527

Slow @ 2000:
x264 [info]: SSIM Mean Y:0.9894782
x264 [info]: PSNR Mean Y:50.998 U:52.827 V:52.756 Avg:50.874 Global:48.110

Insane @ 2000:
x264 [info]: SSIM Mean Y:0.9900939
x264 [info]: PSNR Mean Y:51.388 U:53.050 V:53.249 Avg:51.116 Global:48.457

PSNR differs by 2-3 dB. SSIM different not quite by even 0.01! I haven't actually looked at the encoded clips, but it must be pretty significant, yes?

Awatef
25th May 2007, 14:53
I'm not proficient at reading those values, but from what I know, the differences are significant.
Like sound, 43db is twice as loud as 40db!