View Full Version : Problem with first frame
tasoszan
14th September 2009, 12:31
Hello,
I am using this scrip to convert my 4:3 DV camera video to 16:9 and also to clean it. The problem is that the first frame is black. If I remove the Neatvideo filter then the first frame is ok, but the video is not clean. Any suggestions how to fix the problem or to improve the scrip?
Clip="D:\Home Video 2\DV #01\04-12-14_14-09-23.avi"
LoadVirtualDubPlugin("D:\Soft\VirtualDub 1.9.4\VirtualDub-1.9.4\plugins\NeatVideo.vdf", "NeatVideo",0)
import("C:\Program Files\AviSynth 2.5\plugins\limitedsharpenfaster.avs")
LSF_sharp_ness=200 LSF_radi_us=3 LSF_sub=1.5 #first sharpening parameters (LimitedSharpenFaster)
USM_sharp_ness2= 20 USM_radi_us2=1 USM_thres_hold2=0 #second sharpening parameters (UnsharpMask)
saturation=1.2 blue=-0 red=-0 #color adjustment
W=720 H=576
trim_begin=2
setmemorymax(400)
AviSource(Clip)
trim(trim_begin,0)
crop(0,64,-0,-80)
ConvertToRGB32(Matrix="PC.601")
NeatVideo()
Converttoyuy2(interlaced=true)
jdl_UnfoldFieldsVertical(true)
LanczosResize(W,H)
LimitedSharpenFaster(smode=3,strength=LSF_sharp_ness,overshoot=50, ss_X=LSF_sub, SS_Y=LSF_sub, dest_x=W,dest_y=H)
unsharpmask(USM_sharp_ness2,USM_radi_us2,USM_thres_hold2)
coloryuv(off_U=blue,off_V=red).tweak(sat=saturation)
jdl_FoldFieldsVertical(true)
Thanks
Gavino
14th September 2009, 14:15
If the problem is that NeatVideo messes up the first frame, then you could just move your trim
trim(trim_begin,0)
to the end of the script, thus putting the bad frame in the bit your are discarding anyway.
Also, assuming (since it's DV) your input video is YV12, your conversion to RGB32 should have interlaced=true.
Guest
14th September 2009, 14:35
Your interlaced resizing is suboptimal. You should bob, resize, and then reinterlace, rather than resizing separated fields.
Gavino
14th September 2009, 15:27
Your interlaced resizing is suboptimal.
I noticed that too. But if the input is a PAL DV, it's already 720x576, so the resize does nothing. ;)
Guest
14th September 2009, 15:48
Still, it's worth pointing out to the OP that it is a suboptimal method.
Gavino
14th September 2009, 16:08
Yes, you're right, of course.
Another thing I wondered was whether the NeatVideo filter (which I know nothing about) works on an interlaced source. Perhaps it should be applied after the field separation.
tasoszan
14th October 2009, 10:49
Thank you for your answers. I finally decided to use the scrip below. The problem I have now is that is very slow (0,05 speed). Also if I encode more than 1 video after 2-3 video clips the encoder (cce) crash. Can you help me?
Clip="D:\Home Video 2\DV #01\04-12-24_12-13-36.avi"
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DVTimeStampEx.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveDirt.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\removegrain.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Repair.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\AGC.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MVTools2.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MaskTools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\warpsharp.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\LimitedSupport_09Jan06B.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\autolevels.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MVTools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MT.dll")
import("C:\Program Files\AviSynth 2.5\plugins\limitedsharpenfaster.avs")
import("C:\Program Files\AviSynth 2.5\plugins\RemoveDirt.avs")
PRE_sharp_ness= 30 PRE_radi_us= 4 #presharpening (UnsharpMask) before any denoising
LSF_sharp_ness=180 LSF_radi_us=3 LSF_sub=1.5 #first sharpening parameters (LimitedSharpenFaster) sub=subsampling
USM_sharp_ness2= 20 USM_radi_us2=1 USM_thres_hold2=0 #second sharpening parameters (UnsharpMask)
blue= -0 red=-0 #manual color adjustment, when returning result3. Values can be positive or negative
saturation=1.3 #for all outputs
denoising_strenght=800 #denoising level of first denoiser: MVDegrainMulti()
denoising_frames= 3 #number of frames for averaging (forwards and backwards) 3 is a good start value
block_size= 16 #block size of MVDegrainMulti()
block_over= 8 #block overlapping of MVDegrainMulti()
temp_radius=10 temp_luma=4 temp_chroma=2 #second denoiser: TemporalSoften
W=720 H=576
trim_begin=5
setmemorymax(400)
AviSource(Clip)
trim(trim_begin,0)
ConvertToRGB32(Matrix="PC.601",interlaced=true)
LeakKernelBob(order=0, threshold=7)
Spline36Resize(720,576,0,64,-0,-80)
Converttoyv12()
mem=last
pref= mem.blur(1.0).blur(1.0).removedirt().tweak(sat=2.5)
noise_baseclip= mem.unsharpmask(PRE_sharp_ness,PRE_radi_us,0).coloryuv(off_U=blue,off_V=red).tweak(sat=saturation)
vectors= pref.MVAnalyseMulti(refframes=denoising_frames, pel=2, blksize=block_size,overlap=block_over, idx=1)
noise_baseclip.MVDegrainMulti(vectors, thSAD=denoising_strenght, SadMode=1, idx=1)
TemporalSoften(temp_radius,temp_luma,temp_chroma,15,2)
DeGrainMedian(limitY=2,limitUV=3,mode=1)
DeGrainMedian(limitY=2,limitUV=3,mode=1)
LimitedSharpenFaster(smode=3,strength=LSF_sharp_ness,overshoot=50, ss_X=LSF_sub, SS_Y=LSF_sub, dest_x=W,dest_y=H)
unsharpmask(USM_sharp_ness2,USM_radi_us2,USM_thres_hold2)
DoubleWeave().SelectEvery(4,1) # for TFF 16:9 encoding
Converttoyuy2(interlaced=true)
DVAutoTimeStampEx(Clip)
Didée
14th October 2009, 11:52
a) a technical mistake:
vectors= pref.MVAnalyseMulti( [...] , idx=1)
noise_baseclip.MVDegrainMulti( [...] , idx=1)
If the input clips for MVAnalyse and MVDegrain are different, then you've to use different idx values, too.
Like e.g.: MVAnalyseMulti( ... , idx=1) // MVDegrain( ... , idx=2)
When both idx' are the same, then you end up with MVDegrain averaging the sledgehammer-filtered "pref" clip into the result. And that's probably not what you want.
b) temporal complexity --> "speed"
your denoising chain is MVDegrainMulti ## +-3 frames
TemporalSoften ## +-7 frames (you spec'ed 10 frames, but 7 is the maximum that TemporalSoften will perform)
DegrainMedian ## +-1 frame
DegrainMedian ## +-1 frame
Temporal filters acquire one or several previous + upfollowing frames to process the current frame.
If a temporal filter is followed by another temporal filter, then for each frame that the 2nd filter requests, the full temporal work of the predecessing filter must be done. Temporal complexity is growing quickly.
It gets worse when you chain more and more temporal filters. Temporal complexity is growing very quickly, short of saying "exploding".
You actually have a temporal complexity of (3) * (3) * (15) * (7), which is way, way, waaay too much.
(Know that story? 1st field -> 1 ricegrain , 2nd field -> 2 ricegrains, 3rd field -> 4 ricegrains ... 8 ... 16 ... 32 ... and finally, not enough rice on the whole darn planet to populate the 64th field ...)
Throw out all that TemporalSoften and DeGrainMedian, and see how much faster the script will run.
After that, consider very carefully how much filtering you really need *after* the MVDegrainMulti call.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.