VideoHelp Forum




+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 51
  1. Hi


    I need to create a simple static gaussian blurred background, 1920x1080 16:9, with avisynth

    I can I do?
    Last edited by marcorocchini; 23rd Jan 2025 at 09:06.
    Quote Quote  
  2. HII can someone help a cat thanks?
    Quote Quote  
  3. It's a 0.717:1 image, not 16:9

    How do you want to resolve or adjust the AR to 16:9 ? Crop it ? Rotate it ? Stretch it (fat cat) ?

    You can use GaussianBlur(some value depending on how blurry you want it), or FastBlur is probably faster

    Another way is downscale it by some factor (depending on how blurry you want it), then upscale it
    Quote Quote  
  4. yes it's 0.717:1 a little problematic when the target is 16:9

    Probably a moisture of crop and little stretch.

    I'im in a batch which cannot predict the AR of the input image, however an output image must be generated that is "always" adequate to the 16:9 HD frame to be used as a background to (subsequently) bring another image in layout above. So what can definitely avisynth script to do this?
    Quote Quote  
  5. Do you mean this?
    This ad, just happened to pop on screen at me, after reading your post.
    https://www.youtube.com/watch?v=FCo2eaEeZ2M
    I thought you want to blur just background, not the object.
    Quote Quote  
  6. yes I need to generate a simple background 1920X1080 16:9 from the source image, gaussian blurred
    Last edited by marcorocchini; 15th Jan 2025 at 08:10.
    Quote Quote  
  7. Code:
    Import("v:\automazioneclip\avisynth\plugins\IResize.avsi")
    Import("V:\automazioneclip\AviSynth\plugins\smoothFPS2.avsi")
    Import("V:\automazioneclip\AviSynth\plugins\smoothFPS3.avsi")
    Import("v:\automazioneclip\AviSynth\plugins\CropResizedic2017.avsi")
    Import("V:\automazioneclip\AviSynth\FrameRateConverter2021\FrameRateConverter.avsi")
    LoadPlugin("v:\automazioneclip\AviSynth\FrameRateConverter2021\X64\FrameRateConverter.dll")
    LoadPlugin("v:\automazioneclip\AviSynth\ffms2-2.40-msvc\ffms2-2.40-msvc\x64\ffms2.dll")
    Import("V:\automazioneclip\AviSynth\FFMS2_AVSI_2019\ffms2.avsi")
    LoadPlugin("v:\automazioneclip\AviSynth\LSMASH_AGO_2023\x64\LSMASHSource.dll")
    LoadCPlugin("v:\automazioneclip\avisynth\plugins64\yadif.dll") 
    LoadPlugin("V:\automazioneclip\AviSynth\MaskTool2\X64\masktools2.dll") 
    LWLibavVideoSource("C:\Users\Administrator\Desktop\Nuova cartella (2)\example.bmp")
    
    
    LoadPlugin("c:\variableblur.dll")
    
    
    x = float(width) / float(height) 
    function m4(float x) {return( x<16?16:int(round(x/4.0)*4))}
    
    LancZosResize(m4(x * 1080.0),1080)
    
    
    #FuzzyBorders(16,9)
    
    #GaussResize(width/2, height/2).GaussResize(width,height)

    not working


    Image
    [Attachment 84834 - Click to enlarge]


    Hi, please can someone help a poor cat?
    Quote Quote  
  8. FAT cat , FAST blur
    Code:
    #Crop (some value)
    LanczosResize(1920,1080)
    FastBlur(5)
    Quote Quote  
  9. anh ok thanks, but only one thing

    please download this short video

    https://www.swisstransfer.com/d/c4d77fed-b07f-4848-87aa-44cd8ff9eaca

    she is a friend of my cat

    My default transcoding routine suggest this .avs:

    Code:
    Import("v:\automazioneclip\avisynth\plugins\IResize.avsi")
    Import("V:\automazioneclip\AviSynth\plugins\smoothFPS2.avsi")
    Import("V:\automazioneclip\AviSynth\plugins\smoothFPS3.avsi")
    Import("v:\automazioneclip\AviSynth\plugins\CropResizedic2017.avsi")
    Import("V:\automazioneclip\AviSynth\FrameRateConverter2021\FrameRateConverter.avsi")
    LoadPlugin("v:\automazioneclip\AviSynth\FrameRateConverter2021\X64\FrameRateConverter.dll")
    LoadPlugin("v:\automazioneclip\AviSynth\ffms2-2.40-msvc\ffms2-2.40-msvc\x64\ffms2.dll")
    Import("V:\automazioneclip\AviSynth\FFMS2_AVSI_2019\ffms2.avsi")
    LoadPlugin("v:\automazioneclip\AviSynth\LSMASH_AGO_2023\x64\LSMASHSource.dll")
    LoadCPlugin("v:\automazioneclip\avisynth\plugins64\yadif.dll") 
    LoadPlugin("V:\automazioneclip\AviSynth\MaskTool2\X64\masktools2.dll") 
    vid=LWLibavVideoSource("C:\Users\Administrator\Desktop\Nuova cartella (2)\cat2.mp4",fpsnum=2500,fpsden=100).WriteFileStart("Framecount.txt", "Framecount()")
    aud=LWLibavAudioSource("C:\Users\Administrator\Desktop\Nuova cartella (2)\cat2.mp4",stream_index=1      )
    left=GetChannel(aud, 1)
    right=GetChannel(aud, 2)
    both=mergechannels(left, right)
    audiodub(vid, both)
    ConvertAudioTo16Bit()
    TurnRight()
    #TurnRight()
    #Turn180()
    #TurnLeft()   
    
    converttoYV12(interlaced=false)
    
    x = float(width) / float(height) 
    LancZosResize(m4(x * 1080.0),1080)        
    FuzzyBorders(16,9)
    function m4(float x) {return( x<16?16:int(round(x/4.0)*4))}
    
    emask = mt_convolution(vertical="-1 2 -1").ColorYUV(off_y=-64).ColorYUV(gain_y=128).mt_expand(chroma="-128").Blur(0.8)
    Overlay(last, Blur(0.6, 0.7), mask=emask)
    FrameRateConverter(50000,1000, preset = "faster")
    ConvertToYUY2(interlaced=false)
    assumeFPS(50)
    where the FuzzyBorders.avsi is this:

    https://www.swisstransfer.com/d/8e345b02-ff1e-4e75-95c7-08a667d6a891

    But I wonder:

    how should I change the script to get just the blurred background without also the video image?

    Image
    [Attachment 84841 - Click to enlarge]
    Quote Quote  
  10. I finally got it now, it took a while, , you need to fill borders to a specific resolution.
    hello_hello scripts do that, try to use ImageBorders or FrostyBorders scripts
    https://forum.videohelp.com/threads/393762-ImageBorders-FrostyBorders-Scripts
    https://forum.doom9.org/showthread.php?t=175039
    Quote Quote  
  11. yes ok but in this case I need the only blurred background (in fullscreen HD 16:9), and not also the video at the centre of screen
    Quote Quote  
  12. is there a way to have the only background using FrostyBorders script?
    Quote Quote  
  13. just loop image, apply FrostyBorder to it , use as background to overlay and apply your video on top (personally i would perform blur on background image and then loop image so all will be faster).

    Same approach for ffmpeg - two inputs, background image resized anamorphically, repeat it endlessly, use it doe background in overlay, place video on top.
    Quote Quote  
  14. pandy please help a poor cat: I need the avisynth script

    Image
    [Attachment 84868 - Click to enlarge]
    Quote Quote  
  15. Originally Posted by poisondeathray View Post
    FAT cat , FAST blur
    Code:
    #Crop (some value)
    LanczosResize(1920,1080)
    FastBlur(5)
    poison thanks but today I'm not very fat: maybe using this the background results is not calculate well as using something like the (old) FuzzyBorders?



    Code:
    # requires http://avisynth.nl/index.php/AddGrain
    ##################################
    ### a nice Pillarbox effect - extends blurred source into left & right borders 
    ##  also known as /SoftPillarbox/
    ##
    ## NOTE: 
    ##  * padding is 24 pixels minimum (12 per side), in steps of 4
    ##  * if at least 24 pixels of padding is not needed, source is returned unchanged
    ##  * this filter looks best if source has had any minor black bars cropped off beforehand
    ##
    ## @ aspect_num, aspect_den 
    ##          - defines the output ASPECT RATIO; default 16, 9
    ##              (the ratio determines the new, padded width, given source video height)
    ##              Examples: 
    ##              | FuzzyBorders()           ## expand to 16:9 aspect ratio (default)
    ##              | FuzzyBorders(16, 9)      ## expand to 16:9 
    ##              | FuzzyBorders(4, 3)       ## expand to 4:3 
    ##              | FuzzyBorders(48, 9)      ## expand to 3 x 16:9 (triple monitors!)
    ##              | FuzzyBorders(2560, 1080) ## expand to true 21:9 (21.3333:9)
    ##              | FuzzyBorders(Width+32, Height) ## expand to explicit width
    ## @ edge  - amount of picture on left & right to be stretched over pillarbox; 
    ##              range 0.02_0.5; default 0.03 (3%)
    ## @ gain  - brightness of pillarbox portion; 
    ##              range 0.2_2.0; default 0.9 (slightly darker)
    ##              (bypass / substitute plain black borders if gain < 0.1)
    ## @ sat   - saturation of pillarbox portion; 
    ##              range 0.0_2.0; default 0.5 (50%)
    ## @ blue  - amount of pillarbox blue shift; 
    ##              range -32_32; default 2 (subtle)
    ## @ blur  - amount of pillarbox spatial blur; 
    ##              range 0_100; default 100 (very heavy)
    ## @ noise - amount of pillarbox fixed-pattern noise; 
    ##              range 0_50; default 3 (subtle)
    ## @ tblur - radius of pillarbox temporal blur; 
    ##              range 0_9; 0=off; default 4 (moderate)
    ## @ scene - pillarbox temporal blur scene change threshold
    ##              range 0_255; default 30
    ## @ xblend - amount of cross-blending for pillarbox symmetry
    ##              range 0_1; default 0.0 (off)
    ##
    ## @ version 2.3 (interface; add blend, scenechange; bypass if output too narrow)
    ## @ version 2.4 (AddGrain_DeepColor)
    ##
    function FuzzyBorders(
    \               clip C, int "aspect_num", int "aspect_den", 
    \               float "edge", float "gain", float "sat",int "blue", 
    \               int "blur", int "noise", int "tblur", int "scene", 
    \               float "xblend")
    {
        C
        anum  = Default(aspect_num, 16)
        aden  = Default(aspect_den, 9)
        wid   = _mod(4, (Float(anum) / Float(aden) * Height))
    
        edge  = Min(Max(0.02, Default(edge,   0.06)), 0.5)
        gain  = Min(Max(0.0,  Default(gain,   0.9 )), 2.0)
        sat   = Min(Max(0.0,  Default(sat,    0.6 )), 2.0)
        blue  = Min(Max(-32,  Default(blue,   2   )), 32)
        blur  = Min(Max(0,    Default(blur,   100 )), 100)
        noise = Min(Max(0,    Default(noise,  3   )), 50)
        tblur = Min(Max(0,    Default(tblur,  4   )), 9)
        blend = Min(Max(0,    Default(xblend, 0.0 )),  1.0)
        scene = Default(scene, 32)
    
        test1 = C.Width > (wid-24)
        
        ## TEMPORAL SOFTEN (done first as it adds artifacts)
        (tblur==0 || test1) ? Last 
        \ : TemporalSoften(tblur, 255, 255, scene, 2)
    
        ### EXTRACT LEFT & RIGHT EDGES
        L = (test1) ? Last : Crop(          0,               0, _mod(2, edge*Width), 0) 
        R = (test1) ? Last : Crop(_mod(2, (1.0-edge)*Width), 0, _mod(2, edge*Width), 0)
    
        ## STRETCH
        ## p=19: softest w/o visible 'blockiness' 
        L = (test1) ? Last : L.GaussResize(_mod( 2, 0.5*(wid-C.Width)), Height, p=19)
        R = (test1) ? Last : R.GaussResize(_mod(-2, 0.5*(wid-C.Width)), Height, p=19)
    
        ## BLUR
        ## (almost can't have too much blur)
        L=(blur<0.5 || test1) ? L 
        \ : L.QGaussBlur(blur, blur).QGaussBlur(blur, blur)
        R=(blur<0.5) || test1 ? R 
        \ : R.QGaussBlur(blur, blur).QGaussBlur(blur, blur)
        StackHorizontal(L, R)
    
        ## SYMMETRY
        (blend<0.01 || test1) ? Last 
        \ : Overlay(FlipHorizontal, opacity=blend/2.0)
    
        ## DARKEN, DESATURATE, ADD BLUE SHIFT
        ## (differentiate from main program, but not too much)
        (test1) ? Last 
        \ : ColorYUV(gain_y=f2c(gain), off_u=blue, cont_u=f2c(sat), cont_v=f2c(sat))
    
        ## ADD FIXED NOISE ('FROSTED GLASS') 
        ## (enough to hide any banding from mega-blur)
        (noise==0 || test1) ? Last 
        \ : AddGrain(Float(noise), 0.22, 0.22, constant=1>0)
        
        return (test1) ? C
        \ : StackHorizontal(
        \       Crop(0, 0, _mod(2, 0.5*Width), 0), 
        \       C, 
        \       Crop(_mod(-2, 0.5*Width), 0, 0, 0))
    }
    
    ##################################
    ### quick & dirty Gaussian blur
    function QGaussBlur(clip C, float radx, float rady)
    {
        return C.BilinearResize(
        \           Max(16, _mod(2, Float(C.Width)/radx)), 
        \           Max(16, _mod(2, FLoat(C.Height)/rady)))
        \       .GaussResize(
        \           C.Width, C.Height, p=19)
    }
    
    ##################################
    ### return true if running in Avisynth+, false otherwise
    ##
    function IsAvsPlus()
    {
        sVer = LCase(VersionString) 
        return (FindStr(sVer, "avisynth+")    > 0)
        \   || (FindStr(sVer, "avisynthplus") > 0)
    }
    
    #######################################
    ### scale "normal" float arguments to 
    ### [[ColorYUV]]'s <gain_x>, <gamma_x> & <cont_x>  
    ##
    function f2c(float f) {
        return Round((f - 1.0) * 256.0) 
    }
    
    ##################################
    ### return argument <f> as integer and ensure it is modulo <m>
    ##
    ## @ m - mod value (round toward zero, unless m < 0)
    ## @ f - input (may be positive or negative)
    ##
    ## Examples
    ## | _mod( 2,  3.3) =  2 ## round toward zero
    ## | _mod(-2,  3.3) =  4 ## round away from zero
    ##
    function _mod(int m, float f)
    {
        x  = (m>0) ? -1 : 1
        m  = Max(1, Abs(m))
        sg = Sign(f)
        i  = Round(Abs(f))
        return sg * Max(0, i + x * (i % m))
    }
    
    function BlackBorders(clip v, int width, int height)
    {
       left = ((width - v.width) / 4) * 2
       right = width - (v.width + left)
    
       top = ((height - v.height) / 4) * 2
       bottom = height - (v.height + top)
    
       AddBorders(v, left, top, right, bottom)
    }
    so I wonder: I need the background only, the blurred background without the source image at the center of the screen.

    Is there a way to modify the script so that I get the only blurred background?
    Quote Quote  
  16. Originally Posted by marcorocchini View Post
    Code:
    FrostyBorders(16,9)
    Image
    [Attachment 84870 - Click to enlarge]
    It tells you that mod 4 is needed for image height, but that goes perhaps for width as well.
    Any avisynth or vapoursynth script would have a problem with at least odd resolution sizes and you'd need to fix it anyway.
    So for your FrostyBrorders, you'd need to fix to at least mod4.
    That means just before applying FrostyBorders, you need to check and automatize crop of your image if needed to mod4, width or height need to be divisible by 4.

    I do not know Avisynth math or condition scripting, but it is possible to write.

    Or maybe hello_hello script CropResize can do it as well.
    Quote Quote  
  17. _Al_Cat thanks but please leaving FrostyBorders, considering only for example the FuzzyBorders script above: I ask if there is the possibility to have on avisynth output the only blurred background, fullscreen 1920x1080 16:9 aspect ratio
    Quote Quote  
  18. Is this what you want?
    Quote Quote  
  19. Or just 1920x1080 of something blurred? Based on that small image? Based on those colors? Just Blur the heck out of it (that image) and upscale it.
    Quote Quote  
  20. I just need the blurred background: based on a mixture of rules such that the final result is "pretty" to the eye. I don't need the clear image, only the blurred background 1920X1080 16:9 aspect ratio.

    Does exist anyway to get it?
    Last edited by marcorocchini; 17th Jan 2025 at 09:29.
    Quote Quote  
  21. hI, please can someone help the poor cat

    Image
    [Attachment 84921 - Click to enlarge]
    Quote Quote  
  22. For FrostyBorders you need to specify the output dimensions rather than the aspect ratio, but it's not designed to give you a blurred image without the original picture in the center.

    Do you want the image static or changing as the borders would with FrostyBorders? It might help to know why you want the background or what you'll be using it for in order to offer appropriate suggestions. Based on a random assumption of what you might want it to look like though.....

    Crop and resize each video to the same resolution so the size of the borders won't change (CropResize will apply the appropriate cropping for you based on the output dimensions, so the source resolution could be anything).
    Pick whatever resolution you prefer, but if you do the math based on my choice of a 320x720 input with a 1280x720 output resolution, the borders added will be 480 pixels wide.

    CropResize(320,720)

    Image
    [Attachment 84926 - Click to enlarge]


    FrostyBorders(1280,720, Clone=3, Blur=30)

    Image
    [Attachment 84927 - Click to enlarge]


    1280 - 320 = 960
    960 / 2 = 480
    320 + 480 = 800

    StackHorizontal(Crop(0,0,-800,0), Crop(800,0,0,0))

    Image
    [Attachment 84925 - Click to enlarge]


    Spline36Resize(1280,720)

    Image
    [Attachment 84924 - Click to enlarge]


    Or zoom in rather than stretch.
    CropResize(1280,720)

    Image
    [Attachment 84931 - Click to enlarge]


    The sides could probably be blurred together to remove the seam in the middle, but I really don't know what you're after.
    Maybe something a little sillier?

    V = last
    V = OverLay(V, FlipHorizontal(V), opacity=0.4)
    OverLay(V, FlipVertical(V), opacity=0.4)
    TemporalSoften(5,255,255,20,2)
    FastBlur(20,20,3,Dither=true)
    Spline36Resize(1280,720)

    Image
    [Attachment 84928 - Click to enlarge]


    Edit: FastBlur has a bug that causes it to produce random flashes of blocky colour, very intermittently. Fortunately though, there should be a new version on the way soon. https://forum.doom9.org/showthread.php?p=2013325#post2013325
    Last edited by hello_hello; 17th Jan 2025 at 15:21.
    Quote Quote  
  23. oh Thanks cat

    Originally Posted by hello_hello View Post
    but it's not designed to give you a blurred image without the original picture in the center.


    so, is there a way to get in avisynth only the background image, blurred such a way that it "reflects" the source on average, calculated correctly, in a reasonable "pretty to eye" way and in fixed resolution 1920x1080 16:9 without the original picture in the center?
    Quote Quote  
  24. Originally Posted by hello_hello View Post

    Do you want the image static or changing as the borders would with FrostyBorders?
    maybe as the FrostyBorders

    Originally Posted by hello_hello View Post

    It might help to know why you want the background or what you'll be using it for in order to offer appropriate suggestions.
    yes, is for the video of my cat


    IF possible, I need the avisynth output of the only blurred background, only it, just calculated at the best way

    Originally Posted by hello_hello View Post

    The sides could probably be blurred together to remove the seam in the middle, but I really don't know what you're after.
    Maybe something a little sillier?
    in reality I would simply look for the most refined image calculation possible, to return a background that correctly reflects the input source, despite being very blurry. But precisely calculated on a fair basis, if possible
    Quote Quote  
  25. Maybe crop, downscale , upscale

    Code:
    crop(0,height/4, 0, -height/4)
    bicubicresize(24,12)
    bicubicresize(1920,1080)
    Quote Quote  
  26. Originally Posted by marcorocchini View Post

    so, is there a way to get in avisynth only the background image, blurred such a way that it "reflects" the source on average, calculated correctly, in a reasonable "pretty to eye" way and in fixed resolution 1920x1080 16:9 without the original picture in the center?
    You could always blur it and then crop and resize to 1920x1080, or stretch it to 1920x1080 if you prefer.

    FastBlur(20,20,3,dither=true)
    CropResize(1920,1080)

    Image
    [Attachment 84933 - Click to enlarge]
    Quote Quote  
  27. thanks cat, my question is: but would this work as well as FrostyBorders would?

    it is clear that it always depends on the type of input image, it would therefore not be possible to build something without knowing what the original image actually looks like. But somehow if the calculation can be averaged, perhaps even by "zooming" or squeezing the area in the center to bring it more towards the sides.

    Moreover, it is clear that the background alone and nothing else obviously serves as a background to put something else on top of, but at the moment I would only be interested in the blurred and fullscreen background
    Quote Quote  
  28. Ok, this time I might really know what you actually want, sorry
    to use FuzzyBorders, copy/paste only lines that actually work with image only:

    Code:
    function QGaussBlur(clip C, float radx, float rady)
    {
        return C.BilinearResize(
        \           Max(16, _mod(2, Float(C.Width)/radx)), 
        \           Max(16, _mod(2, FLoat(C.Height)/rady)))
        \       .GaussResize(
        \           C.Width, C.Height, p=19)
    }
    
    function _mod(int m, float f)
    {
        x  = (m>0) ? -1 : 1
        m  = Max(1, Abs(m))
        sg = Sign(f)
        i  = Round(Abs(f))
        return sg * Max(0, i + x * (i % m))
    }
    
    function f2c(float f) {
        return Round((f - 1.0) * 256.0) 
    }
    
    LoadPlugin("C:\ ...   path   ... \AddGrain.dll")
    LWLibavVideoSource("catLearn.jpg")
    GaussResize(1920, 1080, p=19)
    blur = 100
    gain = 0.9
    blue = 0.2
    noise = 3
    sat = 0.5
    QGaussBlur(blur, blur).QGaussBlur(blur, blur)
    ColorYUV(gain_y=f2c(gain), off_u=blue, cont_u=f2c(sat), cont_v=f2c(sat))
    AddGrain(Float(noise), 0.22, 0.22, constant=1>0)
    It worked, only I had to disable that AddGrain line for myself, because I do not have plugin, but you might have it.

    Last edited by _Al_; 17th Jan 2025 at 16:55.
    Quote Quote  
  29. and out cat:
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!