View Full Version : The power of Avisynth: restoring old 8mm films.
johnmeyer
22nd August 2011, 16:12
As usual, thank you for your input, John! :)
You have forgotten weave() at the end of your script.I edited my script above to add that. I was in a hurry and didn't grab enough of the script. Thanks for catching my error.
Can you explain some more please? I do not have any experience with separatefields() and selectevery().
And how do I change this to go from 18fps to 25fps PAL?
The above script is designed to go from 18 fps to 29.97 interlaced. This permits 18 fps progressive film to be displayed on a standard NTSC interlaced display. The script creates a variant of the traditional "3:2" pulldown which takes 23.976 (nominally 24 fps) and converts it to 29.97 (nominally 30 fps) interlaced. With traditional pulldown, the "fields" of the progressive film are repeated. (Progressive video can be broken down into odd and even fields, despite the fact that there is no temporal difference between those fields as is the case with interlaced video.) Thus, you get the first two fields from the first frame, followed by the two fields from the next frame, but then the first field displayed from the second frame is repeated (that's the "3" in the "3:2"). The two fields from the next frame are then displayed, and so on.
This same conversion could be done by repeating entire frames, but the stutter and judder would be twice as apparent. By repeating fields instead of frames, you end up with half the temporal disruption that you would get by duplicating entire frames.
The 3:2 pulldown is how film has been displayed on NTSC TVs since the beginning of time.
For PAL, 24 fps film is often just broadcast as is, resulting in slightly fast playback. No pulldown is done. However, for 18, 16, and slower film (a lot of my old film transfers from the 1920s and 1930s need to be played back even slower than 16 fps, probably because the cameras were still sometimes hand-cranked in those days) you have to add pulldown for PAL playback. This pulldown is done by repeating fields.
You can search these forums and find various scripts I've posted, mostly for adding pulldown to go from 18 fps progressive to 29.97 interlaced. However, many years ago, someone told me I was being rather thick and that I could use a much more generic script that would handle adding pulldown from any starting frame rate, and go to any desired final interlaced frame rate (including PAL 25 fps interlaced, i.e., 50i). The only things you need to change are:
1. Change the AssumeFPS in the first line of the above script to match your film frame rate (18 fps in the script example).
2. Alter the ChangeFPS to double the final frame rate (so that would be 50 for PAL instead of 59.94).
Here's a link to a very short, but useful, discussion about this from quite a number of years ago:
Telecine (http://forum.doom9.org/showthread.php?p=445906#post445906)
Hope that helps!
videoFred
22nd August 2011, 16:35
Here's a link to a very short, but useful, discussion about this from quite a number of years ago:
Telecine (http://forum.doom9.org/showthread.php?p=445906#post445906)
Hope that helps!
It sure helps, thank you John!
Fred.
bizz & buzz
24th September 2011, 23:10
This script does wonders! but I noticed that scene-changes remain dirty and not being cleaned... is there a way to fix it?
bizz & buzz
26th September 2011, 15:39
Please, any help will be much apperciated
videoFred
26th September 2011, 15:55
Because the denoiser is averaging several frames, it takes a few frames at scene change before it works like it should be. There's nothing we can do about that, you will have to cut a few frames at scene change manually. (after running the script).
Fred.
johnmeyer
26th September 2011, 18:21
The other alternative is to denoise each scene individually. This is what I do on critical film scenes. I also adjust the script parameter for each scene. One issue for any sort of denoising is that that is no "one size fits all" script, and even a great script like this one requires that the settings be tuned for the specific problems in each scene.
videoFred
27th September 2011, 06:27
The other alternative is to denoise each scene individually. This is what I do on critical film scenes. I also adjust the script parameter for each scene.
Yes, this is the only good way to do a realy perfect job. This is one of the reasons why I capture scenes, never an entire reel in one shot. So at the end of a capture session, I have reel#1.01.avi, reel#1.02.avi etc... Scriptwriter is a great help here, it creates one script for every scene. Then it's easy to tweak the parameters for every individual file. Then I run all the scripts in a VDub jobfile.
But if a filmreel contains not to many different scenes, you can get away with one setting for the entire reel.
Fred.
joka
27th September 2011, 16:10
bizz & buzz
I have tested the script some time ago and found also, that the last frame before and the first frame after a scene change is not cleaned (no dirt remomal). IIRC the RemoveDirt function do not care about scene changes.
bizz & buzz
27th September 2011, 22:13
Thanks for your comments guys.
Came across a little suggestion by Didée, (see the MC version HERE (http://forum.doom9.org/showthread.php?p=1206869#post1206869)), that did a great job.
LoadPlugin("RemoveDirt.dll") # v0.9 of RemoveDirt
LoadPlugin("MVTools.dll") # There're plenty of incompatible-to-each-other versions currently.
# v1.10.2.1 would be good for this little script here
source = last # whatever you have
prev = source.MVCompensate(source.MVanalyse(isb=false,blksize=16,overlap=8,idx=8),idx=8)
next = source.MVCompensate(source.MVanalyse(isb=true, blksize=16,overlap=8,idx=8),idx=8)
source.SCSelect(next,prev,source,dfactor=2.0)
Sure there are sometimes MC artifacts, but they are unnoticeable in normal playback speed.
Perhaps it will be a good idea to implement this as an option in VideoFred's script.
Thanks again :)
fpp
6th October 2011, 21:08
A Bravia, a smart TV? Then you can connect it to your home network, right? Then you realy must try PS3 media server. The Sony can not read to many codecs, only mpeg2 and h264. PS3 media server is transcoding everything (in real time) so the Sony can read it. I can even stream uncompressed RGB and YV12 this way. :)
Yes, a KDL40EX500. I did some tests for fun initially on Ethernet (the previous TV was a 12-year old CRT :-).
The inbuilt player is very limited indeed.
I also tried PS3 media server, which works really well... but I didn't like the idea of my PC transcoding stuff while the kids were watching a movie, so in the end I just added a Popcorn Hour A200 to take care of that :-)
It doesn't seem to like your uncompressed files however, so if I want to see the raw transfers on the TV I'll give PS3mp another try, thanks for the tip !
PS: sorry for answering so late, but somehow Doom9 decided to stop sending me notifications for this thread around August 22nd, so I though nothing was happening until I got suspicious and checked back in today...
dodgyknee
19th October 2011, 18:48
Sorry, novice here.
I have been very impressed with the results of this script - but so far this hasn't been possible for me!
I have an avi which is the output of a frame-by-frame scanned standard 8 film but when I plug the file into Fred's script it fails with an avisynth open failure, error code 2, on line 122 with the interpolation script and line 120 with the blending script. I have, honestly spent hours trying to figure this out but I am very stuck!
Can anyone give me a hand with this?
Sandy
videoFred
20th October 2011, 06:38
Sorry, novice here.
Hi Sandy, you are most welcome here. :)
It looks like Avisynth can not open your AVI file.
Line 120 and 122 is where the file is opened.
Please show me a screenshot of the error message.
Or at least give me the full error message.
Fred.
dodgyknee
20th October 2011, 18:56
Thank you very much Fred for the warm welcome, it is much appreciated.
I started typing out the error message for you and this made my mistake obvious! I had missed out part of the file directory (the folder). Having fixed this, I then was presented with another error which I have also sorted by installing yuvcodecs.exe.
The film is being restored now (slowly) but I'm not not sure what to do when it ends but I'll need to figure that out later.
This is really great Fred!
Sandy
mammo1789
26th October 2011, 03:04
Thanks Fred for the wonderful package. After I run you script the result is much sharper ( too much for my taste) and less blurry and stable. I recorded directly trough canon power shot a720 camera in 6400x480 30fps progressive. But the spots and lines ( like black not straight and constant lines are still there) I tough the script should solve that. Another question is how to see only the final video when encoding and not the original result ( and on the result part there is text describing the usage of auto levels and so on) I know that I should delete something from the script but I don't know what
Thanks
videoFred
26th October 2011, 06:21
Thanks Fred for the wonderful package.
You are welcome. But please read the helpfiles. :)
Fred.
mammo1789
26th October 2011, 16:07
You are welcome. But please read the help files
Thanks Fred I read the files but i still don't understand how to get only one picture. I changed the sharpening and blurring parameters to make it more subtle and i played with the denoising parameters. But if i try to delete some lines ( results lines ) i get script error. Can you just explain me plain simple how to get only the result output as a single picture without the text, I'm not to good in avisynth.
The screen i get is this i would like only the middle.
http://imageshack.us/photo/my-images/683/screenshot001ek.png/
mammo1789
26th October 2011, 16:09
http://http://imageshack.us/f/683/screenshot001ek.png/
johnmeyer
26th October 2011, 17:12
Thanks Fred I read the files but i still don't understand how to get only one picture. Remove the "S" from this line.
result="resultS4" #specify the wanted output here
videoFred
27th October 2011, 06:41
Thank you John. :)
Fred.
Boffee
28th October 2011, 20:49
I am afraid I am also having trouble with Fred's script. It just will not run. I only have a single core processor and hopefully I have edited the script to run it but I get the following error."Avisynth open failure. Evaluate System exception- Illegal Instruction (C:\Users\KEITHW\Documents\Film_Restore\05) Film_Restoring\Script_and Plugins\04_Film_Restoring_Frame_Blending.avs, line 160)"
Can anyone suggest what is wrong? Perhaps I have edited it wrongly. I must admit I am confused as to what lines are mt calls to disable. Can anyone post what Fred's script should look like edited ror single core working?
Pieter8mm
30th October 2011, 15:43
Erase al the SetMode lines. There are 3 of them in the script:
SetMTMode(5) #disable all MT calls if you are using a single core computer
SetMTMode(1,0)
SetMTMode(5)
Good luck ;)
Boffee
30th October 2011, 21:13
Thanks for that, still fails line 160 though. I have no idea how to fix this.
johnmeyer
31st October 2011, 03:27
You could try my version of the script, posted much earlier in this thread. I removed all references to the original MVTools, only using the newer MVTools2. This gets rid entirely of the MVAnalyzeMulti statement (line 160 in your script). However, I also made a lot of other changes, and considerably reduced the amount of sharpening. You are welcome to try it:
johnmeyer version of the script (http://forum.doom9.org/showpost.php?p=1406847&postcount=216)
If this doesn't work, then perhaps your problem with Fred's script lies somewhere else.
Boffee
31st October 2011, 21:31
Brilliant, your version of the script works. Thanks very much John. One thing I notice is I get a strange frosted glass type of effect over the picture for a few frames every time there is a scene change, see scene shot. Any ideas what this could be?
screen shot http://flic.kr/p/aCJY8R
johnmeyer
8th November 2011, 18:45
Brilliant, your version of the script works. Thanks very much John. One thing I notice is I get a strange frosted glass type of effect over the picture for a few frames every time there is a scene change, see scene shot. Any ideas what this could be? This has been discussed earlier in this thread:
Scene Changes (http://forum.doom9.org/showthread.php?p=1528482#post1528482)
The problem is that not all the plugins have scene change detection built in, and even for those that do, there is no practical way to "tune" these for the huge range of scene types one might find in amateur film. If you read the above link and the replies in the posts which immediately follow, you'll find a few suggestions for how to deal with the problem.
Gerry62
9th November 2011, 07:33
Just found a sort of issue that I cannot find a awnser for,
Nowm I want to output 29.970 FPS NTSC, Ok sounds fine, But when I change the:
play_speed=
numerator=
to 29.970 It comes up with the following Error
"The Named Argument 'num' to MFlowFps had the wrong Type"
Now Ive tried all variations of 29, 29.9, 29.97 etc.
Is is there something I'm Doing Wrong?
Oh and what's denumerator= used for? I have no idea what the following means 60000/1001= 59.94fps
Anyone help? Probably stupid questions
Gavino
9th November 2011, 09:34
Gerry, set numerator=30000 and denumerator=1001, since the NTSC frame rate is 30000/1001 (= 29.97 approx).
('denominator' would be the correct English word.)
Jan Evertsen
23rd November 2011, 14:11
First post, so i'll start with a big THANK YOU for all your hard work and useful comments.
Some time ago- March 2011, Pieter8mm wrote something about a script
I found a other script on this site wich I like to share with you all.
http://www.homedvd.nl/Site/avisynth.html
I haven't tried yet. Put the picture example looks nice.
This site is down...
Does anyone have this script and can maybe post it or PM it to me?
I've been working with Fred's script and John's script with great success, but I would like to have a look at this one, too.
Gerry62
23rd November 2011, 19:35
Yeah, what was that script that is now down?
johnmeyer
23rd November 2011, 20:03
All you have to do is go to the root page, and you'll find that it is a Dutch movie transfer site. Here is a link, translated to English, to conform to this board's English-only requirement:
High End Scanning and Digital Restoration (http://translate.google.com/translate?sl=nl&tl=en&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fwww.homedvd.nl%2FSite%2F)
Perhaps if you click on some of the links, you can find the script.
[edit] None of the movies on their main page appears to have been restored with anything similar to VideoFred's script, although the actual film transfers are exceptionally good.
Oh, wait, the very last examples DO show restoration, but clearly not using anything resembling VideoFred's approach (no stabilization, for instance, and the chain link fence details have not been enhanced).
Jan Evertsen
23rd November 2011, 22:23
Thanks John.
I am dutch and already searched all pages of this site but the script was nowhere to be found. I still hope that a reader of this forum downloaded the script when Pieter8mm mentioned it.
I agree that the maker of this site clearly uses another script and so I am curious about this one, because I like the results (although a bit more stabilisation would be nice).
Now i have another question. I have a nice clean black&white transfer but it is very grey.
When I use Johns script I can adjust the whites and blacks but the results are a bit unnatural, like the shadows in this baby's face.
Original:
http://img43.imageshack.us/img43/9243/012original.th.jpg (http://imageshack.us/photo/my-images/43/012original.jpg/)
Avisynth output:
http://img821.imageshack.us/img821/171/012autowhite.th.jpg (http://imageshack.us/photo/my-images/821/012autowhite.jpg/)
Does someone have an advice to 'smoothen' this effect?
johnmeyer
24th November 2011, 01:51
I have a nice clean black&white transfer but it is very grey. When I use Johns script I can adjust the whites and blacks but the results are a bit unnatural, like the shadows in this baby's face.
Does someone have an advice to 'smoothen' this effect?
My answer to that is similar to what I've posted before: AVISynth is not necessarily the answer to every problem. In this case, my approach is to do most of the "levels" work inside my editing program (which is Vegas). This program has a "Color Curves" interactive fX which lets me draw a Bezier transfer curve that alters the exposure of the film, but with a different gain applied to each level. Most film to video transfers result in video that is too dark in the shadows, a little dark in the midtones, but just right or a little too bright in the lightest areas. Each scene typically requires slightly different exposure correction. So, I apply a "generic" gamma curve, using this color curve fX, to each scene, and then, using a calibrated monitor and the built-in real-time histogram, I interactively tweak the exposure while watching the instantaneous results on both the monitor and histogram displays.
I do not use any of the automatic levels or color correctors built in to VideoFred's script.
Here's what the color curves dialog looks like, in case my description above doesn't make sense:
https://i.imgur.com/tzTAkPk.jpg
I'm using this exact dialog right at this moment to correct a 1933 amateur 16mm silent film that I'm restoring for a French documentary director.
I wish I knew of some autogain function in AVISynth that would do this, and many people have certainly tried to produce such a thing. One such plugin that I used quite a bit, before I discovered VideoFred's work, was the "High Dynamic Range Automatic Gain Control" plugin. You can search this forum and find the plugin. Try it out, and perhaps it will do what you want, without having to do all the manual labor I describe above. I think it has been updated since I last tried it.
videoFred
24th November 2011, 07:24
Yeah, what was that script that is now down?
It's a clone of my script. Do not worry about it.
Fred.
Jan Evertsen
25th November 2011, 00:41
John, thank you again for your reply.
I tried to adjust levels in another program. So far i am very happy with the results.
I do not use any of the automatic levels or color correctors built in to VideoFred's script.
So i presume you use "Result4", saturation=1 and gamma=1 and set all black levels to 0 and the whites to 255?
Another question about your script: what does the "0.9" do in
sharp1=denoised.sharpen(0.9)
I already had a look at HDRAGC and had some very nice results on color film. But now i'm working on some b&w films, adjusting the levels is a lot faster.
johnmeyer
26th November 2011, 08:04
So i presume you use "Result4", saturation=1 and gamma=1 and set all black levels to 0 and the whites to 255?Yes.
Another question about your script: what does the "0.9" do in
sharp1=denoised.sharpen(0.9)If that is in my version of VideoFred's script, I don't remember it.
videoFred
28th November 2011, 07:26
what does the "0.9" do in
sharp1=denoised.sharpen(0.9)
It's the strenght of the sharpen filter. :D
Fred.
johnmeyer
30th January 2012, 22:48
I thought that readers of this thread might be interested in something I did using not only VideoFred's script, but also using MVTools2 to synthesize frames to replace totally broken frames.
Have a look here at the before/after:
Restoring Jumpy Film (http://www.youtube.com/watch?v=uzMFodrGHDs)
This 8mm film was taken in 1954, and the camera (not the projector) malfunctioned and didn't bring the film to rest before opening the shutter. As a result, not only were the frames jumping up and down, but many of those which jumped were blurred. I verified that this problem was indeed on the film itself, and not a malfunction in my film-to-video transfer equipment.
I went through by hand (thousands of frames) and marked each jump frame. I did this by writing a script in Sony Vegas which let me replace any bad frame with a duplicate of the prior frame. I had to do this by hand because there was no pattern to the bad frames, and the frames which were displaced vertically, but not blurred, could be easily repaired using Deshaker or Mercalli (motion stabilization tools).
I then used a variation of the old AVISynth "filldrops" function software which can detect perfect duplicates and the replace them with interpolated frames using mflowinter
So, on the right-side "after" version of the clip, about 50% of those frames are computer-generated.
I then fed this into VideoFred's script which stabilized and sharpened the result.
Emulgator
31st January 2012, 00:14
Wow, this is awesome work !
Gargamel
31st January 2012, 10:58
+1 !
Congratulations, John, and thank you for sharing that idea.
Your film rescue is really wonderful !
jinkazuya
14th February 2012, 22:18
Just wonder if Fred could reupload the whole thing and tell us what version of the plugins that we could use. Because there are a lot of errors running the script and now we use MEGUI to encode MKV...
Really hope to try the script on the video but encounter a whole bunch of errors. If Fred has time and reorganize the script and even give us the script used for MKV and the plugin versions, it would be great.
Anyway, thanks a lot. Cuz most of the videos I have are of bad quality just wanna rescue them.
johnmeyer
15th February 2012, 00:19
... most of the videos I have are of bad quality just wanna rescue them.Just a quick clarification ...
You keep saying "videos." The script really isn't designed to do anything with video, but is instead oriented towards improving film that has been captured to video using a "frame accurate" film-to-video transfer system.
jinkazuya
15th February 2012, 01:42
Just a quick clarification ...
You keep saying "videos." The script really isn't designed to do anything with video, but is instead oriented towards improving film that has been captured to video using a "frame accurate" film-to-video transfer system.
Yes...I know. But it also help to improve the quality of the video such as movies as well right.
If you ever see something amazing like that, you really don't wanna try it out right away:D
videoFred
15th February 2012, 07:35
Just wonder if Fred could reupload the whole thing and tell us what version of the plugins that we could use. Because there are a lot of errors running the script and now we use MEGUI to encode MKV...
I have 3 XP computers, one Vista and one new 64bits 8-core Win7 machine. The script runs fine on all these machines,without any problems, with the plugins I have uploaded. :sly:
Fred.
jinkazuya
15th February 2012, 08:58
hehehe...don't get wrong :D, I am just afraid of the compatible issues.
I know the script is fine. However, whenever I ran the script, it just gave me a bunch of error message (does not have this filter or errors in certain line of the function).
Anyway, is it possible to use the script for the original ripped DVD VOB.
BTW...Used this with MEGUI to encode MKV.
Also the SetMTMode won't work...I already followed the instruction as described in the help folder, put the dll file of the avisynth into System32 or SysWOW64.
These are the basic inbuilt function of the MEGUI.
LoadPlugin("C:\Users\Desktop\MeGui\tools\dgindex\DGDecode.dll")
DGDecode_mpeg2source("C:\Users\Desktop\Encoded Movies\VIDEO_TS\VTS_01_1.d2v", info=3)
LoadPlugin("C:\Users\Desktop\MeGui\tools\avisynth_plugin\ColorMatrix.dll")
ColorMatrix(hints=true, interlaced=true, threads=0)
videoFred
15th February 2012, 09:24
I know the script is fine. However, whenever I ran the script, it just gave me a bunch of error message (does not have this filter or errors in certain line of the function).
What errors? We will solve them one by one. :p
Also the SetMTMode won't work...I already followed the instruction as described in the help folder, put the dll file of the avisynth into System32 or SysWOW64.
Forget the MT and please remove all MT calls. Instead, run multiple instances of my script if you have a multi core computer. On my 8-core I can easily run 4 instances at the same time.
Fred.
Undead Sega
18th February 2012, 05:42
Hi guys, I know this may seem abit random but still relevant, I thought I would like to share this very simple Flash app that shows the different colour layers from the film 'The Patriot' when reconstructing the faded Yellow layer:
http://www.history.org/foundation/journal/summer04/patrest.swf
Original site is here:
http://www.history.org/foundation/journal/summer04/patriot.cfm
I thought the work was amazing, and I never thought that one could reconstruct or restore a faded layer in film. Tell me what you think, been meaning to mention this kind of topic for ages but didnt know how to do it exactly :)
johnmeyer
19th February 2012, 00:29
Interesting ... but:
1. How did they separate the layers? Is this something to which any of us would have access?
2. Once they have the yellow layer, which appears to have virtually no information, how did they restore it?
[edit]Ah, I just read the second link. They had B&W separation masters. So, I "can't do this at home."
videoFred
19th February 2012, 10:55
Interesting ... but:
1. How did they separate the layers? Is this something to which any of us would have access?
2. Once they have the yellow layer, which appears to have virtually no information, how did they restore it?
[edit]Ah, I just read the second link. They had B&W separation masters. So, I "can't do this at home."
I was asking myself the same questions ;)
However, it might be possible with masktools but this is beyond my knowledge.
Fred.
Undead Sega
20th February 2012, 02:55
I was asking myself the same questions ;)
However, it might be possible with masktools but this is beyond my knowledge.
Fred.
What would be done exactly with MaskTools??? :D
videoFred
20th February 2012, 07:42
What would be done exactly with MaskTools??? :D
Making color masks :p
Fred.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.