Log in

View Full Version : Retaining detail in VHS capture to x264


video_magic
3rd August 2011, 15:25
I've read extensively through http://mewiki.project357.com/wiki/X264_Settings , and some older threads on Doom9, and a few other places.

I have run many test encodes on 1 minute from my clip trying presets and my own combinations of options & their different values (Trellis or deadzone-intra deadzone-inter, Deblock, AQ, psy-rd, B-frames, Subme etc etc)

I am using x264 r2044 , my current problem are a series of clips I taped from the TV in 1993-1999. I don't want to keep my Physical Video Tapes , just some selected footage as a collection of files. I am happy with my captures, and I just want to have my x264 clip looking as near as possible to the tape without having a huge file - I was hoping for a bitrate of around 3000 or under.

I am not that fussy about exact Aspect Ratio, and capture at 704x576 , 25FPS. All I do in Avisynth is crop (any blank border area), AssumeFPS Pal_Video , and converttoyv12 . My current problem clip for example as fed to x264 is 700x436

When I have used x264 in the past on cleaner footage I was okay, but now with these clips I'm up to 3800 in yet another x264 test encode and can't seem to retain the accuracy on darker 'mottled' backgrounds with faint horizontal combing lines.

My clips are captured with UT Video lossless and I'm only on Pay As You Go Mobile internet so can't upload the clips. I can tell you they are not excessively noisy and wouldn't have thought there was any obvious reason why they are being this troublesome.

Some details do look good and very accurate, but larger areas of dark or light shading have clear differences in the patterns. I suppose I could run my next test at 5000 but would like to take a break and ask advice:

What settings and values should I try? - I want to retain detail so it looks as near as like the original (including occasional bright flecks like is normal with tapes), given what I've put above. Smoothing, noise-reduction & the like are not what I want to do.

Thanks in advance for being patient. Example comand lines to try from experts would be welcome.

nm
3rd August 2011, 16:06
When I have used x264 in the past on cleaner footage I was okay, but now with these clips I'm up to 3800 in yet another x264 test encode and can't seem to retain the accuracy on darker 'mottled' backgrounds with faint horizontal combing lines.

"Horizontal combing lines" makes it sound like you have some deinterlacing to do. Or are you already encoding as interlaced? A screenshot of a troublesome frame might help if you can't upload even a short clip.

What settings and values should I try? - I want to retain detail so it looks as near as like the original (including occasional bright flecks like is normal with tapes), given what I've put above. Smoothing, noise-reduction & the like are not what I want to do.

Pick a preset that gives you a suitable balance of speed vs. compression. Slowest presets only give 10 to 20 % higher compression than the default settings (--preset medium). Use --tune film or perhaps --tune grain in addition.

For your purposes, CRF rate control is more appropriate than bitrate-based 2-pass encoding.

Post your current x264 command line.

Mini-Me
5th August 2011, 21:05
I'm no expert here, but I agree with nm that CRF is probably better for what you're trying to do. Since these are VHS captures and you didn't mention deinterlacing, I assume you want to keep the interlacing. In that case, you'll want to encode as interlaced. You can signal that to x264 with the -tff and -bff switches (whichever parity your captures are). Try the following x264 options as a starting point, and switch -bff for -tff if appropriate:
x264 --preset medium --crf 17 --tune film --tff -o "output.mkv" "input.avs"

As nm said, you can try substituting --tune film with --tune grain.

CRF doesn't guarantee a particular bitrate, but I imagine that CRF 17 should probably give you a bitrate in the right ballpark. From what I've read, most people tend to use CRF values from 16 to 20 or so for high-quality [if not transparent] SD encodes. While these are considered relatively high bitrates for SD, they're still low enough that using somewhat slower presets should be worth it. If you can stand the speed hit, try moving down to the slow or slower preset.

If you're already using the slowest preset you can stand, and you've tried both --tune film and --tune grain, then your best hope is simply biting the bullet and dropping the CRF value. Bitrates around 3000 kb/s should give pretty good results, but they won't always be transparent (even if you don't have an obvious reference at hand for comparison). It all depends on your expectations. You mentioned that your source isn't exceptionally noisy, and you don't want to denoise. I would feel the same way, but you should know that these bitrates aren't high enough to flawlessly encode everything. Some minor aspects of the image are likely to be lost, and the noisier the input, the more likely it is that keeping some of the noise will come at the expense of actual detail.

Note that the presets are excellently constructed for overall balance and wide applicability to many sources. I can't even count how many times I've seen new users post long command lines asking for help or very fine-grained advice on options, only to end up seeing tons of posts follow saying, "Use the presets!" Experts might be able to tune specific parameters on a source-specific basis to get slight improvements, but you have to really know both x264 and your source inside-and-out to do this, or you're more likely to do more harm than good (and you might not even realize the problem until further down the line). If you want to become an expert, you'll have to go through a lot of trial and error, but the time to do that is probably not when you're trying to create a final encode of something important to you. ;)

video_magic
9th August 2011, 12:26
Thanks nm & Mini-me.

I've taken a snapshot, but I had to change it to a jpeg to upload it here because of the maximum filesize limit, I did it at quality 95 'though. It shows the mottling on the dark backgrounds - I suppose that is naturally because it is from the analogue tape source and captured over composite cable, but I don't have 'Snow' type noise in my captures hardly ever that you sometimes get from VHS.

I've spent some days. The trouble with the presets was they either gave a too big file, or look either too 'clean' or 'processed' if the file is smaller.

I've now got encodes that I am quite happy with at a reasonable filesize & without taking too long to do. I would be happy to do the rest of the tape captures now & batch encode them.

I found that together with lowering the bitrate, the most significant settings for me was upping the B-Frames, increasing Merange & Subme, using -3 deblock, disabling Trellis and going back to using deadzone with both on 8 . A few other tweaks, but on my E6700 Core 2 Duo I get typically 37 FPS pass1 & 6 FPS on pass2. This is 2375 bitrate for 702x572, and I recalculate for the same bitrate at my other cropped resolution inputs.

Here's my final settings:

x2642044.exe --output NUL --keyint 450 --min-keyint 15 --scenecut 25 --bframes 7 --b-adapt 2 --deblock -3:-3 --fake-interlaced --bitrate 2375 --rc-lookahead 45 --aq-mode 2 --aq-strength 0.8 --pass 1 --stats "d:\LPS\prbeauex.LOG" --direct auto --trellis 0 --deadzone-intra 8 --deadzone-inter 8 --threads 2 --thread-input c:\1tmp\PRBEAUTI1.avs

PING 1.1.1.1 -n 1 -w 20000 >NUL

x2642044.exe --output "d:\LPS\x264out\prinbeex6.264" --keyint 450 --min-keyint 15 --scenecut 25 --bframes 7 --ref 6 --deblock -3:-3 --fake-interlaced --bitrate 2375 --rc-lookahead 45 --aq-mode 2 --aq-strength 0.8 --pass 2 --stats "d:\LPS\prbeauex.LOG" --direct auto --me umh --merange 24 --subme 9 --trellis 0 --deadzone-intra 8 --deadzone-inter 8 --threads 2 --thread-input c:\1tmp\PRBEAUTI1.avs

nm
9th August 2011, 12:59
I've taken a snapshot, but I had to change it to a jpeg to upload it here because of the maximum filesize limit

Upload the image somewhere else. Attachments may take a long time to get approved and we can't see the content before that happens.

I've spent some days. The trouble with the presets was they either gave a too big file, or look either too 'clean' or 'processed' if the file is smaller.

--tune grain should give pretty much the same result as your settings.

I still think CRF would be much better idea than blindly using the same bitrate for all videos.

Here's my final settings:

x2642044.exe --output NUL --keyint 450 --min-keyint 15 --scenecut 25 --bframes 7 --b-adapt 2 --deblock -3:-3 --fake-interlaced --bitrate 2375 --rc-lookahead 45 --aq-mode 2 --aq-strength 0.8 --pass 1 --stats "d:\LPS\prbeauex.LOG" --direct auto --trellis 0 --deadzone-intra 8 --deadzone-inter 8 --threads 2 --thread-input c:\1tmp\PRBEAUTI1.avs

PING 1.1.1.1 -n 1 -w 20000 >NUL

x2642044.exe --output "d:\LPS\x264out\prinbeex6.264" --keyint 450 --min-keyint 15 --scenecut 25 --bframes 7 --ref 6 --deblock -3:-3 --fake-interlaced --bitrate 2375 --rc-lookahead 45 --aq-mode 2 --aq-strength 0.8 --pass 2 --stats "d:\LPS\prbeauex.LOG" --direct auto --me umh --merange 24 --subme 9 --trellis 0 --deadzone-intra 8 --deadzone-inter 8 --threads 2 --thread-input c:\1tmp\PRBEAUTI1.avs

Use the same settings for both passes. x264 will lower the first pass settings automatically so that it runs faster.

Are your videos supposed to be progressive (2:2 pulldown) so that the leftover combing is only an artifact from broadcast and recording? It's difficult to give good filtering advice without seeing a small clip. Most likely you do need to either deinterlace or encode as interlaced.

Why do you use --fake-interlaced?