Log in

View Full Version : The power of Avisynth: restoring old 8mm films.


Pages : 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Didée
5th August 2010, 17:21
If it really is that way (I didn't check), then it's really a bug. It's not even related to interlacing, Avisynth does not have any flag for that. The only flag is "field based", to mark that the videostream consists of separated fields, which should be weaved again to form full frames.

It has nothing to do with "the choice of the user". When the script outputs full frames, but has them flagged as being field separated, then it's just wrong.

Probably you have used SeparateFields() somewhere in the script, and used that clip as base clip for further operations, so the is_fieldbased flag got propagated.

a = interlaced.bob()

b = interlaced.separatefields()

c = b.resize(b.width, b.height*2)

d = c.merge(a,0.9999)


a: is_fieldbased = false (correct)
b: is_fieldbased = true (correct)
c: is_fieldbased = true (still true. It's debatable if that's wrong or correct. In practice, it's most probably wrong.)
d: is_fieldbased = true (definetly wrong)

videoFred
6th August 2010, 06:28
Probably you have used SeparateFields() somewhere in the script, and used that clip as base clip for further operations, so the is_fieldbased flag got propagated.

I have not used no SeparateFields() nowhere :)

As far as I know the output of my script is progressive and no one was complaining so far.
Perhaps JK1974 has added a SeparateFields() somewhere in the script?

Fred.

JK1974
6th August 2010, 10:30
I have not used no SeparateFields() nowhere :)

As far as I know the output of my script is progressive and no one was complaining so far.
Perhaps JK1974 has added a SeparateFields() somewhere in the script?

Fred.

No, definately not.
Maybe someone is willing to feed meGUI with the script and try to reproduce it.

One thing however: I used ImageSource instead of AVISource, but I can´t believe that this is the reason as Images are frame based by nature...

videoFred
6th August 2010, 12:03
Please try Info() at the end of the script, after the "Eval(result)" line.

It tells me :
Fieldbased (Separated) Video: NO

I think your input is already separated... Mine is progressive. My script is not changing this, it just takes what it gets.

This means you should add 'AssumeFrameBased()' in the first line of the script, in the 'source1=.....' line.

Fred.

supernater
7th August 2010, 16:07
Thanks for your help videoFred. Your results are truly impressive. I'm very interested in the anti-shaking aspect of your script, I think it is perfect for some of the video I've shot on my camera/phone.

I'm kind of new to this and I had a few questions....

#1: In your code you use this line...

stab=DePanStabilize(source1,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15).deflicker()

The method is set to 1. In the depan/depanestimate documentation it says...
method - used method for stabilization:
0 - inertial (default);
1 - average (new since v1.10). dxmax, dymax, rotmax, zoommax, fitlast parameters are ignored.

So does this mean that the dxmax/dymax values aren't needed?


#2: In the depan/depanestimate documentation I usually see example codes like this...

mdata = DePanEstimate(i)
DePanStabilize(i, data=mdata)

However, in your script you create a clip that is cropped by 40, greyscaled, and inverted and call it a stab_reference as the input for DePanEstimate. What is the advantage of doing this?


#3 At the end of your code, stab2 is cropped by less than the maxstabH, maxstabV values. Why is this done? Shouldn't the cropped values of stab2 be the same as the maxstabH, maxstabV values? I guess I don't understand why you decrease the cropping progressively as you move from stab_reference, to stab, to stab2 (I pasted your code below for reference).


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).deflicker()
stab2= stab.crop(CLeft,CTop,-CRight,-CBottom)

Gerald1937
8th August 2010, 13:14
Quote Rightall
c3) I have a lot of films with sound on the magnetic tape track which is simultanously captured and contained in the AVI-file.

Klaus

If your projectors are now set to playback at 16.666 fps and the sound track was originally recorded using 16 fps you may find the sound quality poor/strange due to the speed change. From memory the extra tape speed causes a frequency shift upwards +df that is added to all component frequencies of the originally recorded sound. The harmonic relationships of the original sound i.e. F , 2F, 3F become (F+df), (2F+df), (3F+df) that are not harmonically related.

If you require lip synchronization in certain scenes you may want to un-link the sound track from the video then adjust cut/shorten silent periods to obtain lip synch, then re-link the tracks.

Regards Gerald1937

Gavino
8th August 2010, 14:08
If your projectors are now set to playback at 16.666 fps and the sound track was originally recorded using 16 fps you may find the sound quality poor/strange due to the speed change. From memory the extra tape speed causes a frequency shift upwards +df that is added to all component frequencies of the originally recorded sound. The harmonic relationships of the original sound i.e. F , 2F, 3F become (F+df), (2F+df), (3F+df) that are not harmonically related.
I don't think that's right.
All frequencies are multiplied by the same factor (16.666/16), so harmonic relationships are preserved.
(Just like playing a 33rpm disc at 45rpm, as I'm sure you remember. :))

videoFred
9th August 2010, 08:11
#1: In your code you use this line...

stab=DePanStabilize(source1,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15).deflicker()

The method is set to 1. In the depan/depanestimate documentation it says...
method - used method for stabilization:
0 - inertial (default);
1 - average (new since v1.10). dxmax, dymax, rotmax, zoommax, fitlast parameters are ignored.

So does this mean that the dxmax/dymax values aren't needed?

Thank you for tracking this, Supernater!

You are right. In my documentation this is not mentioned. It only says 0= inertial and 1= average. I guess Fizick has updated it later. I did not understood fully what Fizick meanth with this parameter.

But it works somehow because dxmax and dymax is also defined in DePanEstimate(). Sometimes with incorrect results and I blaimed it always on a possible bug. But with method=0 it works like it should now.


#2: In the depan/depanestimate documentation I usually see example codes like this...

mdata = DePanEstimate(i)
DePanStabilize(i, data=mdata)

However, in your script you create a clip that is cropped by 40, greyscaled, and inverted and call it a stab_reference as the input for DePanEstimate. What is the advantage of doing this?

Well, for stabilizing we only need motion analisys. No colors and no crawling pixels. This is the reason why I have binarised, greyscaled and inverted the stab_reference clip.

The cropping has another reason: sometimes the stabilizer is following a moving object, and sometimes we don't want this. For example if you only want to stabilize a slight vertical jitter, you can crop to an area where only this jitter can be analyzed while ignoring all de rest.


#3 At the end of your code, stab2 is cropped by less than the maxstabH, maxstabV values. Why is this done? Shouldn't the cropped values of stab2 be the same as the maxstabH, maxstabV values?

In principle you are right. But very often the maxstab. values are never reached or perhaps only on a few frames. This depends on the amount of shaking on the source of cource. Thus I try to crop as less as possible to avoid removing to much from the picture. This is also the reason why I have set mirror=15. You will barely notice it if a few -mirrored- frame borders are visible.


I guess I don't understand why you decrease the cropping progressively as you move from stab_reference, to stab, to stab2 (I pasted your code below for reference).

Stab_reference is only a reference clip for analyzing motion and creating the mdata clip. Then I apply the stabilizing on source1, using the information from the mdata clip, and create a stabilized clip called stab. To keep the code readable and because I use different versions of stab further in the script, I have named them stab2, stab3 and so on.

Fred.

supernater
9th August 2010, 18:54
Thank you for the reply videoFred, I understand a lot better now. Recently I've acquired an Android phone and I've been recording videos on it. I've been attempting to adapt that part of your script to stabilize some of the shake that my videos have. In the future I will probably use other aspects of your script to address some of the other issues with my phone videos.

Thanks again for the wonderful script! Your results are simply amazing.

Gerald1937
12th August 2010, 21:52
Gavino

I stand corrected. A tape recorder speed error does not change the harmonic relationship as I suggested.

Regards
Gerald1937

videoFred
30th August 2010, 09:09
Script update 30/08/2010:
see page one of this thread.

Fred.

Undead Sega
31st August 2010, 06:48
Could avisynth filters, scripts or the scripts mentioned in this thread possibly recover a faded 16mm film??? For example, a faded film that looks more reddish than what it is suppose to be.

videoFred
31st August 2010, 07:18
Could avisynth filters, scripts or the scripts mentioned in this thread possibly recover a faded 16mm film??? For example, a faded film that looks more reddish than what it is suppose to be.

Perhaps...Please upload an example clip. AVI if possible.

Fred.

Emulgator
31st August 2010, 09:48
Undead Sega, you may use AdjustY followed by ColourYUV.
Use SourceHistogram to look where the remaining U and V of the source sit.
Or use SmoothTweak to shift U and V and then SmoothCurve to spread these values.
Both apply dithering while processing, very valuable to reconstruct values that otherwise would be omitted.

Undead Sega
1st September 2010, 03:20
At this moment of time, i do not have the capability or the equipment to view, transfer or even capture 16mm film so I am not able to show it to you in the way it was meant to be.

However, I did my best to give you an idea, i hooked up my old HP scanner and taped down a section of the 16mm film itself and scanned a single frame on its own at the highest DPI i could (its that old so it wont look great), i cropped and straightened the frame and here it is:

http://img819.imageshack.us/img819/453/16mmchristmascarol2.png

looks familiar anyone? :D

johnmeyer
1st September 2010, 05:49
As I indicated in another thread, I think you'd be much better off doing color correction in a competent editing program rather than try to do this using AVISynth. You really need the immediate feedback, scopes, external monitor, masks, selective color correction, etc. AVISynth is simply the wrong tool for this task, IMHO.

The image from the leader of your film isn't ideal for knowing how well you'd be able to recover the image. I have dealt with lots of old movie film that is either mostly blue and white, or like yours, red and white. In some cases there is not enough of the faded layers left to do a lot other than subtract out the red. Sometimes you are better off just turning it into B&W film, which of course is easy. However, depending on how much time you want to spend, you can use selective color correction combined with masks to make sure the sky is blue and the trees are green. In effect, you are colorizing the film, but since there is still some hint of the original color, you can "amplify" what is left and get decent results.

Here's what I did in Vegas, in less than one minute, with your single frame:

https://i.imgur.com/SSIxMS4.jpg

With a little more time I could attack the blue that inevitably emerges as you subtract out the red. This is where the selective color tools become important: as you introduce artifacts from the correction process, you can selective remove them.

Unfortunately, as I said above, this frame isn't a good one to use because there is nothing that is white, black, or neutral gray. Usually you can find some of this in the course of going through the reel and they provide reference points for setting the color compensation.

I have some examples on my YouTube page of old 16mm film that had faded to red and which I've corrected. Go to the 5:10 mark in this video:

1937 - Caribbean and Central America (http://www.youtube.com/watch?v=LoOMI-RGIxk)

This was originally nothing but red and white, about as bad as any old faded film I've transferred.

Here's another example from a similar reel:

Yellowstone Park 1937 (http://www.youtube.com/watch?v=cM6UQITactI)

This was in similarly bad shape and indeed the opening, even after restoration, shows very little color. However, instead of the overwhelming red cast, there is only a hint of red. By the time you get to the one minute mark, you can actually start to see some greens and blue, some of it introduced by me using the selective color correction I mentioned.

There is no way you can do these things, especially when you apply correction selective to different parts of the image depending on what should be there, if you only use a script.

I had the best luck on this short clip:

Salt Lake City 1937 (http://www.youtube.com/watch?v=7CockAucXBg)

You will see, right from the opening frame, that I was able to coax a little green and some blue out of the film. It doesn't take much, but you have to have some residual dye left in order to make any of this work.

As to which version of "Christmas Carol" this came from, I don't know. I grew up watching the Alastair Sim version. I also have collected both the 78 rpm and the rarer 33 1/3 audio recording featuring Basil Rathbone in the title role. He made a great Scrooge. I played the 78 rpm version every Christmas as a child and it still brings back great memories

pirej
1st September 2010, 13:20
Here is an example using virtualdub filter ColorMill(it can be used in avisynth too).

Emulgator
1st September 2010, 14:42
A pure Avisynth solution, 1 extra region right, still unfeathered.
An NLE like Vegas or Edius would come in handy to apply feathering here,
but at least Edius makes visible steps while feathering over only 2..3..4 steps.
Maybe I will try feathering in Avisynth as well sooner or later. This script took quite a bit longer than 1 minute...
http://dvd-manufactur.de/files/16mmchristmascarol_DVD-MF.0000.jpg

Undead Sega
1st September 2010, 15:52
To johnmeyer and Emulgator, those are great responses and I would like to say that you both have done good work attempts on these old films to keep them alive. Really good job :D

This is 16mm film print of Richard Williams' (sound familiar anyone?) A Christmas Carol:

http://en.wikipedia.org/wiki/A_Christmas_Carol_(1971_movie)

which was voiced by Alastair Sim who did indeed star in the version you are talking about, he was merely asked to reprise his role for the animation as his film is usually regarded as the best version of A Christmas Carol. At the same time, I have managed to grab a frame of the same frame that i have uploaded of what it is orginally suppose to look like:

http://img843.imageshack.us/img843/5638/originalchristmascarolf.png (http://img843.imageshack.us/i/originalchristmascarolf.png/)

Hope this helps, also as a reference as well. Let me know what you think.

videoFred
1st September 2010, 16:23
At this moment of time, i do not have the capability or the equipment to view, transfer or even capture 16mm film so I am not able to show it to you in the way it was meant to be.

Then there is not much we can do, can we? :p

Fred.

johnmeyer
1st September 2010, 16:52
Yes that helps. With two minutes in Vegas I produced this:

https://i.imgur.com/wQUpdEh.jpg

Of course I don't know what the rest of it would look like. It looks like some AVISynth noise reduction would help when the color correction is finished.

Undead Sega
1st September 2010, 16:53
I am planning one day to get ahold of the wonderful Lumix GH2 and someone with a 16mm project, and record directly from the lens output straight to the image sensor, this way i should get unparrell picture quality? :D

pgb
3rd September 2010, 13:00
You'll be lucky to find a projector lens that will focus an image onto the camera sensor (about 1cm max). You might do better to put a macro lens on the camera and focus on the projector gate (remembering to dim your lamp otherwise you'll burn out the camera sensor).

Undead Sega
3rd September 2010, 18:44
You'll be lucky to find a projector lens that will focus an image onto the camera sensor (about 1cm max). You might do better to put a macro lens on the camera and focus on the projector gate (remembering to dim your lamp otherwise you'll burn out the camera sensor).

Indeed, this is what I plan to do, however when dimming down the light, wouldnt i be sacrificing the amount of light that is suppose to be projecting through the film?

Also, with this way, would i get the best, all the detail or the information that a film frame would contain?

johnmeyer
3rd September 2010, 19:34
Taking the image directly from the lens is by far the least of the issues in getting a quality transfer. The biggest issue is getting a frame-accurate transfer like a Rank Cintel or Workprinter. If you merely point the video camera at the projector and record the image, you will get a junk transfer.

As to the specific issue of how to capture the image directly from the lens, you must use a telephoto lens in the projector, i.e., something used for projecting from the back of an auditorium. The wide angle lens used for home projectors will not work. And, as pgb noted, you MUST use a much dimmer bulb or you will ruin your camcorder. The bulb used in most projectors generates a huge amount of light and also heat. Even if you don't fry the sensor in your camera, you will almost certainly not be able to stop down the lens enough to get a good exposure. In addition, most camcorder lenses produce the sharpest image at relatively large apertures. I replaced the 300W bulb in my projector with a 15W bulb. A properly diffused daylight color LED bulb is your best bet.

Undead Sega
4th September 2010, 18:48
Indeed that would be the case and also i believe it is now a common practise for those who want their film transfered to a digital form. I have seen the Rank Cintel, that thing is quite a monster and i dont believe i have access to one either but im sure it performs as it looks. With and talking about the Workprinter, I thought this was quite funny:

http://www.moviestuff.tv/quick16_HD.html

because in here it is using the exact camcorder as i am :D And i suppose anyone can do very similar to this with a working 16mm projector :D

On the topic of how to capture the image directly from the lens, this is something I might need to know more about, I have read that one would need to use a Macro lens and zoom in to the film's frame for capture. And yes, I can understand that a bright light can ruin the image sensor of a camera, this is where i read as well, that many people doing this replaces the bulb with a 'RGB LED' lights? Please correct me if i am wrong on this.

johnmeyer
4th September 2010, 20:54
I capture directly from the lens of my Eiki SSL-O 16mm projector. It is a 100mm lens and I put my Sony FX-1 HD camcorder about two inches from the lens. This captures the image before the image has become upright, which is the key. There is no need for any fancy lens on the camcorder. I discovered this arrangement by accident when I was trying to improve on Roger Evan's Workprinter, a device which uses an external aerial lens to re-focus the image onto a spot about four feet from the projector. That arrangement is very tricky to set up and can result in chromatic aberrations around the edge. Once I realized how this worked, I called Roger and explained what I'd done. He then improved upon the setup and created the device you linked to. I also told him how I had eliminated the need for the sync cam and interface to the left mouse button that is the heart of his Workprinter. My approach uses IVTC software to recover the film frames from unsyncrhonized capture of the film from a shutterless projector (I removed the shutter from my Eiki). My approach works perfectly, but Roger is a hardware guy and so he took the idea in a different direction and came up with the sound sync pulse that he uses in his Sniper and some of his other units. Both his approach and mine let you get frame-accurate transfer while running the projector at full speed. This not only speeds up the transfer compared to a Workprinter or Cintel, but also lets you easily and quickly transfer sound film.

As for the bulb, the LED has some advantages in terms of heat (no damage to the film) and longevity. However, after I had my Workprinter upgraded a few months back (I had one of the very first units, and Roger has made all sorts of improvements) and started transferring using the LED light, the one thing I noticed is that the color is a little more difficult to correct compared to a light source that has a more standard Tungsten light spectrum, something that most editing software is more "familiar" with and therefore has more built-in color correction tools. In the end, the LED light source can be color corrected just fine, but it requires a little more custom effort.

My unit doesn't use an LED light source, but instead I was able to find a 20 watt 24 volt MR16 bulb to replace the 250 watt 24 volt MR16 that is the standard projection bulb in my Eiki. I also added an additional diffuser to further soften the light. I am able to capture at 1/1000 shutter speed (which is needed for my unique software method of getting frame accurate results) with the aperture on the camcorder between f4.5 and f11, with no ND filter. I can stop the film for as long as I want to focus the camcorder (perfect focus is essential for a good transfer). I always check focus before I start each reel.

I don't know what an "RGB LED" might be, but if you do go the LED route, you simply want one that is balanced for either daylight or tungsten. The package will either use those terms, or will use the Kelvin equivalents.

Gargamel
5th September 2010, 10:33
Hello everybody,

Thank you for that very interesting thread! And thank you for sharing these scripts.

Transferring old footages is a hobby for many people, especially when they have family films.

In my case, I have only 2 Regular 8mm little reels, but a lot of Super 8 (no sound).
With a few others (a little club!), we began using, between our projector (with a standard 25mm lens for S8) and the camera, a home-made 'condenser' (an optical mirror + a 3d or 5d large lens, about 120mm diameter).- Results may be correct, but after a very long fine adjustment... chromatic fringes were often a problem.
Actually, we use a "lens-in-lens" system, easier to mount. The camera shoots directly in the projector lens, without a mirror nor additional lens.- But the usual projector lenses don't fit; for S8, we have generally to mount a 75 to 85mm lens, and another problem is to find a lens "projector-compatible"; sometimes an old 24x36 projector lens is OK (for example, old 85mm Will-Wetzlar, cutting its plastic external tube); sometimes a wonderful Angenieux or Paillard-Bolex 70mm lens can fit (for instance, on Beaulieu projectors).

We always replace the original bulb either by a little halogen one (20W max, but I only used 5W bulbs) + a white plexiglass diffusor, or by a LED (some guys use multi-LEDs... but I'm very happy with a Falker system: a 3W LED with diffusor and regulator, supposed to give a 5500°K light).

To avoid light sparkling (capturing 18 f/s, PAL), generally the projector speed is adjusted to ~16.7 f/s.- The more lucky ones have a camera with SmartScan or so, which can shoot the 18 f/s projection.- A little few capture picture by picture.

The final aim is to burn DVD for our children or relatives. Obviously, the result isn't a professional one, but itsn't too bad for ~40 year old footages...
http://vimeo.com/11983446

(That example was before the videoFred/johnmeyer scripts, but now stabilization and cleaning will improve a lot! )

Sorry for my English.
Have a nice day!

Undead Sega
7th September 2010, 03:24
I capture directly from the lens of my Eiki SSL-O 16mm projector. It is a 100mm lens and I put my Sony FX-1 HD camcorder about two inches from the lens. This captures the image before the image has become upright, which is the key. There is no need for any fancy lens on the camcorder. I discovered this arrangement by accident when I was trying to improve on Roger Evan's Workprinter, a device which uses an external aerial lens to re-focus the image onto a spot about four feet from the projector. That arrangement is very tricky to set up and can result in chromatic aberrations around the edge. Once I realized how this worked, I called Roger and explained what I'd done. He then improved upon the setup and created the device you linked to. I also told him how I had eliminated the need for the sync cam and interface to the left mouse button that is the heart of his Workprinter. My approach uses IVTC software to recover the film frames from unsyncrhonized capture of the film from a shutterless projector (I removed the shutter from my Eiki). My approach works perfectly, but Roger is a hardware guy and so he took the idea in a different direction and came up with the sound sync pulse that he uses in his Sniper and some of his other units. Both his approach and mine let you get frame-accurate transfer while running the projector at full speed. This not only speeds up the transfer compared to a Workprinter or Cintel, but also lets you easily and quickly transfer sound film.

As for the bulb, the LED has some advantages in terms of heat (no damage to the film) and longevity. However, after I had my Workprinter upgraded a few months back (I had one of the very first units, and Roger has made all sorts of improvements) and started transferring using the LED light, the one thing I noticed is that the color is a little more difficult to correct compared to a light source that has a more standard Tungsten light spectrum, something that most editing software is more "familiar" with and therefore has more built-in color correction tools. In the end, the LED light source can be color corrected just fine, but it requires a little more custom effort.

My unit doesn't use an LED light source, but instead I was able to find a 20 watt 24 volt MR16 bulb to replace the 250 watt 24 volt MR16 that is the standard projection bulb in my Eiki. I also added an additional diffuser to further soften the light. I am able to capture at 1/1000 shutter speed (which is needed for my unique software method of getting frame accurate results) with the aperture on the camcorder between f4.5 and f11, with no ND filter. I can stop the film for as long as I want to focus the camcorder (perfect focus is essential for a good transfer). I always check focus before I start each reel.

I don't know what an "RGB LED" might be, but if you do go the LED route, you simply want one that is balanced for either daylight or tungsten. The package will either use those terms, or will use the Kelvin equivalents.

johnmeyer, that is priceless advice, I dont actually know where to begin or how to respond to that but really thanks very much, this is all so much for me for wanting to restore just one 16mm film that i purchased out of love for the director and hoping to do a restoration on the print as well but at the highest quality, but of course after from what you've said, it comes at a price and I'm not surprised. Also because of you, the consumers will now be able to purchase a better transfer machine :D

I mean, would it be so bad to purchase an Elmo-CL or any 16mm projector just for one 16mm film that has a 50/50 chance of getting brilliant results? Or would any 16mm projector (with sound) would do the job?

Regarding the light, I suppose I can understand you on the LED thing, however would something like the Philips CFL lights (them Energy saving ones)do the job?

Nightshiver
7th September 2010, 14:37
You do realize it's not going to be cost effective at all if your only going to transfer 1 film, right? Unless you already have a camera, film projector, capture method, software, etc.

Undead Sega
8th September 2010, 00:33
Well that's what I thought exactly, but I want to give it my best shot on this. I've got the film, very soon I will have my dream camera :D which will give me the necessary capture method and software (HDMI to RAW :D) or I can just use my Canon HV30. It is only a matter of getting an excellent transfer which I assume would involve having the right projector and adjusting it correctly.

Emulgator
20th September 2010, 14:43
Just in case somebody wants to use RemoveDirtMC outside of videoFreds Script
(recent version from 30-08-2010, and I guess this might apply to a few versions before as well):
I found the last two variables to be handed over to Removedirt swapped.
bool _grey is expected before int limit.
The following version works as standalone for me. (I went on from the nephilis fix from 2010 08 01)


#RemoveDirtMC by heini011 on 26.February 2006
#Suggested by johnmeyer on 09.June 2010
#Incorporated into Filmrestoration script by videoFred on 08.July 2010
#Fixed (vector direction) by nephilis on 01.August 2010
#Fixed (swapped parameters) by Emulgator to work with recent MVTools 2.5.10.1 on 20.September 2010
#
function RemoveDirtMC(clip clp, bool _grey, int limit)
{
_grey = default(_grey, false)
limit = default(limit, 6)
i=MSuper(clp, pel=2)
bvec = MAnalyse(i, isb=true, blksize=8, delta=1, truemotion=true) # for a backward search isb should be "true" not "false"
fvec = MAnalyse(i, isb=false, blksize=8, delta=1, truemotion=true) # for a forward search isb should be "false" not "true"
backw = MFlow(clp, i, bvec)
forw = MFlow(clp, i, fvec)
clipa=interleave(backw, clp, forw)
clipb=RemoveDirt(clipa, _grey, limit)
clipc=SelectEvery(clipb, 3, 1)
return clipc
}


Be careful, I did not try it in videoFreds recent script yet.

videoFred
24th September 2010, 11:41
I have made some modifications on the sharpening. I have figured out there is some relationship between the different sharpening steps I am using.

As a rule of thumb we can say that unsharpmask() sharpening strength can be doubled on every next step with a radius lower than the previous step.

For example:
First sharpening: radius=3 strength = 30
Second sharpening: radius= 2 strength= 60
Third sharpening: radius= 1 strength= 120

Sharpening is much better, when using this method.
I have made a few albums on Facebook:

1958 regular-8 Kodachrome anamorphic:
http://www.facebook.com/album.php?aid=2055923&id=1298449764&l=f29566379a


1974 super-8 Kodachrome:
http://www.facebook.com/album.php?aid=2058406&id=1298449764&l=9830569e79

Fred.

Gargamel
24th September 2010, 13:14
Thank you a lot for your script, and for that new sharpening, Fred.

In my case, it seems ok with only:
First sharpening: radius=3 strength = 10
Second sharpening: radius= 2 strength= 15 or 20
Third sharpening: radius= 1 strength= 30 or 40

With stronger values, the result is grainy. But with these little ones, it's quite correct.
http://vimeo.com/15119321
"Correct", but of course, far from your albums: your pictures are terrific !!!

clive18
25th September 2010, 19:54
Hi
Thanks for a wonderful script.
I am just getting the hang of things, so this is my first post. My question is regarding the mirror image of the capture, as my capture looks fine, but when I saw a car number plate in the film, I realized the the whole film is a mirror image, as I am using the straight (projector)-->(plano-convex-lens)--->(camcorder) setup without a mirror.

So my question is how does one correct the mirror image in avisynth, and when is the best place to do this, (beginning or end of the script). Other concerns are if this will have an effect on the interlacing etc.

Thanks again.
regards
Clive

Undead Sega
26th September 2010, 07:55
You do realize it's not going to be cost effective at all if your only going to transfer 1 film, right? Unless you already have a camera, film projector, capture method, software, etc.

Well that's what I thought exactly, but I want to give it my best shot on this. I've got the film, very soon I will have my dream camera :D which will give me the necessary capture method and software (HDMI to RAW :D) or I can just use my Canon HV30. It is only a matter of getting an excellent transfer which I assume would involve having the right projector and adjusting it correctly.

well...sorry for bringing this up again, but what will I do now then if that's the case? I'm worried also of my 16mm film, its still in the box that it came with through the post :D

Jenyok
20th October 2010, 18:35
There is a specific question to you.
.
Do anything have checked, operating scripts of removal of scratches, points (dirt) of development a film, other defects and artifacts of cinema film 8 mm ?
.
I have read all the theory here and on other web sites, wrote and tried many scripts and avisynth's plugins, but there are no good results.
Sending me on plugins is not interesting to me, I will repeat once again, checked and worked scripts are necessary to me.

Jenyok
21st October 2010, 04:10
Emulgator

Script is really worked.


LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEDIRT_20050507\removedirt.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_10\mvtools2.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEDIRT_20050507\removedirts.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAINT-1_0\removegraint.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAIN-1_0\removegrain.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAIN-1_0\repair.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS_20071112\mvtools.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_10\mvtools2.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEDIRT_20050507\removedirt.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\FLUXSMOOTH_25_DLL_20040729\fluxsmooth.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\VAGUEDENOISER_25_DLL_20050926\vaguedenoiser.dll")



function RemoveDirt(clip input, bool "_grey", int "repmode")
{
_grey = default(_grey, false)
repmode = default(repmode, 16)
clmode = 17
clensed = Clense(input, grey=_grey, cache=4)
sbegin = ForwardClense(input, grey=_grey, cache=-1)
send = BackwardClense(input, grey=_grey, cache=-1)
alt = Repair(SCSelect(input, sbegin, send, clensed, debug=true), input, mode=repmode, modeU = _grey ? -1 : repmode)
restore = Repair(clensed, input, mode=repmode, modeU = _grey ? -1 : repmode)
corrected = RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, \
dmode=2, debug=false, noise=10, noisy=12, grey=_grey)
return RemoveGrain(corrected, mode=clmode, modeU = _grey ? -1 : clmode)
}


# RemoveDirtMC2 by heini011 on 26 February 2006
# Suggested by johnmeyer on 09 June 2010
# Incorporated into Filmrestoration script by videoFred on 08 July 2010
# Fixed (vector direction) by nephilis on 01 August 2010
# Fixed (swapped parameters) by Emulgator to work with recent MVTools 2.5.10.1 on 20 September 2010
#
function RemoveDirtMC2(clip clp, bool "_grey", int "limit")
{
_grey = default(_grey, false)
limit = default(limit, 6)
i = MSuper(clp, pel=2)
bvec = MAnalyse(i, isb=true, blksize=8, delta=1, truemotion=true) # for a backward search isb should be "true" not "false"
fvec = MAnalyse(i, isb=false, blksize=8, delta=1, truemotion=true) # for a forward search isb should be "false" not "true"
backw = MFlow(clp, i, bvec)
forw = MFlow(clp, i, fvec)
clipa = interleave(backw, clp, forw)
clipb = RemoveDirt(clipa, _grey, limit)
clipc = SelectEvery(clipb, 3, 1)
return clipc
}

Emulgator
21st October 2010, 22:18
Happy to help !

frustum
9th November 2010, 19:45
I've been in close email exchange with Fred (author of the script) and have used it to great effect for about 35-ish 50ft 8mm reels. I can't thank him enough for sharing this script.

However, things haven't been entirely smooth, and this tax has cost a lot of time.

(1) multithreading doesn't work for me with Fred's script

(2) avisynth crashes a LOT when I attempt to reload a script in virtualdub (via <f2>)

I have a new dell system bought just for this task. It has a quad core i5-750 cpu, 8GB RAM, 1.5TB drive, running windows 7 x64. 32b virtualdub and 32b avisynth are installed and work well except as noted below.

I've tried 2.57mt and 2.58mt and neither helps problem (1). If I make a small script and do some busywork like resize the image large then small then large then small, setmtmode() does its job and I get a hefty speedup. But with Fred's script, no matter what setmode() options I use, no matter where I move them in his script, or if I simply remove them, it doesn't change the speed of the render. It is frustrating to have a quad core cpu and sit there knowing only one core is in use. Is this a known issue with configurations like mine? Is it a matter of the script being too complicated? On the other hand, fred sees a speedup using a dual core processor using the same script.

Are other people using Fred's script and seeing a speedup (or not) from setmtmode()?

On point (2), I will process a scene, tweak some parameter in the script, hit <F2> in virtualdub to reload, and very often, I get some address exception and I need to reload. In the worst case it is 100% of the time when my editing script gets long. This also means avsmodp is useless to me because avisynth is unstable so it brings down avsmodp with ease.

Part of the problem is the length of my script. To give a flavor of my scripts, they look somewhat like this:

orig = directshowsource("mymovie.avi")
scene1 = orig.trim(100,200)
scene2 = orig.trim(202,350)
...
scene20 = orig.trim(4215,4555)

fix_film(scene1, cleft=16,cright=24,ctop=20,cbottom=16, gamma=1.3) + \
fix_film(scene2, cleft=32,cright=16,ctop=20,cbottom=16, gamma=1.0) + \
...
fix_film(scene20, cleft=16,cright=24,ctop=20,cbottom=16, saturation=1.3, result="2", red=-5, blue=+5)

where each call to fix_film() is invoking a subroutine-wrapped version of Fred's script. My understanding is that avisynth essentially flattens all that out, that subroutines are really akin to macros that get inlined. as a result, I might have 20 copies of every filter in the chain from Fred's script. If I have about 25 scenes or more, avisynth dies immediately before rendering the first frame.

I haven't bothered yet trying to get avisynth x64 and all the required plugins (perhaps not even possible?) x64 to see if that will fix what appears to be a memory limitation. Does it seem worth the hassle to try it, or does the x64 version not address limitations in complexity (eg, there is some table somewhere harcoded with up to 255 calls per script no matter which version of avisynth is being run)?

creaothceann
9th November 2010, 20:48
Have you tried SetMemoryMax with a large value?

As a last resort you could write the script like this:

directshowsource("mymovie.avi")
#Trim( 100, 200).fix_film(cleft=16, cright=24, ctop=20, cbottom=16, gamma=1.3)
#Trim( 202, 350).fix_film(cleft=32, cright=16, ctop=20, cbottom=16, gamma=1.0)
...
#Trim(4215, 4555).fix_film(cleft=16, cright=24, ctop=20, cbottom=16, saturation=1.3, result="2", red=-5, blue=+5)

Uncomment and encode one or several line at a time (use a lossless codec like ffdshow's HuffYUV (http://img153.imageshack.us/img153/4803/ffdshowhuffyuv.png)) and combine the results.

johnmeyer
9th November 2010, 22:01
I was the one who added the setmtmode() statements when I suggested some modifications. However, my version of the script was specifically designed to work multi-threaded, something I achieved by removing some of Fred's magic. So, my suggestion is that if you use the "stock" script as posted by Fred, you should comment out all the setmtmode() statements. As you have found, even if the script doesn't crash, they don't help much because of the way the script is currently structured. With my version, I did get about a 2:1 speed up, something obviously worth doing, but far from the 4-8 times improvement I have sometimes achieved with scripts that are linear and only use one instance of one plug-in.

Tiberiust
9th November 2010, 22:52
@frustrum
I feel yr pain ;) . Avisynth is very reliable. MT in Avisynth is not really 'official', and it's certainly not reliable unless you really know exactly what version of what filter is doing what at what time in relation to whatever else - not a process for the beginner. I reckon I've spent as much time over the past 6 months testing MT routines as actually refining my still basic scripting knowledge. I've ran encodes for 10 hrs only for them to crash at 92%. Encodes have completed only to have messed up frames somewhere...anywhere...and the problems are rarely consistent.

So I've binned MT for anything other than a simple deint and one or 2 basic filters after that - quick DVD rips for instance. Consistently lighting up all 8 cores on my 4ghz i7 became an unachievable obsession :(
I'd recommend trying 2.6 Alpha from IanB and the 'official' team. I use it and now get 99pct script reliability without a SetMTMode in sight. JoshyD's 64bit works well (tho I've read abt resizer problems) and it's all awesomely fast with MT, but it only works for me in very specific limited scripts.

However with decent RAM (yu have 8GB) and Win 7 x64, yu can run multiple instances of 32bit Avisynth with great stability using VDub 32. I often leave mine running 4 or more concurrent encodes, all without MT, and they all finish properly.

Maybe I'm being clueless and other people's experiences are different....but I'm MT'ed out...

T

frustum
10th November 2010, 05:57
creaothceann -- Yes, I have tried 800 (what fred's script uses), and 1024. If I go much larger, say 1300, it seems to crash avisynth. yes, cutting a film into smaller pieces works, and I've done it, but it is simply more convenient to have everything done in one script. I was hoping to find a way to allow that.

johnmeyer -- that seals it then -- I'm done with setmtmode. I've spent a LOT of time trying to get it to work, but it is just too unpredictable when and how it will work and when it and how it will crash. I can live with bugs if their causes and consequences are predictable, but that isn't the case here.

tiberiust -- my experience with 2.57mt was it crashes a lot, but then I seem to be pushing too hard on its limits. now that I've sworn off mt, I've installed 2.58 (no mt, not x64) and it does seem to be a lot more stable. I can edit and it <f2> in virtualdub many times (but not unlimited) without crashing. at least that is one problem mostly solved. Some day when I'm feeling adventurous I'll try 2.60.

Thanks for your input, everyone. It has helped me resolve what to expect and what I want to do about the problem.

videoFred
10th November 2010, 07:49
I've been in close email exchange with Fred (author of the script) and have used it to great effect for about 35-ish 50ft 8mm reels. I can't thank him enough for sharing this script.

You are most welcome :)

It is time to mention that you have improved the autolevels plugin, and I thank you for that. It's a great improvement.

http://forum.doom9.org/showthread.php?t=128585&page=3

I will soon update my script to work with the new autolevels() plugin. I will also add a 'light' version of the script, without removedirtMC() and without degraining. This script runs in real time.

It is very obvious that removerdirtMC() and the degraining afterwards are slowing down the script. Splitting the script could help here. But then we have to work with a few intermediate files of cource.

RemovedirtMC() is using MVTools. Perhaps we could make it faster when using MVToolsMulti() instead? Talking about MVToolsMulti(): there are several (6) versions of the dll. Have you tried them all?

Fred.

stoffal
20th November 2010, 18:38
Thank you, Fred, for your fantastic work on 8mm restoration!
It is just too bad AviSynth is not supported by Mac/Apple... =(

I have a question on the process:
Does it make more sense to first stabilize the footage and then bring it from 18->25 frames? Or is it better to first bring it from 18->25frames and then do the stabilization?

What is your experience ?
Thank you!
Chris

creaothceann
21st November 2010, 02:24
18->25
Are you sure this would improve the video? If you're not playing it on a (PAL) TV the result might look about the same.

And afaik stabilization doesn't depend on the framerate...

johnmeyer
21st November 2010, 03:23
The framerate change he is talking about in Fred's script uses motion estimation. Fred's script does it the right way, as far as I can tell. However, the real question is whether you want that effect or not. Also, Fred's script outputs progressive 25 or 30 fps, and if you want to show on an interlaced TV set, then you need to do the conversion differently, at least if the goal is to make the film look like video.

In the end, for most projects, I don't enable this portion of the script because the result begins to stray too far from what film "is supposed" to look like. Of course this is entirely personal preference.

Undead Sega
22nd November 2010, 04:45
Hi everyone, its me again, how are you all and how is everything? I hope all is well.

I'm here to ask something once again in relation to my faded 16mm film reel I have, does anyone recommend this Elmo CL-16 projector for transfering?

Also, in what format do you lot capture in? Because I was thinking, if one was able to capture raw from the image sensor directly from their cameras to a computer, or to a codec by the name of 'Cineform Raw (if anyone's heard of it)' does this give you alot of freedom to play and adjust the colours of the captured film?

videoFred
22nd November 2010, 07:43
:
Does it make more sense to first stabilize the footage and then bring it from 18->25 frames? Or is it better to first bring it from 18->25frames and then do the stabilization?

What is your experience ?
Thank you!
Chris

Hello Chris,

First, you only need the frame rate conversion for playback on DVD or HD. For computer playback, you can leave the files as they are. Then you have 18fps progressive.

Second, if frame rate conversion is needed, there are lots of options.

Option1: disable the frame rate conversion in my script and let your NLE do it.

Option2: for slow landscape panning scenes, the interpolation option in my script works remarkable good.

Option3: I'm working on a script with frame blending instead of interpolation. I will upload it as soon as possible.

Fred.