VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Results 1 to 14 of 14
Thread
  1. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    Is it possible to write an AviSynth script that replaces just one shot in a movie by loading an image and panning across it?
    Quote Quote  
  2. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    It should be, I don't see why not. You could probably do it by creating the animated image at the proper length, then overlay that on the video at a specified time.
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  3. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    Are there any tutorials you can direct me to that describe how to create the animated image at the proper length?
    Quote Quote  
  4. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    I use Avisynth now and then, but never for editing. This is something that I can do in 30 seconds in a video editor. I'm sure if I put an effort into it, I could do it in Avisynth, but I'm not interested and it would be too boring anyway.

    Jagabo is someone I consider to be an Avisynth guru, maybe he'll respond with a script.
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  5. Works for me - i'm not the author and i don't remember who is the author but anyway he deserve for credits

    Panoramaxxx picture was quite large (over 10000x1080)

    Code:
    imagesource("Panorama_Large_0.jpg")
    
    pwidth  = 1280  #  set to desired
    pheight = 720  #  output resolution
    
    pwidthF=float(pwidth)
    pheightF=float(pheight)
     
    bicubicresize(width()*pheight/height(),pheight)
    trim(1,1).loop(10000*3).AssumeFPS(50.0)
    
    animate( 0,10000*3, "bicubicresize", pwidth,pheight, .33,.33, 0.0,            0.0, pwidth,pheight, 
     \                                  pwidth,pheight, .33,.33, width()-pwidthF,0.0, pwidth,pheight)
    
    return(last)
    Quote Quote  
  6. Something like:

    Code:
    # A function to crop a section from a larger image with subpixel accuracy
    function CropSection(clip vid, float xpos, float ypos, int width, int height)
    {
        BicubicResize(vid, width, height, src_left=xpos, src_top=ypos, src_width=width, src_height=height)
    }
    
    # get a source video
    source = ffVideoSource("video.mp4")
    
    # build a 100 frame panning sequence from a still image, with properties that match the source video
    still = ImageSource("image.jpg", start=0, end=99, fps=source.framerate)
    # over frames 0 to 99 pan from 100,100 to 250,150
    still = Animate(0,99, "CropSection", still,100.0, 100.0,source.width,source.height,\
                                         still,250.0, 150.0,source.width,source.height)
    still = still.ConvertToYV12() # match source color format
    
    # replace frames 100 to 199 of the source video with the panning sequence
    source.Trim(0,99) + still + source.Trim(200,0)
    Quote Quote  
  7. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    Thank you very much! I was able to plug my data in and have it work perfectly.

    Now I'm trying to make the image an overlay, so that there is a hole in part of it that shows the animation of the original video underneath. But I'm getting an error:
    Avisynth open failure:
    ShowAlpha: RGB32 data only
    (line 15)

    Is it possible to have both animation and overlay when the video source is from a DVD? I assume my color space is YV12 since it's from a DVD.

    Here is my current script (eventually I'll be using two video sources):

    Code:
    LoadPlugin("C:\DVD\DGDecode.dll")
    clip1 = MPEG2Source("C:\DVD\04\VTS_01_1.d2v")
    clip2 = MPEG2Source("C:\DVD\24DC\VTS_01_1.d2v")
    still = ImageSource("C:\Images\04.png", pixel_type="RGB32", start=0, end=258, fps=clip1.framerate)
    
    function CropSection(clip vid, float xpos, float ypos, int width, int height)
    {
        BicubicResize(vid, width, height, src_left=xpos, src_top=ypos, src_width=width, src_height=height)
    }
    
    still = Animate(0,258, "CropSection", still,0.0, 0.0,clip1.width,clip1.height,\
                                         still,0.0, 834.0,clip1.width,clip1.height)
    still = still.ConvertToYV12()
    
    clip1.Trim(0,11666) + still.Overlay(still, mask=still.ShowAlpha()) + clip1.Trim(11926,0)
    Quote Quote  
  8. Make your mask before converting to YV12:

    Code:
    LoadPlugin("C:\DVD\DGDecode.dll")
    clip1 = MPEG2Source("C:\DVD\04\VTS_01_1.d2v")
    clip2 = MPEG2Source("C:\DVD\24DC\VTS_01_1.d2v")
    still = ImageSource("C:\Images\04.png", pixel_type="RGB32", start=0, end=258, fps=clip1.framerate)
    
    function CropSection(clip vid, float xpos, float ypos, int width, int height)
    {
        BicubicResize(vid, width, height, src_left=xpos, src_top=ypos, src_width=width, src_height=height)
    }
    
    still = Animate(0,258, "CropSection", still,0.0, 0.0,clip1.width,clip1.height,\
                                         still,0.0, 834.0,clip1.width,clip1.height)
    alpha_mask = still.ShowAlpha()
    still = still.ConvertToYV12()
    
    clip1.Trim(0,11666) + still.Overlay(still, mask=alpha_mask) + clip1.Trim(11926,0)
    Quote Quote  
  9. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    Thank you, the error is gone, but it looks like the mask isn't working. The hole in the PNG is showing up as white instead of empty.
    Quote Quote  
  10. Oh, you need to specify that you want to overlay onto the original video.

    Code:
    clip1.Trim(0,11666) + clip1.Trim(11667, 11925).Overlay(still, mask=alpha_mask) + clip1.Trim(11926,0)
    Quote Quote  
  11. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    Thank you!

    For anyone who is curious, the reason I want to use Avisynth is so I can upload the script so people can duplicate my video edit if they want.
    Quote Quote  
  12. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    This is a little off topic, but I have other shots I'm doing that have no motion, animation, panning, zooming, etc. (they're completely still).
    In those instances, is converting to source framerate and color space necessary?
    If so for framerate, does the answer change if I'm using Srestore to specify framerate at the end of the script?
    My source video is from DVD.
    Quote Quote  
  13. Originally Posted by lomaidala View Post
    This is a little off topic, but I have other shots I'm doing that have no motion, animation, panning, zooming, etc. (they're completely still).
    In those instances, is converting to source framerate and color space necessary?
    If so for framerate, does the answer change if I'm using Srestore to specify framerate at the end of the script?
    My source video is from DVD.
    If you are appending segments in an avs script, yes they need the same framerate and colorspace

    If the other shots are completely static, you can assume any framerate for those sections with AssumeFPS()

    You can add the edits after srestore, and assume the same framerate in those other sections before joining them
    Quote Quote  
  14. Actually, if those static shots have audio and are timed to a composition, you'd want to use changefps() instead of assumefps() . AssumeFPS() will slow down/ speed up but keep the same frame count. That will change the timing and cause you to go out of sync if timing was important. ChangeFPS() will drop or duplicate frames (which doesn't really matter for a still shot) and keep the same duration
    Quote Quote  



Similar Threads