Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th June 2010, 06:14   #1321  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
Quote:
Originally Posted by tormento View Post
Do you think that the thSAD number is too high or low? I read in the documentation that a too low number could cause "staggered denoising" but what is a too low number for that parameter? As I want remove grain only, do you think I should use a different thSADC for chroma?
I love quoting myself... Could you please stop masturbating and giving me some help from your heavenly highness?
__________________
@turment on Telegram

Last edited by tormento; 15th June 2010 at 06:32.
tormento is offline   Reply With Quote
Old 15th June 2010, 08:08   #1322  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
"Do you think that the thSAD number is too high or low?"
dunno.

"I read in the documentation that a too low number could cause "staggered denoising" but what is a too low number for that parameter?"
depends.

"As I want remove grain only, do you think I should use a different thSADC for chroma?"
dunno.

The reason thSAD is a parameter and not hardcoded, is because sometimes you have to change it to get good results. Should you use a different thSADc for chroma? Is there chroma noise? If there is do you want to remove it? Is it the same strength as the luma noise? Denoising is a preference thing anyway.Try different thSAD(c) values and use the one you like the most.
*.mp4 guy is offline   Reply With Quote
Old 15th June 2010, 08:24   #1323  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
While we have some more experts in the thread, two simple questions (which probably don't warrant a simple answer :P) : is there really any use using UMH for search method and under what circumstances could MRecalculate prove to be useful?

The reason why I ask these questions is that I have a lot of handheld shot (shaky, that is), grainy 8mm film transfer stuff to process and I want to get the stabilization process work done as well as possible. In addition to this, one long reel is filmed at an enduro race so there's a lot of movement going on pretty much all the time. From what I've been testing things, in these cases using MDepan for creating the log file to feed to Deshaker's second pass is the way to go.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 16th June 2010, 03:43   #1324  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
just for the record, I know absolutely nothing about deshaking video.

That said, I think the most important things to look at will be pre-denoising and adequate motion vector length (I'm not sure what resolution your source footage is, but iirc mvtools could have a restrictive maximum mv length if its really bad, or HD, or both)
*.mp4 guy is offline   Reply With Quote
Old 16th June 2010, 13:05   #1325  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
If I've understood correctly (regarding Deshaker at least), the basic idea is for the motion detection engine to lock onto the background or some other static object. Deshaker's 1st pass can be set to ignore motion of blocks falling under certain conditions, for example those blocks whose movement happens in the "wrong" direction. The great thing about MAnalyse is that the settings can be tweaked a lot and the result can be immediately seen with MShow. I was just wondering whether there are options to helping MAnalyse towards the preferred behaviour.

The problem with MDepan is that I don't know which motion vectors are ignored when the stabilization data (hor and ver pan, rotation and zoom per frame) is created (either for DepanEstimate or to a Deshaker-style log file). Fizick, would it be possible to create an MShow-like view of discarded and accepted blocks? Currently tweaking the "wrong" and "range" parameters is practically impossible. Also, what does "range" actually do? Is the parameter coupled with "wrong"?
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 17th June 2010, 07:45   #1326  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Terneuzen, Zeeland, the Netherlands, Europe, Earth, Milky Way,Universe
Posts: 689
Quote:
Originally Posted by Boulder View Post
If I've understood correctly (regarding Deshaker at least), the basic idea is for the motion detection engine to lock onto the background or some other static object.
I have made a depan version of this, you can select any region for motion detection:

Code:
# film stabilizing script by videoFred.
# Version 06/2010
#====================================================================================


# specify the source clip here with full path name

film="C:\Documents and Settings\Eigenaar\Mijn documenten\films\Dirk\videofred_002.avi"




#GENERAL PARAMETERS
#--------------------------------------------------------------------------------------------
result="result2" # specify the wanted output here 
                 # result1= stabilized/cropped/resized clip
                 # result2= comparison original vs not cropped stabilized clip
                 

trim_begin=0   # trim frames at the beginning
               # useful to skip fast to a certain scene  




#SIZE, CROP AND BORDERS PARAMETERS
#--------------------------------------------------------------------------------------------
CLeft=20  CTop=20  CRight=20  CBottom=20  #crop values after Depan and before final resizing 

W=720  H=576 #final size after cropping 



#STABILIZING PARAMETERS
#--------------------------------------------------------------------------------------------
maxstabH=20 
maxstabV=20 #maximum values for the stabilizer (in pixels) 20 is a good start value

est_left=40   est_top=40  est_right=40  est_bottom=40 # crop values for special Estimate clip
                                                      # the stabilizer will use this region only

est_cont=1.0  # contrast value for special Estimate clip
              # change this if the stabilizer wont work



# END VARIABLES, BEGIN SCRIPT
#=============================================================================================


# NEEDED PLUGINS
#------------------------------------------
Loadplugin("Depan.dll")
LoadPlugin("DepanEstimate.dll")
LoadPlugin("MT_Masktools.dll")




source1= Avisource(film).trim(trim_begin,0).converttoYV12()




#STABILIZING
#..............................................................................................
stab_reference= source1.crop(est_left,est_top,-est_right,-est_bottom).tweak(cont=est_cont)\
.MT_binarize(threshold=80).greyscale().invert()

mdata=DePanEstimate(stab_reference,trust=1.0,dxmax=maxstabH,dymax=maxstabV)
stab=DePanStabilize(source1,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15)
stab2= stab.crop(CLeft,CTop,-CRight,-CBottom).Lanczos4Resize(W,H)
stab3=DePanStabilize(source1,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,info=true)

WS= width(stab)
HS= height(stab)
stab4= stab3.addborders(10,10,10,10,$B1B1B1).Lanczos4Resize(WS,HS)

result1=stab2




#SPECIAL SERVICE CLIP FOR COMPARISON
#................................................................................................
service_clip= overlay(source1,stab_reference,x=est_left,y=est_top)\
.addborders(2,2,2,2,$FFFFFF).Lanczos4Resize(WS,HS)




#SPECIAL COMPARISON CLIP FOR TESTING THE STABILIZER
#.......................................................................................................
result2= stackhorizontal(subtitle(service_clip,"baseclip for stabilizer -only the B/W clip is used",\
size=32,align=2),subtitle(stab4,"test stabilizer: dx=horizontal, dy=vertical",size=32,align=5))


Eval(result)
With this script, it is possible to 'lock' DepanEstimate() to a certain region of the clip.
Only this information will be used for DepanStabilize().

Result2 will show you all the needed information.



Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 17th June 2010, 10:54   #1327  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
The problem is that the region changes in each scene, sometimes during the scene With 4.5hrs of material to process, I'm trying to automate things as much as possible (even to the extent that I've butchered your restoring script a bit and turned it into a bloated function )
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 17th June 2010, 11:29   #1328  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Terneuzen, Zeeland, the Netherlands, Europe, Earth, Milky Way,Universe
Posts: 689
Quote:
Originally Posted by Boulder View Post
The problem is that the region changes in each scene, sometimes during the scene
Ah! Yes, I know about this problem. Depan fails here...


Quote:
With 4.5hrs of material to process, I'm trying to automate things as much as possible (even to the extent that I've butchered your restoring script a bit and turned it into a bloated function )
Cool! Show me!

Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 17th June 2010, 11:49   #1329  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Quote:
Originally Posted by videoFred View Post
Cool! Show me!
Sure, after I've cleaned it up a little Even after that I know I'll be embarrassed to post it, but let's see if someone could enhance it further. For some reason I've never been able to get the Eval blocks work correctly with boolean operators.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 17th June 2010, 11:58   #1330  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Terneuzen, Zeeland, the Netherlands, Europe, Earth, Milky Way,Universe
Posts: 689
Quote:
Originally Posted by Boulder View Post
Sure, after I've cleaned it up a little
Very good. When you are ready, please post it in the 'Power of Avisynth' thread.

Thank you in advance Boulder!

Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 17th June 2010, 12:08   #1331  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Boulder View Post
For some reason I've never been able to get the Eval blocks work correctly with boolean operators.
You might find it easier to use GScript instead.
Gavino is offline   Reply With Quote
Old 17th June 2010, 13:50   #1332  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Quote:
Originally Posted by videoFred
Very good. When you are ready, please post it in the 'Power of Avisynth' thread.
No problem. If I have the time to go through the script, I'll post it tonight. IIRC it is actually based on johnmeyer's modification, but it is quite easy to replace stuff if you wish to do so for your own use.

I'll also post one difficult scene to stabilize, unless DepanStabilize manages to fix it. For now I've had to edit the Deshaker log file from MDepan manually to avoid sudden jumps in the stabilized video.

Quote:
Originally Posted by Gavino View Post
You might find it easier to use GScript instead.
Thanks, that looks very useful!
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 17th June 2010, 20:17   #1333  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
By the way, what are the correct resizing parameters for creating a pelclip (both luma and chroma since I'm using YV12) for pel=4?

For pel=2 it's (width*2,height*2,src_left=0.25, src_top=0.25) for luma and (width*2,height*2,src_left=0.5, src_top=0.5) for chroma but should all the parameters be doubled for pel=4?
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 17th June 2010, 20:41   #1334  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Boulder View Post
By the way, what are the correct resizing parameters for creating a pelclip (both luma and chroma since I'm using YV12) for pel=4?
(width*4,height*4,src_left=0.375, src_top=0.375) for luma and (width*4,height*4,src_left=0.75, src_top=0.75) for chroma.
Gavino is offline   Reply With Quote
Old 18th June 2010, 08:17   #1335  |  Link
Vitaliy Gorbatenko
viterra
 
Join Date: Feb 2003
Location: St. Peterburg, Russia
Posts: 142
Help properly configure MVTools that there were no ghosts and sailing parts of the image with the brightness variations. For this sample http://www.mediafire.com/?mrdkatnmyqd
And if it possible - keep thSAD = 400 and limit = 255. sample.avs included.

Last edited by Vitaliy Gorbatenko; 18th June 2010 at 09:58.
Vitaliy Gorbatenko is offline   Reply With Quote
Old 19th June 2010, 01:08   #1336  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Boulder, if you have a good script, I'll test it on the BD of Blade Runner. They butchered that: there's so much gate weave throughout the film that I can't watch it until I fix it. Either the camera was wobbling the entire time, or no one bothered to lock down the telecine.
foxyshadis is offline   Reply With Quote
Old 19th June 2010, 09:45   #1337  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
This is what I've been using as my latest attempt:

Code:
AVISource("w:\nimeton 1.avi",pixel_type="YUY2")
block_size=16
block_size_recalc=8
lambda= 100*block_size*block_size/64
lambda_recalc= 100*block_size_recalc*block_size_recalc/64
lsad= 400*block_size*block_size/64
Crop(16,16,-16,-16,true).ConverttoYV12()
Unflicker()
cleaned=DegrainMedian()
pelclipluma=Spline64Resize(width*4,height*4,src_left=0.375, src_top=0.375)
pelclipchroma=Spline64Resize(width*4,height*4,src_left=0.75, src_top=0.75)
pelclip=pelclipluma.MergeChroma(pelclipchroma)
supaclip=MSuper(pel=4,rfilter=4,pelclip=pelclip)
supacliprecalc=MSuper(cleaned,pel=4,rfilter=4,pelclip=pelclip,levels=1)
vec=Manalyse(supaclip,truemotion=false,global=true,blksize=block_size,overlap=block_size/2,
\dct=5,search=5,searchparam=8,lambda=lambda,lsad=lsad,plevel=0,pnew=25,badsad=400,temporal=true) # temporal=false if SetMTMode is called
vecrecalc=MRecalculate(supacliprecalc,vec,truemotion=false,blksize=block_size_recalc,overlap=block_size_recalc/2,
\dct=5,search=5,searchparam=8,lambda=lambda_recalc,pnew=25,thsad=100)
MDepan(last,vecrecalc,error=80,thscd1=625,thscd2=160,info=true,wrong=3,zoom=false,range=0,log="w:\deshaker\nimeton 1.log")

function Unflicker (clip o)
{
screen   = mt_lutf(o,o,mode="average",yexpr="x",U=1,V=1) #.greyscale
screenTS = screen.temporalsoften(1,9,0,9,2).merge(screen,0.249).temporalsoften(2,5,0,5,2)
calmed   = o.mt_makediff(mt_makediff(screen,screenTS),U=2,V=2)
deflk    = o.Deflicker()
masky    = o.mt_lut("x 32 < x 16 - 16 * x 204 > 255 204 x - abs 255 30 / * - 255 ? ?").removegrain(11,-1)

return o.mt_merge(calmed,masky,U=2,V=2)
}
Lots of things borrowed or stolen from other scripts, particularly Didée's MAnalyse and MRecalculate are probably overkill (using both of them and their settings) but I don't care at this point as this 4.5 hrs of Super-8 video is a one-time thing only.

I've used the script to create a log file to feed to Deshaker and run the 2nd pass there with only ConverttoRGB24(matrix="pc.601") in the script. I noticed that limiting correction to 2 percent will eliminate most shakiness coming from handheld camera movements (not to mention that some scenes have been shot by a 60-70 -year-old person). It could be that even 1 percent is enough for your purposes. Unflicker is for removing the slight flickering in the source material.

Deshaker 2nd pass settings that I've used:


If you or anyone else has any suggestions to improve things, please let me know

Oh, one more bug report to Fizick: if I try to set pel=2 in the MSuper statement that is then fed to MRecalculate, VDub crashes after advancing one frame. This occurs if the MSuper clip that is fed to MAnalyse uses pel=4.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...

Last edited by Boulder; 19th June 2010 at 09:47.
Boulder is offline   Reply With Quote
Old 19th June 2010, 18:21   #1338  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
I've done two projects in the past months which involved 16+ hours of 8mm, Super8, and 16mm. The more recent project was 8+ hours. So, I know what it is like to try to get through a lot of film.

You might want to consider some alternative workflows if you want to do more deshaking.

First, if you Google my name (John Meyer is my real name) and Deshaker, you will find both a Deshaker guide I wrote, as well as a script I wrote which automates the Deshaker process from within the editing program, Sony Vegas. Another person has taken my script, added a UI that mimics Deshaker, and created a DLL version of the script. If you have Vegas, or if you are doing this for a living and therefore can charge off the purchase of Vegas, you will find this permits a workflow that completely gets around the scene change problem (although Deshaker does have a scene change flag) and also permits you to do really advanced motion stabilization that would either be impossible with depan, or which would just take too much time.

The short version of what I do is to first run an AVISynth scene detection script on my film capture. This gives me frame numbers for the scene changes. This isn't perfect, but it is good enough, and if I miss a few scene changes it doesn't matter much. I then use these numbers to automatically (one click) cut the film in Vegas into individual scenes. Then, the Deshaker script is run on each individual scene, something that can be done in batch mode, so you just click once and walk away for a few hours. The stabilized footage is added to each scene in Vegas as a "take." This means that if the stabilization screws up (which does happen), you just press a button to return to the original.

Now, what I have found with VideoFred's script is that the depan works amazingly well for gate weave and simple camera shake. True, it does force you to zoom in to hide the resulting stabilization black borders, whereas Deshaker has the ability to synthesize new borders. However, as long as you are doing small corrections, you don't have to zoom in much, and the compromise is IMHO not bad.

So, my new workflow is to do a quick scrub through the film, and find scenes that I think need the "heavy duty" stabilization. I then only run Deshaker on that. Then, when that is finished, I frame serve the result into VideoFred's script.

None of this may be useful if you don't use Vegas, but perhaps it gives you some ideas for an alternate workflow. The idea of trying to do anything with AVISynth that has to be changed scene-by-scene sounds too painful to contemplate, especially when dealing with many hours of material.
johnmeyer is offline   Reply With Quote
Old 20th June 2010, 03:03   #1339  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 540
Thanks John.
hydra3333 is offline   Reply With Quote
Old 24th June 2010, 21:48   #1340  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
Quote:
Originally Posted by Boulder View Post
Oh, one more bug report to Fizick: if I try to set pel=2 in the MSuper statement that is then fed to MRecalculate, VDub crashes after advancing one frame. This occurs if the MSuper clip that is fed to MAnalyse uses pel=4.
Confirmed. I released fixed version 2.5.10.1 with working MRecalculate for different pels
(also fixed info in MDepan)
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.

Last edited by Fizick; 24th June 2010 at 23:09. Reason: just released!
Fizick is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:09.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.