Saturday, February 21, 2004

Capture Resolutions


My recommendations for capture resolutions, at least, my current recommendations based on some trial and error and various readings over the last few weeks. This is assuming that you're going to be putting the resulting video out to DVD at either half-D1 or full D1 resolution. ("Half-D1" is 352x480 30fps NTSC or 352x576 25fps PAL, "Full-D1" is 720x480 30fps NTSC or 720x576 25fps PAL.)

For relatively clean audio off of VHS, that you're not going to have to heavily process (e.g. just applying a Temporal Smoother filter), try capturing at 352x480 (half D1). It will cut your processing time in half and you can get away with lower bitrates on the DVD (3000-6000kbps) which gives you a lot more capacity per DVD.

OTOH, if you're going to have to heavily process (using the Smart Smoother HQ filter) the video, you should probably go ahead and capture VHS at 720x480 or 704x480 (full D1) in order to give the filters more data to work with. Once you've applied your filters, you may wish to make your last processing step a down-conversion to 352x480 (half D1) to speed up MPEG2 encoding and allow for more capacity on the DVD.

Capturing digital video (e.g. a MiniDV camcorder), of course, should be done at 720x480.

posted by Wuphon's Reach at 8:26 PM

Smart Smoother HQ Samples


Here is an example of using Klaus Post's Smart Smoother High Quality filter. The source material is a VHS tape that I own that's a few years old, captured with a S-VHS VCR and a Hauppauge WinTV-dbx PCI card. Clicking on each image will show you the original 720x480 capture frame.

Raw capture:
- Note the tape noise, results in a JPEG image that is 40% larger then the "radius 13 threshold 25" image, which means that if I try to take this straight to MPEG2, the encoder is going to have to use 40% more bitrate (at a guess) to get good quality.
Dirty Pair - raw VHS capture

HiQ: radius 3 threshold 50 average
- Not really much better then the raw sample, 3 is too small of a radius to make much of an impact.
Dirty Pair - Smart Smoother High Quality v2.11 Klaus Post - radius 3 threshold 50 average

HiQ: radius 13 threshold 50 average
- Note the loss of detail, such as the bead of sweat on her cheek below the eye. A good bit of the loss of detail is due to the threshold of 50 though (see r13/t25 below).
Dirty Pair - Smart Smoother High Quality v2.11 Klaus Post - radius 13 threshold 50 average

HiQ: radius 13 threshold 100 average
- This shows what happens as you raise the threshold value.
Dirty Pair - Smart Smoother High Quality v2.11 Klaus Post - radius 13 threshold 100 average

HiQ: radius 13 threshold 200 average
- Worst-case sample of threshold blur.
Dirty Pair - Smart Smoother High Quality v2.11 Klaus Post - radius 13 threshold 200 average

HiQ: radius 9 threshold 25 average
- This is very close. Note the detail is still there when compared to the originial image, but almost all of the tape noise is gone without losing detail.
Dirty Pair - Smart Smoother High Quality v2.11 Klaus Post - radius 9 threshold 25 average

HiQ: radius 13 threshold 25 average
- Not much difference between radius 9 and radius 13. But radius 13 takes longer to process.
Dirty Pair - Smart Smoother High Quality v2.11 Klaus Post - radius 13 threshold 25 average

The HiQ filter does a very good job on cartoons like that shown. My personal preference due to time reasons is "radius 7 or 9 threshold 10 or 15 or 20" which gives me around 5-6fps on my Pentium 4 1.6GHz laptop (r9/t15). Threshold 25 seems a little fuzzy when compared to threshold 15 (sorry, no sample), but that may depend on the quality of your source.

I'm not sure how well these settings work when CG is mixed in with the traditional cel animation. I'll try to find a sample (I have a copy of the King and I, animated version, on tape which has some mixed CG/cel shots). Update: When playing with the filters "radius 7 threshold 20 amount 254 maintain 10 weighted with difference" seems to be a very good setting, but it's very very very slow (4-6fps on my AthlonXP 2600+ for a 720x480 30fps clip). So instead, I'm going to go with "radius 7 threshold 15 amount X maintain 5 average with difference" which is a good bit faster and seems to be a decent middle ground.

For the curious who wonder how I extracted these images. VirtualDub allows you to export individual frames to individual TGA or BMP files. Load up your AVI in VDub, select a sequence of half a dozen frames, then use the "File, ..." to write your TGA/BMP files. Change up your filter settings and repeat the "File, ..." command to export a new set. You'll also need to change your video compresion method to "None (RGB)" prior to export and each 720x480 TGA file will be around 900Kb (which eats up disk space pretty quick if you try exporting hundreds of frames).

posted by Wuphon's Reach at 8:02 PM

Thursday, February 19, 2004

VHS Capture Links


Digging around to see if anyone else has examples of processing VHS captures (with an eye towards anime/cartoon source material).

Making Anime Music Videos

FanSub guide

Video Processing Anime

posted by Wuphon's Reach at 8:54 PM

DVD Encoding Bitrates


Assuming use of AC3 audio (256kbps) and 4.25GB per disc, encoding with video rates of:

8000kbps 74min
7500kbps 78min
7000kbps 84min
6500kbps 90min
6000kbps 97min
5500kbps 105min
5000kbps 115min
4500kbps 128min (2h 8m)
4000kbps 142min (2h 22m)
3500kbps 162min (2h 42m)
3000kbps 187min (3h 7m)

At bit-rates below 5000-6000, you may need to switch to a lower resolution such as 352x480 (352x576) instead of 720x480 (720x576). For VHS source material this lower resolution is usually plenty anyway.

6000kbps with AC3 (256kbps) is what I use to put (2) hour long TV episodes on a single disc. Once commercials have been stripped, US episodes are only 48 minutes each (96 min total) and the average encoding is usually a touch less then 6000 allowing me to even put a few minutes worth of commercials on each disc. (Yes... I sometimes capture the funny/unique commercials and put them on the disc as extras.)

Update: I've switched to 4800kbps VBR video with 256kbps AC3 audio in order to fit (3) episodes on each 4.35GB DVD-R disc. Or, if you want to pack (4) on a disc, you can do 3100kbps VBR video with 256kbps AC3 audio. However, your source material needs to be extremely clean (or switch to half-D1 resolution).

posted by Wuphon's Reach at 2:39 AM

Wednesday, February 18, 2004

Fixing Audio Drift


While most things seem to be working well at the moment, I do seem to have a slight audio drift on longer captured segments (prior post). According to the log file generated by VirtualVCR (my settings):

Capture file is 50m38s, 91025 frames, zero dropped
(according to VDub, Video is 50m 37.20s and audio is 50m 37.11s)
Video rate is 29.969246
Audio rate is 44103.361847
AV Diff is -0.000101

Well, besides the fact that I'm capturing at 44.1kHz instead of DVD standard 48kHz (whoops!), the 44103Hz and AVDiff of -0.000100 is pretty standard for every capture I've done recently. So it's predictable. Video rate is always 29.969 which is also close to spec.

Now, the easy fix is to try stretching the audio in Cool Edit 2000 from 3037.11s to 3037.20s. End-result would be to push the audio later in the action (e.g. if a gun flash appears after the sound for the gun flash, now it should be synced up).

On this particular clip, audio trails the video bit a tiny bit (better at the start of the 50 minute clip, worse towards the end). So stretching is actually the wrong thing (even though the audio is shorter then the video). I need to reduce the audio rate by 0.207s (3037.119 * 44100/44103 = 3036.912) if my calculation is correct.

An alternative calculation is to also take into account the video rate not being exactly 29.970. So 3037.119 * 44100/44103 * 29.970/29.969246 = 3036.989 or -0.130s. That might actually be pretty darn close (I'm betting that the neg 0.207s correction is going to be too much).

Oh, and when you go to interleave the video back in using VirtualDub... make sure that "Audio, Full Processing" is turned on to make sure that it uses the WAV source instead of the source audio from the AVI. (At least, I think this bit is required.)

Another (possible) tip: In order to test, you should create a new AVI with the new audio track mux'd back in. In order to save space, try using the fast-n-dirty "2:1 reduction" filter (not the high quality one). That should only take 1/4 of the space of the original AVI and might help if your test is disk-constrained rather then CPU constrained. On my Athlon 2600+ with 5400rpm 160Gb ATA/100 drive, it's neck-and-neck whether it's better to do it as straight-copy or to reduce it 2:1.

Even easier method using VirtualDub to check sync:

1) export your WAV, change the length, save back as WAV
2) open up your AVI in VirtualDub
3) change Audio to "Full Processing", select "WAV..." as the source, pick your WAV file
4) queue up to a good checking spot, click the "play input" button

That skips the need to re-mux the audio in order to do a quick check. You'll probably still want to do a close examination once you re-mux what you think is your final guess.

posted by Wuphon's Reach at 2:08 PM

VDub Filtering


Well, for relatively clean sources, where I only want to get rid of a touch of noise, it looks like VirtualDub's "Temporal Smoother" at strength 3 to 5 followed by the "Smoother" filter at strength 5 to 10 works very well. Throughput on my AthlonXP 2600+ is around 18-20fps. The temporal filter seems to do a good job of steadying up an image. In certain cases, you may want to really dial-back the smoother filter (3-5 or even disable it, just using the temporal smoother).

It also does wonders for the resulting bitrate. Encoded with TMPGEnc VBR 2-pass, with a target of 6000kbps, the resulting output is more like 4500kbps which allows me to pack a lot more on a disk (a touch over 2 hours). Normally, when I encode at 6000kbps in TMPGEnc, I only get 92 minutes per tape (enough to fit 2 episodes of Law and Order for instance if I cut commercials). However, unlike broadcast TV, the signal that I'm playing with at the moment has large black borders on all 4 sides that I've filled to solid black. Only the center 80% has a signal. That probably accounts for a good portion of the 33% change in bitrate.

Klaus Post's Smart Smoother HQ also works well. When I encoded some anime/cartoons earlier, I got better results using the Smart Smoother at "5 / 100 / 254/ 0 / weighted / withdifference" then I did with the temporal filter + smoother. Downside was the long cleanup time in VirtualDub (8fps or so). I may play around with trying to use just "average pixels" instead of weighted.

Update: Using the HiQ filter with just average ("with difference" is off), radius 7, threshold of 10 I get 15-18fps on my AthlonXP 2600+ (352x480 30fps source). That's competitive with my original temporal+smooth method. For cell drawn anime 7/10/average/nodiff seems to give very good results. Increasing the radius to 9 or 11 makes things a bit flatter but would also slow it down.

Update #2: I'm finding that I dislike what the "Smoother" filter does to the output at strength 10-20. The last VHS capture that I did was 352x480 with simply using "Temporal Smoother" at strength 5. I still may try the smoother at some lower single-digit values, or combine it with a sharpen filter.

posted by Wuphon's Reach at 9:05 AM

Monday, February 16, 2004

VHS2DVD Process Streamlining


Slowly streamlining the process. Currently, I'm using a 4-head VHS VCR to capture an analog OTA signal of Law and Order and ER every week (6 hrs/week) with the goal of putting 2 episodes on a single DVD to play in my set-top player. (The Sony, not the Toshiba SD-2109 which won't read recordable media...) Playback for capture is done on a S-VHS VCR (yes, I should probably use a S-VHS VCR upstairs to do the intial recording... but hey, what I'm taping is more about the story then the video quality, audio is clean which is worth more then a slight amount of video noise). I have a 4x6 card stuck to the front of the VCR upstairs to remind me what is taping when so that I change tapes on the proper days.

Playback and capture is easy enough, I don't listen/watch the episode as I'm capturing except for spot-checking to make sure audio sounds clean and audio levels are proper. I start a new capture AVI at every commercial break, and even sometimes grab commercials into short 40-second AVIs. Law and Order shows typically have a 2-3 minute intro, 4 main segments of 9-15 minutes each, then the credits segment which is a minute or two. Since I'm going to DVD, it's just as easy to leave them as seperate files and just combine them into a single track when I author the DVD. In fact, that gives me the option when I encode to do the credits segment at a low bit-rate to save space (usually encode those at 4000 or 5000 kbps instead of the 6000 kbps that I use for the rest of the show). I usually read a book, catch up on SlashDot or other e-mail while I'm doing the capturing, keeping a quick-eye on the progress to make sure no frames get dropped and to see when commercial breaks show up.

Cropping out the commercials (or extra lead-in / lead-out) is done in VirtualDub using the Direct Processing Mode. I've found that this is a good bit faster and less frustrating then trying to set the edit points in TMPGEnc (VDub is much more responsive when scrolling through the video). Since I'm not doing any filtering or re-compression of the AVI, speeds are on the order of 60-90fps (2x-3x normal speed). A faster hard drive would speed up this process. Again, pretty much a hands-off process, it takes maybe a minute per segment to find the scene-breaks, mark my start/end points and start the conversion.

Right now, I'm not doing any filtering / clean-up of the video signal. And unless I get a super-fast encoding machine, I definitely won't be using TMPGEnc's noise reduction (which seems to be extremely slow). As it is, my P4 1.6GHz laptop takes about 6 hours to encode 1 hour of material. With noise-reduction, that figure jumped to 12-18 hours per hour. Since I'm only able to encode using the laptop atm (the capture box isn't stable again...) trying to do TMPGEnc noise-reduction could quickly put me behind if I have more then 8 or 10 hours of source material per week to encode. These captured episodes aren't worth that amount of time to clean them up.

Once I've converted to M2V+WAV, I open up TMPGEnc DVD Author (TDA), create two tracks (one for each episode), add and rearrange the segments in each track, edit the menu text and then start the processing (which creates the VIDEO_TS folder contents). Authoring time takes maybe 5-10 minutes, and processing time takes 30 minutes (pulling the M2V+WAV files across the LAN).

Open up the VIDEO_TS folder, figure out how much of the disc space is in use (usually 3.7-4.0 Gb), and then I create PAR2 recovery data for all of the files in the folder. Either a 16Mb or 8Mb block size works well, with enough recovery blocks to fill the DVD up to around 4.3Gb. Some folks move their PAR2 files to another folder on the DVD, but I've just been leaving the PAR2 files in the VIDEO_TS folder. Makes it easier to verify the disc later and my Sony DVD player doesn't seem to mind that those files are in the VIDEO_TS folder.

Fire up ImgTools Classic to create an ISO of the proper UDF type, which gets written to my machine with the DVD recorder on it (different box then the one that I author the DVD on). That takes another 30 minutes (maybe 2 minutes to setup, then runs on its own). But while that runs I can be authoring another DVD, or capturing more video or doing cutting. I tried just putting the AUDIO_TS and VIDEO_TS folders on a data DVD using Roxio 6, but my copy doesn't create UDF DVDs that the Sony DVD player will recognize. (I suspect, according to what I've read elsewhere, that Roxio 6 is creating UDF 1.05 DVDs, but the standard requires UDF 1.02.) Not a big deal, using ImgTools is about as easy as copying the files over to the other machine directly. Burning the ISO at 2x in Roxio 6 takes around 30 minutes.

All told, I'm not spending an inordinate amount of time actively managing the process (there's a lot of "bulk processing" time involved), and I usually have the DVD ready the day after I do the capture. I'm still exploring various filters in VirtualDub to see if I can clean up the video signal in a reasonable amount of time. e.g. I'm currently trying out the vxVHS filter, but on my AthlonXP 2600+ I'm only seeing 3.5fps throughput which is way too long if I want to run 6-8 hrs/week of video through it. I may go back to using the "Smoother" filter at a setting of 10 or 20. I had stopped using it because it made things look muddy on the TV upstairs (looks okay on the computer), but that might have been a mis-configured TV (contrast was set to maximum). "Smoother" was a fairly quick filter (15-18fps) and I'd have the option to do my border fills again to get rid of tracking noise at the bottom of the frame.

posted by Wuphon's Reach at 12:56 AM

Powered by Blogger Who's linked to me?