View Full Version : How do I speed up AviSynth processing a VideoFred script?
MartinS
7th September 2020, 12:43
I am copying 8 and 16mm cine using a Flir Blackfly MV camera and reversed Schneider-Kreuznack Companon lens (with very good results)
I can capture 2448x2048 stills:
TIFF 24 bit depth 14.7MB ea
png 24 bit depth 4.5MB
jpeg at 250KB
or an MJPEG avi video stream at 136Mb/s
I am processing the captures with a VideoFred script and AviSynth 2.6 with Virtualdub.
The problem is that processing 4 mins of cine from small jpeg's is taking 20 hours! (png's would take many times longer)
I have tried to process an AVI video stream of 1.9 GB and AviSynth crashed with memory warnings. I can cut the video stream into smaller clips but that would play havoc with the stabilising.
It wouldn't be so bad if I were copying only a couple of films but I have 24 hours of both 8 and 16mm to copy!
The results are so good after the VideoFred treatment that I have to find a way of speeding things up.
I am sure that all of this has been discussed before so please exuse me for repeating the question.
All help WILL be useful
Martin
johnmeyer
7th September 2020, 13:19
You could try my variations on VideoFred's work. They are designed to take advantage of the multi-threading available in some versions of AVISynth and are 3-5 times faster.
StainlessS
7th September 2020, 13:27
AVS+ x64 would be a good idea, rather than avs v2.60 standard [avoid low memory problems].
EDIT: https://forum.doom9.org/showthread.php?t=181351
The Avs+ installer can install both x86 and x64 versions. [which one is used depends upon using eg x86 or x64 version of Vdub2].
You need x86 plugins for x86 version, and x64 plugins for x64 version.
External x86 plugins on wiki, link to x64 plugins follow introduction. http://avisynth.nl/index.php/External_filters
Or direct link to x64 plugs:- http://avisynth.nl/index.php/AviSynth%2B_x64_plugins
EDIT: Not sure if video freds script works under x64, maybe john could advise. [if not work under x64, what are the missing plugins]
MartinS
7th September 2020, 13:54
You could try my variations on VideoFred's work. They are designed to take advantage of the multi-threading available in some versions of AVISynth and are 3-5 times faster.
Could you point to where this could be found John?
Thanks StainlessS...I'll have a look at your post shortly.....I wasnt sure if there was an x64 version of VideoFred's plugins.
The other thought that I had was that someone might have modified Fred's script to work under x64......maybe that's what John is teferring to.
StainlessS
7th September 2020, 14:29
Johns script mod is (so far as I remember) always hard to find, is buried somewhere in VideoFred's thread.
Would be not a bad idea if John were to have his own thread for his version, he can point link at master VideoFred thread in first post,
but also have somewhere that he can point others to when referring to his own mod.
Would also be easy to find, just look for threads started by John [via his profile], intead of ploughing through significant sized VF's thread.
EDIT: Note, John suggests his mod, but does not provide a link to it, perhaps he cannot find it either :)
MartinS
7th September 2020, 16:03
StainlessS
Does this look like the scrips of John Mayer that you refer to?
https://forum.doom9.org/showthread.php?t=144271&page=11 #216
johnmeyer
7th September 2020, 16:56
I've posted about five versions of the script, all of them in VideoFred's threads. This is the latest one:
John Meyer's Branch of VideoFred's Fim Restoration Script Including GamMac (https://forum.doom9.org/showthread.php?p=1861734#post1861734)
I would strongly recommend that you try to get this working by setting Result to either 4 or S4 (the latter gives you a before/after look at the film). Do NOT use GamMac initially because it slows things down.
Stability can be an issue. I have not tested this with 4K scans and I suspect that you are going to have problems with crashes. This isn't caused by my script, or VideoFred's script, but has to do with AVISynth and its memory management. You will also have to play around a lot with all the parameters of the "newer" AVISynth+ multi-threading model. I recently upgraded my CPU to a 6-core, 12-thread model and even with that, I usually have to keep the thread count down to 4-6 in order to keep it stable. Also, I turn off multi-threading when I am scrubbing back and forth, while figuring out the best settings for each reel, and then only turn on the multi-threading when I actually create the final output. Lower resolution will reduce or eliminate the stability issues and will dramatically decrease the time it takes to get through your project.
So, I strongly recommend that you capture at lower resolution, or that you downscale prior to doing restoration. 8mm and Super 8 really don't need much more than 720x480 to capture all the detail. I capture with an HD camcorder at 1440x1080, but then have the camera downscale to SD as it outputs to my computer.
I do this for 16mm as well, although with that larger gauge you can sometimes get more detail with HD (1920x1080) resolution.
You certainly don't need to use 4K resolution for 8mm or Super 8 home movies and probably not 16mm as well.
I had a chance to prove this with some 16mm B&W film I transferred for a client that was taken in 1935 of the Nazis in Dresden, Germany. The man taking it owned a movie camera factory and knew how to use his equipment, so the film was sharp, steady, correctly exposed and properly developed. I transferred all the film and we donated the results to the Wiesenthal Museum in L.A. Years later, the Smithsonian Channel found it and wanted to use it. However, they wanted to have the film re-scanned by their lab in L.A. I arranged for the film to be sent there, scanned, and then had the lab send the digital files to me, so I could review the results prior to sending them to the production company.
This gave me a chance to compare my transfers, done on a modified Eiki 16mm projector to a camcorder mounted at point blank range capturing the image prior to the focal point (i.e., upside down).
What I found was exactly what I expected: their scans (done on a $100,000 Spirit) did a better job of extracting shadow details (which your capture device should do as well since you can adjust the gamma) but I saw no evidence of new detail revealed in the normally-exposed sections of each frame, nor did I sense any additional sharpness (i.e., the illusion of more detail by having sharper edges).
So, I recommend that you spend some time doing transfers at lower resolution, or simply down-resn'g some clips from material you've already transferred, and see if you can detect any loss of detail. With 8mm, there is no way you'll be able to see any difference. That tiny little piece of celluloid simply cannot store that much detail.
MartinS
8th September 2020, 16:58
Thanks John
You certainly don't need to use 4K resolution for 8mm or Super 8 home movies and probably not 16mm as well.
The Blackfly camera is less than 4K at 2448x2048 and I was going to look at starting with 1080 high for a final HD film. The Blackfly camera and Spinview software is new to me and there seems to be a lot to figure out in the mass of settings available:scared:.
The trials I did with my Nikon D810 photographing the cine film in the 8mm gate, and the subsequent AviSynth processing told me that this is the way to go. Now for 16mm I have modified a Bell & Howell projector adding a stepper motor and Arduino for control. I removed the glass from the lens and turned up two aluminium adapters so that the reversed Schneider enlarger lens and C mount camera could be mounted in-line and focussed with the B & H (seems to work well).
But the format of what the Spinview capture software will produce is quite different to my Nikon, so hence the AviSynth questions.
I shall be experimenting with your script John vs the various outputs of the new camera system.
A lot to learn and many ways to head off in the wrong direction!!
So :thanks::thanks: all
videoFred
11th September 2020, 10:46
I can capture 2448x2048 stills:
Martin
Hi Martin, you do not need 2448x2048 stills for 8mm film capturings, it's overkill. It's even overkill for 16mm film.
I always capture at 1392x1032 straight to AVI.
Then, I even reduce this to 1296x960, to speed up the script. It runs at 4fps now, with Avisynth+ and multitasking enabled.
After running the script with all all filters, , I upscale to HD: 1440x1080 with black borders to preserve 4:3 aspect ratio.
See my example clip: please set Youtube quality to full HD.
https://www.youtube.com/channel/UC_k0IKckACujwT_fZHN6jlg
Many greetings,
Fred.
PS: example files?
MartinS
13th September 2020, 14:50
Hi Martin, you do not need 2448x2048 stills for 8mm film capturings, it's overkill. It's even overkill for 16mm film.
You are quite correct VideoFred.....I am assessing and amending the scripts using a 720v480 size and then working at 1440x1080 for the final version.
I now have John Meyer's script working with Avs+ and your VideoFred script with Avs (probs with Avs+, there does not seem to be a MVtools x64 dll)
But there is something that I don't yet understand, (it is likely to be a simple answer, but so far it evades me)
I am copying the 16mm films at present
I have copied one with a 0 EV and again with a -1 EV applied by the capture software. Obviously the -1EV is one stop darker througout.
I set up the 0EV film in both the VideoFred and John Mayer script with option 1 Autolevels, Autowhite/GamMac.
If I change the script film for the -1EV one, hit F5, the brightness of the film in the output window decreases, with both scripts.
Is this to be expected? Am I misunderstanding something?
I thought that "Autolevels" or "GamMac" would have compensated for the -1EV.
I can fiddle the brightness via gamma and saturation but that doesn't seem correct.
Is there an option or switch that I haven't found? Or has one to obtain a perfect grey point in the capture software?
StainlessS
13th September 2020, 15:18
there does not seem to be a MVtools x64 dll
https://github.com/pinterf
MartinS
13th September 2020, 16:09
Well I never!
Thanks SS
johnmeyer
13th September 2020, 18:23
I recommend doing most of your levels and color correction in your NLE, rather than relying on GamMac, Autolevels, or any other AVISynth "automatic" compensation. None of them work all that well for the major types of corrections you find in amateur film, much of which was badly exposed because movie cameras did not normally have automatic exposure until the advent of Super 8 cameras.
My workflow is to edit the film in Vegas, and do exposure and color correction, as best I can, scene-by-scene. I then frameserve into the AVS script and if I still have residual color and level issues, I let GamMac sort that out. I usually create two restored versions of the movie, one with the auto color correction and one without. I then line these up in Vegas and cut between them, taking the better of the two. I do this because GamMac screws up just about as often as it helps. I don't fault anyone for that, because all the other plugins I've tried, including expensive ones for Vegas, get it wrong as often as they get it right.
There is a reason that color timing for "Hollywood" films is still done by having a person with a practiced eye twiddling knobs.
MartinS
13th September 2020, 19:44
Hmmmmm......I need to re-think my workflow now.
but
I have just discovered that Premiere Pro CC has Scene Detect in their beta plan. I am just downloading it.
Seems like my 20-odd thousand feet of cine might take some time.........
Thanks John
johnmeyer
13th September 2020, 20:27
Hmmmmm......I need to re-think my workflow now.
but
I have just discovered that Premiere Pro CC has Scene Detect in their beta plan. I am just downloading it.
Seems like my 20-odd thousand feet of cine might take some time.........
Thanks JohnI have several AVISynth scene detection scripts, and StainlessS has spent a LOT of time perfecting his, and just posted an update within the last week.
videoFred
14th September 2020, 11:16
I do this because GamMac screws up just about as often as it helps.
Hi John,
First of all, thank you again you for all your useful comments in my threads! :thanks:
For the GamMac false results I have found a pretty good solution:
https://forum.doom9.org/showthread.php?p=1803528#post1803528
many greetings,
Fred.
StainlessS
14th September 2020, 11:35
For the GamMac false results I have found a pretty good solution:
I would have thought that setting arg Scale=0, would accomplish same thing.
Adding small white and black block would just disable automatic setting of input_low and input_high
for all 3 red green and blue, ie would set all 3 channel inputs at 0 and 255. Same as Scale=0.
videoFred
14th September 2020, 13:56
I would have thought that setting arg Scale=0, would accomplish same thing.
Adding small white and black block would just disable automatic setting of input_low and input_high
for all 3 red green and blue, ie would set all 3 channel inputs at 0 and 255. Same as Scale=0.
Hi StainlessS, I have just tried it and for some reason, it is not the same. I will show some examples later.
Fred.
StainlessS
14th September 2020, 16:01
I will show some examples later.
Yes please, but provide sample that can reproduce result, ie without subtitles or histogram.
videoFred
14th September 2020, 16:19
yes please, but provide sample that can reproduce result, ie without subtitles or histogram.
ok ;)
johnmeyer
14th September 2020, 16:36
For the GamMac false results I have found a pretty good solution:
https://forum.doom9.org/showthread.php?p=1803528#post1803528I thought you now used the function StainlessS created for you, "FredAverage." That is what I use for the GamMac section of my version of your script. Here is that code:
Baseclip = PreBorderFrame.crop(borderV,borderH,-borderV,-borderH,align=true).bicubicresize(W,H)
blank_black = Blankclip(baseclip, width=autolev_bord1,height=autolev_bord1)
blank_white= Blankclip(baseclip, width=autolev_bord1,height=autolev_bord1, color=$FFFFFF)
Average= baseclip.FredAverage().invert()
over1 = overlay(baseclip,blank_black, x=40,y=300)
over2 = overlay (over1,blank_white, x=160, y=300) \
.bicubicresize(width(baseclip)-(al2)*2,height(baseclip)-(al2)*2)
Detect = (al2 >1) ? overlay (Average, over2,x=al2,y=al2) \
.converttoRGB24(matrix="rec709") : over2.converttoRGB24(matrix="rec709")
result1= PreBorderFrame.ConvertToRGB24.GamMac(verbosity=4,DC=Detect,Show=False, \
LockChan=LockChan, Th=Th, LockVal=LockVal, Scale=Scale, RedMul=RedMul,\
GrnMul=GrnMul, BluMul=BluMul, loTh=LOTH,hiTh=HITH,oMin=OMIN,oMax=OMAX,\
x=GMx,y=GMy,w=GMw,h=GMh).converttoYV12().deflicker().addborders(X,0,0,0,$FFFFFF) \
.addborders(0,0,X2,0,$000000).autolevels(filterRadius=2).crop(X,0,-X2,-0) \
.addborders(bord_left+in_bord_left, bord_top+in_bord_top, \
bord_right+in_bord_right, bord_bot+in_bord_bot)
StainlessS
14th September 2020, 18:52
I thought you now used the function StainlessS created for you, "FredAverage."
Yep, but also lil white and lil black block too:- https://forum.doom9.org/showthread.php?p=1803528#post1803528
http://www.super-8.be/Doom/GamMac_New_detect_05.jpg
EDIT: Also John,
I note that you use FredAverage().Invert in you version of Fred Script,
There is an arg to FredAverage(Invert=true) which does that but without an additional Invert() call.
FredAverage, (not to be confused with RedAverage):- https://forum.doom9.org/showthread.php?t=174520
Requires VS2008 CPP runtimes.
dll's for avs v2.58 & avs v2.60/+ x86 & x64.
A simple average filter for Avisynth v2.60 standard colorspaces, only. (v2.58 colorspaces for v2.58 dll)
Returns a clip where each return frame is a single color average of input frame, same size and colorspace as input.
Does an invert on result if Bool Invert==true.
ColorSpace, YV12, YV16, YV24, YV411, Y8, YUY2, RGB24, RGB32, only.
Return clip Y, U and V, or R, G and B, will be channel averages, unless Invert==True, where channels averages will be inverted.
FredAverage(clip c, Bool "Invert"=false,Bool "TV_YUV"=False)
Invert, Default false == sampled average. Otherwise Inverted average.
TV_YUV, Default false, If True(And YUV), then photo negative invert around TV levels mid Y(125.5), rather than 127.5.
Returns clip same colorspace and size as input.
EDIT:
Also where Invert=True and colorspace is some YUV[so not applicable for GamMac], and arg TV_YUV=true, then
does TV levels invert, ie 16 <--> 235, whereas Invert() filter 16 -> 255-16(ie 239) and 235(ie 255-20) -> 20,
so Invert() filter for YUV @ TV levels is not really correct photo negative invert, is correct only for PC levels.
videoFred
15th September 2020, 11:43
I thought you now used the function StainlessS created for you, "FredAverage."
Yes, but "FredAverage" is only used to correct wrong Gammac colors on blue sky for example. See the tower above here in StainlessS answer. I have noticed that almost all auto white filters are making blue sky ugly gray, if there is a lot of blue sky in the picture. The same with water...
Anyhow, here we go:
Souce file: heavy under exposed 8mm film.
http://www.super-8.be/Doom/test_gammac_source.jpg
Gammac result without prepared detect clip, scale=2
http://www.super-8.be/Doom/test_gammac_no_detect_clip.jpg
Gammac result without prepared detect clip, scale=0
http://www.super-8.be/Doom/test_gammac_scale_0_clip.jpg
Gammac result with prepared detect clip:
http://www.super-8.be/Doom/test_gammac_with_detect_clip.jpg
Prepared detect clip:
http://www.super-8.be/Doom/test_gammac_detect_clip.jpg
Fred.
johnmeyer
15th September 2020, 15:17
OK, I'll add that code to my version of your script. Thanks to both of you (StainLessS & VF).
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.