Tuesday, January 20, 2009

Don't Harsh My Melos: Restoring A Classic Clusterfork


Source



Kentai Restoration


Recently I got a message from someone who, evidently, was plenty impressed with my work on Pinku VHS restoration. He asked me if I'd be interested in trying to restore an MPEG2 recording he had from an early 90s laserdisc. The title was 走れメロス!/HASHIRE MELOS! (Run Melos!), a 1992 theatrical film version of a classic Japanese take on a Greek folk tale. There was also a TV special animated in 1981, which was released dubbed in English back in the early 80s. It's also terrible. This one is far less so.

I told him, sure, I'd see what I can do, but reminded him that I can't work miracles. How good any source can be restored is squarely up to the source itself, and what those problems entail. His reply was, more or less, "don't worry, it's so bad that anything you can do would be an improvement." I'll be damned if he wasn't telling the truth.

I could pretend like I had this one down from the start, because I'm a video restoration demigod lording over other restoration peons, but I'll admit it: I was tempted to fuck this one up pretty badly. From the looks of things this was recorded from a less-than perfect to begin with LD straight into a middle of the road DVD recorder (or similar PC device), which did little to filter out the composite rainbows and added plenty of fugly mosquito noise and macroblocking, even on scenes that are relatively easy to compress.

Then again there could be some even more infuriating story behind this, as there's some really horrific color blocking, so I'm not convinced a DV connection wasn't used at some point in the chain... exactly why, I can't imagine. The audio was also the rarely wanted MPEG layer 2 .MPA format, which makes me wonder if a less than ideal encoder - say, TMPGEnc - was to blame? Without having the full story I can't be sure, but even when TMPGEnc is used properly (and the program is so 'effing complex, it's easy to screw it up), the quality simply isn't there. It was a godsend in the days of VCD, but we've come a long way since the days when blank DVDs were $8 a piece.



In Ancient Greece, they called frames like this "Satyr Dung".

Anyway, left to my own devices with a 5+ gig MPEG file and far too much free time in AVISynth, I did what was possible. I'll admit it wasn't a hell of a lot:

mpeg2source("f:\[...]\Hashire Melos.d2v",CPU=1)
BiFrost()
Telecide(post=0)
Decimate(5)
Levels(0,1,255,-16,270)
Crop(0,46,0,-56)
RemoveGrain(2)
AddBorders(18,0,6,0)
LanczosResize(720,480)
ConvertToYUY2()

Allow me, if I may, to point out why each filter is here, and exactly what it does. No, it won't be 'useful' unless (like me) you decide to become a crazy hermit who tries restoring shitty composite video all day, but some of you may still find it neat regardless.

mpeg2source("f:\[...]\Hashire Melos.d2v",CPU=1)

While this line loads the D2V ("dummy" MPEG2 file), the "CPU" is the tricky part. This is a built-in deblocker, with values from '0' (off) to '6', more power performing more deblocking. The concept of a "deblocker" is to find chunks that specifically look like compression artifacts and then smooth them away temporally, using left over frames in the same GOP. It's an awesome theory, but because every frame in a GOP has a different level of compression, each frame will get a different level of deblocking. Particularly on higher settings, this will mean that the video will literally strobe between being in focus and being smeared beyond recognition, because the deblock filter understands compression gains versus actual "detail" or "noise". With this in mind, keep this as low as you can stand, 'off' if at all possible. You can't get rid of compression artifacts, only try to fuzz them out of existence, and if you're going direct to high bitrate DVD anyway that's just... well, stupid.

BiFrost()

Oh, my GOD how I love BiFrost. Here's exactly what it does:


Goodbye, rainbows! The side-effect is... uh... so, did I mention that I <3 BiFrost? Naturally it can't conquer every composite artifact that you can throw at it, but it does a far better job than it has any right to do, and I no longer feel the need to purchase a hardware based comb filter for this nonsense. Why bother? Those results are fantastic!

Remember kiddies: ALWAYS use comb filters before you IVTC/Deinterlace. The interlaced frames have chroma information that gets discared in the process, so if you don't do this first, it's simply too late for it to do anything useful.

Telecide(post=0)
Decimate(5)

This, dear friends, is the one-two magic ULTRA COMBO!! that converts interlaced material into progressive material. Yes, I can do this by hand. And have. But so long as you don't convert the colorspace FIRST, the filter does all the work for you and (9 times out of 10) does a damn good job of it. I wouldn't recommend using this on most anime productions, seeing as how the IVTC algorithms out there are used to constantly changing live action material as opposed to the limited framerates you typically get out of animation, but seeing as how Melos was a theatrical movie (no video editing here!) with solid 3:2 pulldown and better than average animation, I've yet to notice any issues with the IVTC. The "post" part is the deinterlacing option, and for most anime should be fine-tuned... personally, I keep it at "0", since I'd rather have a frame or two of combing than a frame or two of deinterlacing. Your tolerance may - and likely, will - vary.

Could I tweak these settings to ensure I'm not losing my 3:2 pattern? Absolutely. But honestly, even with OCD paramater fudging, either you've got an NTSC transfer with decent 3:2 pattern or you don't. If you don't, you either need to do it by hand or keep it as-is. Because of later steps, keeping it interlaced isn't an option, so away we go.

Levels(0,1,255,-16,270)

As I've touched on in the past, levels are equal parts hard science and fine art. What really sucks on this particular source is the fact that there is "black" in the transfer, but only in the matte bars: the actual fade to black in the film just turns milky gray, and the hottest white is less offensive, but it certainly isn't the glowing torch white that a modern transfer could be. Having checked the levels "black" is roughly 10, but there's so much goddamn noise - compression artifacts, particularly - hiding in that "black" that I dropped it down slightly lower than I usually would. The rule of thumb I used was finding a fade to black sequence, and made that bastard fade to black - not charcoal gray, but the crushed singularity of a black hole. Similarly, already blown-out highlights were found and tested, and while I could, for all I know, be crushing the tiniest bit of contrast out of one or two special effects shots, I'm pretty confident that the healthier looking flesh tones and jet black hair are more important to the impact of the whole.


It's amazing how different proper levels can change everything. This is in no small part because all video is effectively grayscale with a compressed layer of color pixels riding on top of that, so if your black and white points are screwed up, your colors are too. I probably could have pushed the blacks and whites even harder without anyone noticing, but I'd run the risk of crushing blacks or blowing out whites recognizably if I did. I feel like I'm already pushing them just a bit too hard, but I'll grant that the gains of doing it are worth the potential sacrifices.

Remember how I just HAD to make everything progressive earlier? This is why:

Crop(0,46,0,-56)
AddBorders(18,0,6,0)
LanczosResize(720,480)

Mmm, fake anamorphic upscaling... While upscaling doesn't grant you any "more" resolution than simply hitting 'zoom' on a widescreen TV, the simple fact of the matter is most TVs and DVD players really suck at upscaling HD content to their native resolution - forget NTSC! - so the less work that your hardware has to do, the better off it will look. I know, titles with field blending and video edits literally can't be upscaled without further damage done to the integrity of the image, but a theatrical film which has been properly converted into progressive 24fps video can be upscaled without any harm coming to the image. So, that's exactly what I did.

But there was something I did after "crop", but before "add borders"... what was it?

RemoveGrain(2)

Yeah, that was it. Effectively a complex spatial noise reduction filter, RemoveGrain() is VERY good at what it does... of course, there's no "grain" here, only mosquito noise, but it frankly doesn't know the difference. Here's an example of the wonderful things it can do with a value of (2).


Unfortunately, the side effect is pretty obvious: the video gets softer, and kicking it up to (3) and higher is just hell on solid lines, forget anything resembling background details. Keep in mind that any actual NTSC based "noise" that was on the LD has since been smeared into blocky MPEG compression artifacts, so while I'm a firm believer that using noise reduction to get rid of film grain is stupid, we're actually just talking about removing a second layer of compression based noise, which is not the same thing. I know, it's ridiculous. I just want to point out that while I don't ever approve of using DVNR to "fix" perfectly good film based sources, I'm far more lineant on using NR to do exactly what it was always supposed to, which is get rid of video noise.

As for sharpening... what sharpening? I know, particularly when you're already smearing noise out of the source, and when the source is blurry to begin with, there's this lurking niggle in the back of your skull telling you to slap on some sort of sharpening filter to make everything clearer. I don't, for many reasons. One is that the Lanczos algorithm I'm using to upscale everything has a fairly limited "sharpen" feature built-in. The other is that these alsorithms don't know an outline from a compression artifact, and when using pre-compressed materials they tend to make them look worse in the long run. Finally, sharpening filters don't really work: there's no more detail going to magically pop out of a blurry frame, all it can do is try to boost the contrast, making edges more obvious. While Lanczos is subtle enough that it doesn't get on my nerves, using stuff like UnsharpMask, and even LimitedSharpen just drives me insane. I try to do all the work for you, but if you demand "sharp" video from a blurry LD transfer, I'm afraid you're on your own.

Yes, I COULD use one of those all in one scripts like mftoon(), but the sharpening aspect of the filter doesn't really thrill me, and the fact that it warps edges is just... freaky. It does a reasonably good job of denoising the living shit out of your source though, so if you have something along the lines of Melos - blurred AND noisy - you almost might as well... as for me, I'll save that for when I'm desperate to restore a third-gen VHS fansub, or something.

The last stage in all of this is to compress this a second time for DVD using CCE. This will likely cause some minor issues in and of itself, but it'll result in a higher quality transfer that uses less disc space overall. I can't guarantee that the above grabs will be 100% because of all the fun things that CCE does, but imagine me getting more compression flaws on top of the already shoddy source footage. Not a pretty thought, now is it? I may try tweaking the colors slightly before I give up, but not unless I'm totally convinced that it's for the best. Color Correction is just evil, for reasons I've pointed out in the past, and if I can avoid potentual further foulups by simply not doing it, it's worth considering.

Expect to see RUN MELOS! remastered at a torrent tracker and Usenet client near you, eventually. Ha, thought it was up already, didn't you? Much as I'd love to get this finished, I'm up to my eyeballs with a legitimate project that my new psuedo-employer wants to see done... like... yesterday. I'm also at least two weeks behind in restoring new Pinku, no thanks to the last 2 VHS tapes I've recorded being completely screwed up and thus worthless. I also intend to play the crap out of John Woo's Stranglehold when I'm done, so that means I need to get off my chubby keister and get everything else done, first.

I swear, when it rains it pours.

6 comments:

Anonymous said...

Hey, i have been having alot of problems wit my CPU and its been very slow and i keep getting those Online Spam pop ups where you get those fake virus scans. I also have problems downloading Programs and opening and using certin programs. It ether doesnt open or cant find certin programs. I officially got sick of it when i bought a 200$ iPod Touch and cant use it due to Itunes never being able to install and always stoping and saying theres a problem with windows installer in mid installation. Please Tell me a way to fix my computer! the first person whos answer solves my problem gets 10 points. Thanks you dudes and dudets are my only hope. [url=http://gordoarsnaui.com]santoramaa[/url]

Anonymous said...

I deleted norton virus since my account already expired. So I borrowed my brother's Mcafee and installed it to my computer. I tried getting on the Internet but when I do the page connection says cannot be connected. So I checked the signal strength and it says " very good" but it's still not connected? I share a router that is located in my sister's room which is like 10 ft away, and her computer is working just fine with the Internet. But I can't get on because it says " enter http in the address". I try to diganose and repair it say "no problems detected"... I don't understand what can be blocking me from the Internet. Oh ya d the firewalls are not up and I have windows vista. Can somebody help me please? Thanks! [url=http://gordoarsnaui.com]santoramaa[/url]

Anonymous said...

I was on the internet (Mozilla Firefox) and I was just browsing then a message came up and said something like 'Windows defender needs you to restart your computer to solve a problem' so I clicked it and then it obviously restarted. I tried to log onto my user area and it took longer than usual to load up and when it finally loaded up it had a blank background and my documents, no task-bar or shortcut. The only way I got onto the internet was by going on my downloads going on Spotify and then clicking on an advert, for the past couple of days I've been getting warnings saying that I have a harmful virus so I clicked 'Remove' and it said it had gone but every hour or so it kept coming back up. Also I have Windows Vista. Sorry it's so long :( Happy New Year :) thanks :) [url=http://gordoarsnaui.com]santoramaa[/url]

Anonymous said...

Bravo, what phrase..., a remarkable idea

Anonymous said...

Let's talk on this question.

Anonymous said...

This phrase is simply matchless :), very much it is pleasant to me)))