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

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

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

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

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th February 2009, 11:35   #1  |  Link
Kraise
Registered User
 
Join Date: Jul 2006
Posts: 30
Avisynth gone wrong

Dunno, I want to see how much you can mess up a source with Avisynth, I mean create halos, scratches, holes, butcher the film unrecognizable, then post your scripts so the world can use them and their glory of greatness
Kraise is offline   Reply With Quote
Old 8th February 2009, 21:35   #2  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
There a point in that? Usually we try to -improve- videos. Not muck them up. That's the studio's job (read: Cowboy Bebop on Blu-ray.)


Easy way to make it look horrendous:
Code:
AddGrain(10).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).blur(1.58)
Sharpen(1).Sharpen(1).Sharpen(1).Sharpen(1).Sharpen(1).Sharpen(1).Sharpen(1).Sharpen(1)
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 9th February 2009, 16:36   #3  |  Link
thetoof
Sleepy overworked fellow
 
Join Date: Feb 2008
Location: Maple syrup's homeland
Posts: 933
Actually, I'd also be interested in such a script to give a *very* old look to the image by screwing it up, but in a bit more refined fashion
-Sepia
-vertical lines (scratches)
-dirt + cigarette burns (I guess a blurred circular mask)
-shaky (inverse of depanstabilize)

That'd be a bit trickier that an addgrain.blur.sharpen chain, but it'd be some nice butchering
__________________
AnimeIVTC() - v2.00
-http://boinc.berkeley.edu/-
Let all geeks use their incredibly powerful comps for the greater good (no, no, it won't slow your filtering/encoding :p)
thetoof is offline   Reply With Quote
Old 9th February 2009, 18:15   #4  |  Link
Jumpyshoes
Registered User
 
Join Date: Jan 2009
Posts: 3
Code:
HaloMaker3000Deluxe()
That's all I have to say.

Edit: Here's an example of HaloMaker3000Deluxe... almost. It renders really slowly so I did some magic. WATCH THIS AT YOUR OWN RISK: http://www.youtube.com/watch?v=SeWGyH2-dQY&fmt=22

Last edited by Jumpyshoes; 13th February 2009 at 02:17.
Jumpyshoes is offline   Reply With Quote
Old 9th February 2009, 21:56   #5  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Sepia itself would be very easy. Tweak() could get that done. Then, vertical lines could be added with AddGrain(50, 0, 1) (replace str with your choice -- It's going to make huge vertical streaks regardless.)

Cigarette burns would be pretty easy IMO. if you play around with making a mask similar to the script I posted above, you can get a fairly nice random pattern of spots you can use to mask in something:
Code:
blank = BlankClip()
noise = blank.AddGrain(5,0,0).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58)
diff = mt_makediff(blank,noise,U=3,V=3)
You'd just need to find a way to create a "burnt" look (Perhaps play around with tweak()?) and mask it in based on the diff. I'm about 90% sure you could do that. But I'd have to play around and get back to you.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 10th February 2009, 22:01   #6  |  Link
Wilbert
Super Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,375
Quote:
Sepia itself would be very easy. Tweak() could get that done.
You can't create a sepia look with Tweak. Have a look at Colorlooks.
Wilbert is offline   Reply With Quote
Old 11th February 2009, 19:17   #7  |  Link
Reuf Toc
Registered User
 
Join Date: Feb 2007
Posts: 65
To stay in the old look theme, is anybody have an idea to create luma flickering ? Same question for shaking video.

Thanks in advance.
Reuf Toc is offline   Reply With Quote
Old 11th February 2009, 23:03   #8  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
Flicker:
Code:
src = last
flicker = BlankClip(src, width=64, height=64, color_yuv=$808080).AddGrain(100).PointResize(width(src), height(src), 32,32,1,1)
src.mt_adddiff(flicker)
Shake:
Code:
ScriptClip("""
randcrop_w=rand(32)
randcrop_h=rand(32)
LanczosResize(width(src), height(src), randcrop_w, randcrop_h, -32+randcrop_w, -32+randcrop_h)
""")
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 12th February 2009, 21:34   #9  |  Link
Reuf Toc
Registered User
 
Join Date: Feb 2007
Posts: 65
Thank you J_Darnley, especially for luma flickering, I shall not have been able to find it by myself. I was closer for shaking, I just didn't find a way to generate random number for each frame.

I've made a function to give an old look to your movies. It's far from perfect but I'm open to any suggestion. Here it is :

Code:
Function OldLook ( clip clp, bool "sepia", bool "vertscratch", bool "stain", bool "lumaflick", bool "shake")

{

sepia       = default (sepia        , true)
vertscratch = default (vertscratch  , true)
stain       = default (stain        , true)
lumaflick   = default (lumaflick    , true)
shake       = default (shake        , true)


x           = width   (clp)
y           = height  (clp)


# sepia

(sepia       == true )  ? Eval("""
sepiaclip   = blankclip (clp, color = $704214)
clp         = overlay   (clp, sepiaclip,  mode="chroma",  opacity=0.5) """) : nop


# vertical scratches

(vertscratch == true )  ? Eval("""

scratch     = blankclip(clp,color=$ffffff).addgrain(7,0,vcorr=1,seed=1).mt_binarize(threshold=228)
clp         = clp.overlay(scratch,mode="darken",opacity=0.2) """)  : nop

# stains

(stain       ==  true)  ? Eval("""

blank       = blankclip(clp,color=$808080)
noise       = blank.spline36resize(32,32).AddGrain(25,0,0).blur(1.58).spline36resize(x,y)
clp         = mt_adddiff(clp,noise) """) : nop

# luma flickering

(lumaflick   == true )  ? Eval("""

flicker     = BlankClip(clp, width=64, height=64, color_yuv=$808080).AddGrainc(10).PointResize(x, y, 32,32,1,1)
clp         = clp.mt_adddiff(flicker) """) : nop


# shake

last        = clp
(shake       == true)   ? Eval("""

ScriptClip("
x           = width   ()
y           = height  ()
randcrop_w  =rand(2)
randcrop_h  =rand(2)
spline36Resize(x, y, randcrop_w, randcrop_h, -2+randcrop_w, -2+randcrop_h)
")""") : nop



return last }
It's almost not tweakable but I can add parameters if requested.

Last edited by Reuf Toc; 13th February 2009 at 00:08. Reason: Changed color value for sepia
Reuf Toc is offline   Reply With Quote
Old 12th February 2009, 21:40   #10  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
# a function which improves smoothness and compressibility with hd video, smok3 (c) 2009, 2010, 2011
resize(16,16).resize(1920,1080)
__________________
certain other member
smok3 is offline   Reply With Quote
Old 12th February 2009, 23:15   #11  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
Quote:
Originally Posted by Reuf Toc View Post
Thank you J_Darnley, especially for luma flickering, I shall not have been able to find it by myself. I was closer for shaking, I just didn't find a way to generate random number for each frame.

I've made a function to give an old look to your movies. It's far from perfect but I'm open to any suggestion. Here it is :

<snip>

It's almost not tweakable but I can add parameters if requested.
Nice work. I once created a sepia tone with with an overlay and a blankclip of the colour Wikipedia said sepia was.

Also, I continued to work on the shake and flicker some more last night and got these two functions. Flicker:
Code:
function Flicker(clip src, float "flicker_scale")
{
    # More is less, that is the bigger this scale, the less the flicker.
    flicker_scale = default(flicker_scale, 100.0) * 10.0
    Eval("""ScriptClip(src, "rand = 1.0 + float( rand(256)-64 ) / """+string(flicker_scale)+"""
            Levels(0, rand, 255, 0, 255, coring=false)")""")
    return last
}
Perhaps someone can offer the correct value for the random shift to that the min gamma is as dark as the max gamma is bright. Does that make sense? Isn't gamma=0.5 the same change as gamma=5.0?

Shake, it doesn't work as a function, but this is what I would like to to be as:
Code:
function Shake(clip src, int "shift_fraction", int "target_w", int "target_h", string "temporal_variation")
{
    # Sets the maximum fraction of the image that it can move.  10 is one-tenth, 20 is one-twentieth, 100 is one one-hundredth.
    # Means that the relative shaking on a 500px wide image is the same as on a 2000px wide image.
    # Shaking is relative in both x and y.
    shift_fraction = default(shift_fraction, 50)
    # I wanted the output to be scaled down so I added this.
    # Default is to make the output clip the same dimensions as the input.
    target_w = default(target_w, width(src))
    target_h = default(target_h, height(src))
    # A string to alter the shaking in some way, not necessarily with time.
    # To increase the shaking with time, perhaps use: "float(current_frame+1)/framecount"
    temporal_variation = default(temporal_variation, "1.0")
    src_w = width(src)
    src_h = height(src)
    
    Eval("""ScriptClip( BlankClip(src, width=target_w, height=target_h), "
    shift_x=float( rand( """+string(src_w/shift_fraction)+""" ) - """+string(src_w/float(shift_fraction*2))+""" ) * """+temporal_variation+"""
    shift_y=float( rand( """+string(src_h/shift_fraction)+""" ) - """+string(src_h/float(shift_fraction*2))+""" ) * """+temporal_variation+"""

    crop_left = """+string(src_w/float(shift_fraction*2))+""" + shift_x
    crop_top  = """+string(src_h/float(shift_fraction*2))+""" + shift_y

    crop_right  = """+string(-src_w/float(shift_fraction*2))+""" + shift_x
    crop_bottom = """+string(-src_h/float(shift_fraction*2))+""" + shift_y

    LanczosResize(src, """+string(target_w)+""", """+string(target_h)+""", crop_left, crop_top, crop_right, crop_bottom)
    ")""")

    return last
}
An addition to this would be to specify an absolute pixel shift. The default is quite a shift. Think "Why does the Enterprise not have seatbelts?" kind of shaking. Another addition would be to generate half as many random numbers and then interpolate between them so there is slower shaking.

Small demo: http://users.telenet.be/darnley/avis...nd%20shake.mkv
Made with:
Code:
SetMTMode(3,0)
LoadPlugin("D:\Avisynth\Plugins\AddGrainC.dll")
LoadPlugin("D:\Avisynth\Plugins\MT.dll")

ImageReader("D:\Images\4chan\w\bleach_1234314674285.jpg", use_devil=false)
ConvertToYV12()
src = last

(true)?Shake(100, 640, 400):LanczosResize(640,400)
Flicker(100.0)
AddGrain(200, 0.1, 0.9)
Trim(0,239)
AssumeFPS(24)
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 13th February 2009, 12:11   #12  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,442
Quote:
Originally Posted by J_Darnley View Post
Code:
function Flicker(clip src, float "flicker_scale") {
...
    Eval("""ScriptClip(src, "rand = 1.0 + float( rand(256)-64 ) / """+string(flicker_scale)+"""
            Levels(0, rand, 255, 0, 255, coring=false)")""")
There's no need to use Eval here - you can just write
Code:
ScriptClip(src, "rand = 1.0 + float( rand(256)-64 ) / "+string(flicker_scale)+"
            Levels(0, rand, 255, 0, 255, coring=false)")
or, if you use GRunT,
Code:
ScriptClip(src, "rand = 1.0 + float( rand(256)-64 ) / flicker_scale
            Levels(0, rand, 255, 0, 255, coring=false)", args="flicker_scale")
Quote:
Shake, it doesn't work as a function...
To make it work, you are forced to set the variable src in your demo script before calling the function, making it impossible to use on two different clips. The real benefits of GRunT can be seen when applied to this function, solving the problem while also making the function simpler and more readable.
Code:
function GShake(clip src, int "shift_fraction", int "target_w", int "target_h", string "temporal_variation") {
    shift_fraction = default(shift_fraction, 50)
    target_w = default(target_w, width(src))
    target_h = default(target_h, height(src))
    temporal_variation = default(temporal_variation, "1.0")
    ScriptClip( BlankClip(src, width=target_w, height=target_h), "
      variation = Eval(temporal_variation)
      shift_x=float(rand(src_w/shift_fraction) - src_w/float(shift_fraction*2)) * variation
      shift_y=float(rand(src_h/shift_fraction) - src_h/float(shift_fraction*2)) * variation

      crop_left = src_w/float(shift_fraction*2) + shift_x
      crop_top  = src_h/float(shift_fraction*2) + shift_y

      crop_right  = -src_w/float(shift_fraction*2) + shift_x
      crop_bottom = -src_h/float(shift_fraction*2) + shift_y

      LanczosResize(src, target_w, target_h, crop_left, crop_top, crop_right, crop_bottom)
    ", args="src, src_w=width(src), src_h=height(src), shift_fraction, target_w, target_h, temporal_variation")
}
Gavino is offline   Reply With Quote
Old 13th February 2009, 13:02   #13  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
Quote:
Originally Posted by Gavino View Post
There's no need to use Eval here - you can just write
<snip>
or, if you use GRunT,
<snip>

To make it work, you are forced to set the variable src in your demo script before calling the function, making it impossible to use on two different clips. The real benefits of GRunT can be seen when applied to this function, solving the problem while also making the function simpler and more readable.
THANK YOU!

I forget why I was using Eval() in the flicker, perhaps copy-pasta syndrome.

I discovered that I had to set src in the main body of the script. What confuses me is that:
src = last
Shake()
worked as did:
src = last
<lots of text>
but when src was only a variable in the function it would complain. Is this some of what was mentioned in your thread? I haven't read it yet but I certainly intend to.
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 13th February 2009, 13:34   #14  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,442
Quote:
Originally Posted by J_Darnley View Post
I discovered that I had to set src in the main body of the script. What confuses me is that:
src = last
Shake()
worked as did:
src = last
<lots of text>
but when src was only a variable in the function it would complain.
The basic problem which bites you when using ScriptClip inside a function is that the function parameters and local variables do not exist at the time the run-time script is executed. See here.

The conventional solution has been to use the string() function and string concatenation, but this is cumbersome and can't be used for clip variables. GRunT provides a much more natural way of binding the variables at the place ScriptClip is called to values inside the run-time script.
Gavino is offline   Reply With Quote
Old 15th February 2009, 15:17   #15  |  Link
sumawo13
Learning Avisynth user
 
sumawo13's Avatar
 
Join Date: Sep 2008
Posts: 79
This thread has been lingering in my head and I thought I would try an idea on the Reservoir Dogs DVD. I wanted to see if I could make it look as if it were being displayed on TV as best I could.



Here is my script. The only external filter I used was ImageSequence.

Code:
vid1=audiodub(mpeg2source("VTS_01_1.d2v").crop(2,56,-0,-60).lanczosresize(848,352).crop(104,0,-104,-0).addborders(0,64,0,64).converttorgb32().generalconvolution(0, "
0 0 0
-1 -6 4
0 5 0 ", 1, false).converttoyv12(),directshowsource("VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3"))
img1=coronasequence("C:\Documents and Settings\Bryant\Desktop\fuzz2\*.png",sort=1).assumefps(23.976).loop()
overlay(vid1,img1,mode="exclusion",opacity=.25)
trim(110276,119186)
If someone has any ideas, I liked to hear them.
sumawo13 is offline   Reply With Quote
Old 13th April 2010, 01:57   #16  |  Link
shoopdabloop
Registered User
 
Join Date: Mar 2009
Posts: 166
Quote:
# a function which improves smoothness and compressibility with hd video, smok3 (c) 2009, 2010, 2011
resize(16,16).resize(1920,1080)
works wonders!

@sumawo13: that actually looks more embossed than TV-like.
shoopdabloop is offline   Reply With Quote
Old 20th August 2015, 07:11   #17  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,371
Bumping this old thread because it is awesome (I especially like Reuf Toc's "OldLook"), and because I've got a new (?) effect. It's kind of a "reverse TBC", because it modulates horizontal position line-by-line from any audio signal, to create that "analog breakup" effect.


For the jitter source, use white noise, sine waves or whatever you like to get the look you want.

I believe this code is original, but if it was copied from somewhere, I apologize!
Code:
LoadPlugin("Waveform\waveform.dll") 

/*
## requires MaskTools2
## requires "Software TBC"
# http://forum.doom9.org/showthread.php?t=162726
# http://www.sendspace.com/file/s78pp4
# which requires:
# findpos 0.1 (EDIT included w/ tbc061.zip)
# dejitter 0.2 (EDIT included w/ tbc061.zip)
LoadPlugin("tbc\dejitter03\dejitter.dll")
LoadPlugin("tbc\findpos02\findpos.dll")
Import("tbc\dejitter03\dejitter.avs")
## requires MaskTools
*/
Import("tbc\tbc.avs")

##################################
### modulate horizontal position line-by-line
##
## jitter signal source = clip A's audio track (if missing, use clip C's audio)
##
#@version 1.1 Jul-2016 - in addition to YV12, add support for YV24, RGB24, RGB32
##
function JitterGenerator(clip C, clip "A")
{
   Assert(C.IsYV12 || C.IsYV24 || C.IsRGB24 || C.IsRGB32, 
   \ "JitterGenerator: source must be YV12, YV24, RGB24 or RGB32")

    A = Default(A, C)
    A = IsClip(A) && HasAudio(A) ? A : C

    ## Last==
    AudioDub(C, A.ConvertToMono) 

    ## jitter source: add vertical waveform to left 48 pixels
    TurnLeft
    (!C.IsYV24) 
    \ ? Waveform(window=0, height=48, under=true, zoom=1)
    \ : StackVertical(
    \      Last,
    \      ConvertToYV12
    \      .Waveform(window=0, height=48, under=true, zoom=1)
    \      .ConvertToYV24
    \      .Crop(0, Height-48, 0, 0)
    \   )
    TurnRight

    src = Last
    thresh = 85
    
    ## Mark video edges:
    ## search for the first bright pixel in left 48 pixels
    p = tbc_findpos_h(src.ConvertToYV12, x1=0, x2=48, thresh=thresh, leftonly=0>0)

    ## jitter the video
    (C.IsYUV)
    \ ? jitter_shift_yuv(src, p)
    \ : jitter_shift_rgb(src, p)

    Crop(48, 0, C.Width, C.Height)

    ## restore original audio
    return Last.AudioDub(C)
}

#######################################
## (HACK) based on tbc_Rescale;
## shifts video position roughly according to 1st offset 
##
function jitter_shift_yuv(clip C, clip offsets) 
{
    y  = C.Greyscale
    u  = UtoY(C)

    w1 = u.Width
    h1 = u.Height

    u = u.BicubicResize(y.Width, y.Height)
    v = VtoY(C).BicubicResize(y.Width, y.Height)

    ## use 1st offset only
    offsets = offsets.PointResize(4, offsets.Height).Crop(0, 0, 2, -0)

    ## (HACK) tweak offsets for approximately even shift
    offsets = StackHorizontal(
    \   offsets.mt_lut("255 x - 2 / 92 - ")
    \ , offsets.mt_lut("x 16 - ")
    \ ).PointResize(2, offsets.Height)

    y1 = dejitter(y, offsets)
    u1 = dejitter(u, offsets).BicubicResize(w1, h1)
    v1 = dejitter(v, offsets).BicubicResize(w1, h1)

    YtoUV(u1, v1, y1)
}

#######################################
## (HACK) based on tbc_Rescale;
## shifts video position roughly according to 1st offset 
##
function jitter_shift_rgb(clip C, clip offsets) 
{
    r = C.ShowRed   ("YV12")
    g = C.ShowGreen ("YV12")
    b = C.ShowBlue  ("YV12")

    ## use 1st offset only
    offsets = offsets.PointResize(4, offsets.Height).Crop(0, 0, 2, -0)

    ## (HACK) tweak offsets for approximately even shift
    offsets = StackHorizontal(
    \   offsets.mt_lut("255 x - 2 / 92 - ")
    \ , offsets.mt_lut("x 16 - ")
    \ ).PointResize(2, offsets.Height)

    r = dejitter(r, offsets)
    g = dejitter(g, offsets)
    b = dejitter(b, offsets)

    return (C.IsRGB24)
    \ ? MergeRGB(r, g, b)
    \ : MergeARGB(C.ShowAlpha, r, g, b)
}

Last edited by raffriff42; 17th March 2017 at 00:16. Reason: (fixed image link)
raffriff42 is offline   Reply With Quote
Old 20th August 2015, 08:04   #18  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 940
Quote:
Originally Posted by raffriff42 View Post
This looks fun, too, but the sendspace links are down.
Have a backup somewhere of the required plugins?
They're not up on the wiki anywhere (that I see in a search)
__________________
Win10 (x64) build 19041
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
AMD Ryzen 5 2600 @3.4GHz (6c/12th, I'm on AVX2 now!)
Sparktank is offline   Reply With Quote
Old 20th August 2015, 10:38   #19  |  Link
pandy
Registered User
 
Join Date: Mar 2006
Posts: 1,050
Use ffdshow for this things - Noise module is quite nice to add scratches and old movie look.
pandy is offline   Reply With Quote
Old 20th August 2015, 20:12   #20  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,371
Quote:
Originally Posted by Sparktank View Post
This looks fun, too, but the sendspace links are down.
Luckily, dejitter and findpos are included with tbc061.zip.
http://www.sendspace.com/file/s78pp4
raffriff42 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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

Forum Jump


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


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