View Single Post
Old 30th November 2008, 11:01   #8  |  Link
jase99
*nix
 
jase99's Avatar
 
Join Date: Feb 2008
Posts: 34
Thank you Comatose and thetoof for the great suggestions. I used dfftest with a high sigma for a pass 1 denoised clip:

test9a.avs:
MPEG2Source("VTS01_PGC02_cut.d2v")
dfttest(sigma=4)
DupMC(log="test9.dup.txt")

I've been playing with filters to try and get rid of the dirt/noise in the source without losing too much detail. Black lines have been a little troublesome. I noticed dedup didn't adjust the framerate after frames have been dropped to keep the duration the same. The correct fps is required when feeding input to x264 for correct bitrate distribution so I added AssumeFPS(). This is the script I used for pass 2:

test9b.avs:
MPEG2Source("VTS01_PGC02_cut.d2v")
oldcount = framecount
oldfps = framerate
DeDup(show=false,dec=true,threshold=4, maxcopies=10, maxdrops=4, decwhich=0, log="test9.dup.txt", times="test9.times.txt")
FastLineDarkenMOD(thinning=0)
temporaldegrain(degrain=3) #dfttest(sigma=2) loses too much detail
deen("a3d",3) #deen("a3d",4) too harsh
FastLineDarkenMOD(thinning=0)
NNEDIresize_yv12()
AddBorders(4, 0, 4, 0)
aWarpSharp(depth=8,blurlevel=4,thresh=0.5,cm=1)
FastLineDarkenMOD(thinning=0)
Crop(4,0,-4,0)
DeHalo_Alpha()
Spline36Resize(last.width/2,last.height/2)
Crop(2,2,-2,-2)
averagefps = (float(framecount)/float(oldcount))*oldfps
AssumeFPS(averagefps)

Don't be surprised if anyone recognises bits of this script, I've used ideas and script snippets from various posts and done lots of testing to arrive at this.

I checked the output of dedup using show=true, it appears to work great. I limited maxdrops to only 4 because I intend to add subtitles to the encode.

Ultimately I will do a 2 pass x264 encode. The script is extremely slow so pass 2 will be to lossless huffyuv and (in parallel using avs2yuv), to the first pass of x264. The third pass (x264's 2nd pass) will simply use the pre-generated lossless avi as input.

For now though, while I'm still experimenting, I ran a 1 pass crf encode of the sample:

x264 --threads auto --thread-input --sar 8:9 --deblock -1:-1 --crf 20 --b-pyramid --direct auto --ref 16 --merange 32 --partitions all --8x8dct --b-adapt 2 --bframes 6 --subme 9 --me tesa --mixed-refs --weightb --no-fast-pskip --no-dct-decimate --trellis 2 --psy-rd 0:0 --progress --output test9.h264 test9b.avs
avis [info]: 716x476 @ 12.05 fps (312 frames)
x264 [warning]: width or height not divisible by 16 (716x476), compression will suffer.
x264 [info]: using SAR=8/9
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
x264 [info]: profile High, level 4.0
x264 [info]: slice I:6 Avg QP:17.06 size: 32618 PSNR Mean Y:46.32 U:48.27 V:48.00 Avg:46.81 Global:46.73
x264 [info]: slice P:117 Avg QP:18.87 size: 9084 PSNR Mean Y:44.44 U:47.47 V:46.54 Avg:45.11 Global:45.00
x264 [info]: slice B:189 Avg QP:22.96 size: 3516 PSNR Mean Y:43.57 U:46.87 V:45.66 Avg:44.27 Global:44.14
x264 [info]: consecutive B-frames: 4.6% 24.8% 46.1% 19.6% 4.9% 0.0% 0.0%
x264 [info]: mb I I16..4: 17.6% 38.6% 43.8%
x264 [info]: mb P I16..4: 6.1% 8.5% 3.1% P16..4: 52.2% 11.6% 8.3% 1.2% 0.6% skip: 8.4%
x264 [info]: mb B I16..4: 0.7% 0.3% 0.4% B16..8: 22.2% 2.9% 4.7% direct: 2.2% skip:66.6% L0:41.9% L1:52.2% BI: 5.8%
x264 [info]: 8x8 transform intra:43.9% inter:43.8%
x264 [info]: direct mvs spatial:98.9% temporal:1.1%
x264 [info]: ref P L0 66.8% 12.4% 5.7% 2.7% 2.4% 1.9% 1.8% 1.0% 1.0% 0.9% 0.7% 0.6% 0.6% 0.7% 0.5% 0.3%
x264 [info]: ref B L0 66.9% 13.8% 5.3% 2.8% 1.9% 1.6% 1.2% 0.7% 0.8% 0.7% 0.8% 0.9% 0.7% 1.0% 0.8%
x264 [info]: ref B L1 90.5% 9.5%
x264 [info]: SSIM Mean Y:0.9905828
x264 [info]: PSNR Mean Y:43.947 U:47.120 V:46.037 Avg:44.634 Global:44.482 kb/s:593.96
encoded 312 frames, 0.48 fps, 594.21 kb/s

The result is here: http://dump.no/files/c2b5bf8c5221/test9.mkv

Could this script be improved? I'm concerned that I might be altering the source too much or not removing (or removing too much) dirt/noise. I realise this is subjective but I would be grateful for some feedback from experienced cartoon/anime encoders.

I can post some comparison source/encode screenshots if it would help, but I think watching the source and encode in motion is better.
jase99 is offline   Reply With Quote