Fanrestore - Fan Restoration Forum

Full Version: GrainPlate function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
############################################################################################
### GrainPlate 1.0: add real grains to your clip!                                        ###
###                                                                                      ###
### Usage:   GrainPlate(clip, strenght)                                                  ###
###          where strenght range goes from 0 (clip untouched) to 1 (max strenght)       ###
###                                                                                      ###
### Just add your own grain plate, there are many free to download over the web.         ###
### Hints: NEVER upscale/downscale a grain plate; choose one with the same size of your  ###
### clip, or bigger; choose only REAL film grain, and not recreated.                     ###
###                                                                                      ###
### AviSynth script made by spoRv (http://blog.sporv.com) - Created: 2014-06-18          ###
###                                                         Updated: 2016-12-29          ###
###                                                                                      ###
### Creative Commons 4,0 - Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)       ###
### Link to the licence page: https://creativecommons.org/licenses/by-sa/4.0/            ###
############################################################################################

function grainplate (clip clip, "strength") {
strength = default( strength, 0.25)
grain=avisource("putyourowngrainplatefilehere.avi")\
.crop(0,0,clip.width,clip.height).loop.trim(0,clip.framecount-1)
return overlay(clip.tweak(bright=1),grain,mode="softlight",opacity=strength) }

Warning: check the brightness settings with the grain plate you decide to use; it must be raised to be the same of the source without grain plate applied!

deleted user

Thx! 

For those who only have monochrome grain plates like myself, I modified it a bit:
Code:
function grainplate (clip clip, "strength") {
strength = default( strength, 0.25)
g=AVISource("04-MED_CLEAN.avi")
g=MergeRGB(g,UnalignedSplice(g.trim(g.framecount/2-1,g.framecount-1),g.trim(0,(g.framecount/2)-1)),UnalignedSplice(g.trim(g.framecount/3-1,g.framecount-1),g.trim(0,(g.framecount/3)-1)))
grain=g.crop(0,0,clip.width,clip.height).loop.trim(0,clip.framecount-1)
return overlay(clip.tweak(bright=1),grain,mode="softlight",opacity=strength) }

Basically, this applies a delay to the grain plate, once by -50% and once by -33%. Then it merges the RGB from the normal grainplate, the -50% delayed one and the -33% delayed one. 

This is helpful because a monochrome grainplate doesn't really do much to help with chroma blocking. Also, a monochrome grainplate gives an unrealistic result for anything but black-and-white film, as we all know film consists of color layers.

This isn't 100% realistic, as film doesn't consist of RGB layers, but it's good enough for me.

Edit: Just make sure the duration of your grainplate is divisible by both 2 and 3, else some weird results may occur.
I want to start playing with this script. Where can I find a nice grain plate video?
It was A LOT of time ago when I got some nice free plates, so I can't remember, except for gorillagrain; some google-fu with "grain plates" should bring some, though! Big Grin
Oh yes how very lazy of me. Google-fu should have been my first port of call! I found a free clip called "Holy Grain". Might not be the best but will get me started. Thanks.
Yep, IIRC it was nice, too! Ok
Thanks for this! Combined it with the free grain plates at https://tdcat.com/downloads/filmgrain and got some nice results! Uploaded a quick comparison using a Super 16mm plate here:

https://www.screenshotcomparison.com/comparison/11250

Those grain plates are at 24fps so for 23.976 films you will need to modify the one line to:
grain=avisource("putyourowngrainplatefilehere.avi").AssumeFPS("ntsc_film")\
That grain plate for Dirty Pair looks ace! Wish the bozos at Q-Tec and Sunrise left the grainy scans alone instead of sandblasting them "to look closer to the cels".
(2020-09-30, 07:48 PM)spoRv Wrote: [ -> ]It was A LOT of time ago when I got some nice free plates, so I can't remember, except for gorillagrain; some google-fu with "grain plates" should bring some, though! Big Grin

I have 8/16/35, fine/medium/coarse, 1080, 4k, literally hundreds. 23.976, 24, 25, 29.97, they were all free (incl. Gorilla Grain).
Let me know if you'd like them Smile