Log in

View Full Version : How to generate the highest quality, most standards-compliant...


MyFutureSelfnMe
1st October 2008, 04:10
How to generate the highest quality, most standards-compliant...



...transcoded Blu-Ray backups in the world:


I've discovered the following information while trying to recode a bunch of Blu-Ray titles from their 20+GB, 1080p selves to 4GB, 720p variants that can be successfully burned to DVD+R discs. If you follow these instructions, you can achieve this with rather spectacular results.

As a prerequisite, of course, you need to install AnyDVD to gain unencrypted access to the .m2ts files on your Blu-Ray disc. The main title of your movie will generally be stored in one large .m2ts file.

Nero Recode uses the infamous Ateme h.264 encoder, which is closed source, proprietary, and produces decisively higher quality output than x264. Unfortunately, and this is nothing to do with Ateme, Nero Recode itself (like many video processing applications) is a bug ridden piece of ****. It is impossible to directly encode m2ts files to mp4 files using Recode, despite the fact that the m2ts files appear in the "Import Files" dialog.

It is very occasionally possible (as with A Scanner Darkly) to rename an .m2ts file to .mp4 and recode it directly using Nero. This is because Nero -does- have the ability to parse the ts format, it just has issues with some of the streams.

There are some movies, such as The Shining, that successfully recode using that method in 1 pass mode, but freeze after a few minutes in 2 pass mode. It is sometimes possible to successfully encode these in 2 pass mode by using the "Trim Movie" button to reduce the length of the film by 1 second.

Yet another possibility that has worked for me once or twice is to use tsMuxer to convert the .m2ts file to a .ts file, rename the .ts file to .mp4, and import that in Recode.

None of these methods are going to work if you rename your m2ts file, import it in Recode, and find an oddball frame rate such as 22.976. At this point, it's safe to say your h.264 stream is not going to be correctly parsed by Recode. If you attempt it, you will get one seriously jerky movie. In this case, the following may be useful:



To copy the video track:

You cannot extract the h.264 track from the m2ts file, place it in another container format, and encode it with Recode. You will get the exact same result. You need to use a *very recent* version of mencoder to transcode it to another format, and then import the resulting file in Recode. It's important to note that you also cannot just transcode your h.264 stream to another h.264 stream; you will also get the same result. There are two possibilities:

If you have a lot of disk space, you can copy your stream to a raw-video AVI file. This is your lossless option, and will achieve identical results as if Nero Recode didn't suck and was able to handle your m2ts file directly. For a 1080p Blu-Ray title, excluding sound which you don't need at this step, this will generally result in a 580Mbps video stream, which translates to 71MB per second, 4.1GB per minute, and 415GB for a 100 minute feature film. This is a viable and recommended option for those of you with a 1TB+ drive with a lot of free space.

mencoder file.m2ts -ovc raw -nosound -o file.avi

If you do not have half a terabyte of free disk space, your second best option is to encode with XviD with fixed_quant=1. The difference in picture quality between this and raw video is negligible, especially if you're planning to scale it down later to 720p. The main difference will be the occasional bead of sweat on an actor's face that is just a shade or two fainter than in the original video. This method will generally result in 10:1 compression versus raw video; a 60Mbps stream, or between 1x and 2x the size of your original m2ts file. Just be prepared to let mencoder run all night.

mencoder file.m2ts -ovc xvid -xvidencopts fixed_quant=1 -nosound -o file.avi

Now you can import file.avi in Nero Recode, and recode it to file.mp4. I recommend you manually tweak the cropping, disable it if it's some small value like 2 or 4 or 8, use Lanczos resampling if you're scaling your video, and use the "Best" encoder quality. And, of course, use 2 pass! For the purposes of my exercise, I generally scale the video to 1280x720 (or 1280x544 for letterboxed) and use something around 4Mbps.



Of course, unless you're encoding Charlie Chaplin or something, you're not done yet. You need to copy the audio track. For most movies, I can successfully rename the original .m2ts file to .mp4, accepting the fact that the video is not going to copy correctly, set the video quality options to the bare minimum, crop it to some tiny 60x60 postage stamp or whatever, use 1 pass, use the default options for 5.1 audio or 128kbps for stereo, and generate a second .mp4 file for your audio.

Sometimes, for whatever reason, Nero Recode -really- doesn't like your movie, and refuses to do even this. There is also the possibility that you want to save time; I think this method is faster. The following works for DTS tracks:

1. Run tsMuxerGUI, which is itself pretty buggy but I'm too lazy to create a meta file for tsMuxer myself. Check the "demux" box near the bottom of the window now. Click "add" and open your original .m2ts file. Uncheck every track except the first audio track, which is probably DTS-HD. Click "Start muxing". This will generate a .dts file. If the track is PCM, a .wav file (or several, split at the 4GB mark) will be generated instead.

2. If the previous step generated a .dts or .ac3 file, run the following command to convert your file to a multichannel .wav file:

tranzcode file.dts /mch

This does a pretty good job, but unfortunately doesn't support the lossless capability of DTS-HD. Only the lossy portion of the track will be copied. No utilities seem to fully support DTS-HD at the time of this writing. That's not to say your results will be bad; 1.5Mbps lossy DTS sounds pretty ok.

3. Use the Nero command line AAC encoder to convert your .wav file to an .aac file:

neroAacEnc -br 229376 -2pass -ignorelength -if file(multichn).wav -of file.aac

This encodes the AAC file using variable bit rate with a 224kbps target. This would be the default in Nero Recode as well. The ignorelength flag is necessary for .wav files over 4GB.



If you want subtitles, don't let Nero do them for you. The standard subtitle format for mp4 files is "ttxt", or timed text. Nero uses its own proprietary format. ttxt is a UTF8 text format, as opposed to the bitmap format stored in your m2ts file (or used by Nero). Unfortunately the only player at the time of this writing that currently supports ttxt is the VLC Media Player. I'm sure others will follow suit. If you're not willing to wait, you can store your subtitles in a separate file, such as SRT or the newer SSA. These are supported by ffdshow as well as most other apps.

Either way, you are going to need to rip the subtitle track from your m2ts file and do OCR on it. To rip the subtitle track by itself, you need an old version of Xport, xport096.

xport -hj file.m2ts 1 1 1 1

This will generate a file called bits0001.sup. You can load this file in SupRip to convert it to a text-based format. Unfortunately, SupRip's OCR is quite shitty, and you could easily spend an hour manually fixing all its mistakes in Notepad. For this reason, I often skip this step.


Now that you have all the tracks you need - h.264, aac, and possibly .srt - you can simply load them in YAMB to mux them into a single mp4 file.

Congratulations, you just did the highest quality Blu-Ray transcode that is currently possible. It will be at least a couple years before it gets much better than this :) Hopefully Ahead will clean up their act so all these steps are no longer necessary.

Good luck!
-MyFutureSelfnMe, aka Friendo



The following software was referred to in this post:

Nero Recode 3 [part of Nero 8]: http://www.nero.com
SlySoft AnyDVD: http://static.slysoft.com/SetupAnyDVD.exe
tsMuxer: http://www.smlabs.net/tsMuxer/tsMuxeR_1.8.4(b).zip
MPlayer/MEncoder [requires 7zip]: http://voxel.dl.sourceforge.net/sourceforge/mplayer-win32/MPlayer-p4-svn-27323.7z
Tranzcode 0.40 beta: http://hlava.org/data/Tranzcode_v0.40(beta).rar
Nero Reference AAC Encoder: http://ftp6.nero.com/tools/NeroDigitalAudio.zip
XPort 0.96: http://downloads.hdfrance.fr/chilly996/xport_0.96.zip
SupRip: http://exar.ch/suprip/suprip-1.01.rar
YAMB: http://yamb.unite-video.com/Yamb-2.0.0.8.zip

poisondeathray
1st October 2008, 04:21
...Nero Recode uses the infamous Ateme h.264 encoder, which is closed source, proprietary, and produces decisively higher quality output than x264....



I've only seen limited head to head testing, but it seems to produce worse quality than x264..."highest quality" might be subjective and is taboo around these parts :)

Here were some older tests done by Dark S.
http://mirror05.x264.nl/Dark/website/compare.html

Otherwise, thanks for sharing your insights. Personally, I find anydvd + ripbot264 +/- eac3to basically does everything here in a simpler workflow

Dark Shikari
1st October 2008, 04:29
Nero Recode uses the infamous Ateme h.264 encoder, which is closed source, proprietary, and produces decisively higher quality output than x264. Um, what? One could make arguments that in some cases the current Ateme encoder beats x264 in some circumstances (though I have yet to encounter any test where this has been the case), but the encoder core used in Recode is ancient... its over 4 years old and, accordingly, is junk compared to x264. Nevermind the fact that its not even fully-featured; it is crippled compared to Ateme's much-higher-priced professional encoders.

Of course, any such comparison is simply being unfair to Ateme given how old the encoder is; one cannot expect it to have a chance against modern encoders after so many years. Ateme has done an enormous amount of development since the Recode encoder core.

(Also, since when is Ateme "infamous"? Are they infamous for poaching Laurent Aimar, the original author of x264?)

Sagekilla
1st October 2008, 04:44
IIRC, Nero Recode was such a kludge to use for me that I actually switched to StaxRip. Nice improvement in quality over Recode too. If you want extremely high compression @ ~4 GB then this is what you wanna use in x264:

(Didn't say it would be fast though.)

x264 --crf 19 --ref 16 --mixed-refs --bframes 16 --b-adapt2 --bime --weightb --b-rdo --b-pyramid --me tesa --subme 7 --trellis 2 --psy-rd 1:1 --8x8dct --direct-8x8 -1 --threads auto --progress "source.avs" --output "video.264"



If you want more sane, but still high compression settings for 720p:

x264 --crf 19 --ref 6 --mixed-refs --bframes 4 --b-adapt 2 --bime --weightb --b-rdo --b-pyramid --me umh --subme 6 --trellis 2 --psy-rd 1:1 --8x8dct --direct-8x8 -1 --threads auto --progress "source.avs" --output "video.264"


Either will give around ~4 GB backups including a 640 kbps AC3, at least I have anyway ;)

plonk420
1st October 2008, 05:07
unless you're encoding something short like a TV show, i question that you're going to get something of "highest quality" in 4.7gb. you can get something that looks good on CRT or DLP, but LCD is ... uh ... challenging to encode for in a small amount of space...

however that's me ASSuming you're encoding for max quality on ANY person's system, be it LCD, DLP, CRT, plasma, etc...

Sagekilla
1st October 2008, 06:05
@plonk420: Dunno what settings you're using but I can get 4.7 GB rips in very good quality :) I do a little extra prefiltering with MVDegrain, but on a 1920x1200 laptop screen (Read: LCD that's about 2-4 feet from my face, very easy to see any artifacts) it looks great.

The nice thing is I use crf, and I usually get below 4 GB for a rip. I don't know how but one of mine managed to be about 3 GB once, same quality and all.


Edit: Oops, I noticed you said highest quality. That's a bit subjective, and IMO I find the ~4 - 5 GB for 720p rips to be just right for that. Quality is tricky like that, eh?

Blue_MiSfit
1st October 2008, 08:39
A 1920x1200 laptop screen is _not_ the same thing as a 50+ inch LCD :)

MVDegrain helps, but is brutally slow for 1080p. Sure, you're doing 720p, and lots of HD sources don't really deserve full 1080p - but you can't really get excellent results for all titles at 4-5GB each

I guess if it's enough for you, that's fine :)

~MiSfit

CruNcher
1st October 2008, 19:53
Ateme does heavy PSY research,they even have patents in that field it's interesting that people believe perceptually that still hold against x264 even in the super old encoder core :) but really it doesn't surprise me (for certain situations) and overall look & feel :D

I find it super interesting how a mathematical not as efficient encoder that's so old can still beat in the eyes of alot of viewers a such efficiency improved encoder in sane bitrate situations as x264 also given the timeframe difference :) (i wish there would be a scientific blind test being done between both)

Tough of course X264 now has Psy-RD which seems to be a hard contender in that field now

plonk420
1st October 2008, 21:25
@plonk420: Dunno what settings you're using but I can get 4.7 GB rips in very good quality :) I do a little extra prefiltering with MVDegrain, but on a 1920x1200 laptop screen (Read: LCD that's about 2-4 feet from my face, very easy to see any artifacts) it looks great.

4.7gb rips look good to me, too, but then again i'm only watching on DLP.

i haven't tried TOO many HD rips (but i dabble quite a bit in converting demoscene demos into 720p60 encodes), but i've done (movie) dvdrips (with resizing) that i've gotten down to 300 or 400mb that look amazing on CRT and even a huuuge DLP screen, but not good at all on LCD, so i DEFINITELY know (and love) the power of x264 :D

Sagekilla
1st October 2008, 21:27
@Blue_MisFit: Indeed it is not, but you can't deny the fact that when you're dealing with an image very close to your eyes (You can resolve the details better) it becomes VERY easy to see anything that seems "bad"'

I also use --crf 18 or 19, and I've -never- had it jump over 4.5 GB for the video of an encode. I think most people here agree that crf 18 is very high quality for that matter. As you said, not everything deserves 1080p. I've tried it, and it's just not worth the longer encoding time and storage for 1080p vs 720p.