Log in

View Full Version : Pause video using Avisynth


raslvideos
15th February 2009, 21:10
Hi,
I'm using a script to make a PIP (Picture in Picture).
This script is OK, but the source video 2 starts at the same time that the source video 1.
I want to make that thw source video 2 starts only after 8 seconds than the source video 1.

someone help me?

It' is the script:

==========================
# www.hitthebongo.co.uk
# Picture in picture effect - pip displayed in top right corner with border
# "DirectshowSource" paramater allows wmv videos to be used. It may be possible for other video types to be used if the relevant DS filters are installed...
# ... If windows media player can play a file then you probably have the relevant DS filter. Therefore the file type might work in this script
# Audio is only associated with the first rendered clip which will be the main clip

###########USER SETTINGS##############

MainVideo= "C:\video1.mpg" # This is the main source video
PipVideo= "C:\video2.mpg" # This is the pip video source
PipWidthPercentage=35 # This sets the pip width, expressed as a percentage of the MAIN VIDEO/screen width. 50 results in a pip which is half the width of the MainVideo
PipHeightPercentage=40 # Same as above , but for Height
PipTopPercentage=5 # Expressed as a percentage of MainVideo Height # Read NOTES below
PipLeftPercentage=55 #Expressed as a percentage of MainVideo Width # Read NOTES below
BorderThickness=2 # Expressed as a percentage of the PIP video width
BorderColour=$FFFFFF # Visit http://en.wikipedia.org/wiki/List_of_colors for more Hex Triplet Colour Codes

#NOTES
# The Width and Height and placement co-ordinates of a pip video are usually expressed in pixels. I have instead opted for percentage values of the original...
#... MainVideo as I believe this approach is more intuitive.
#The top left hand corner of the pip video is placed somewhere from the left of the screen and a somewhere below the top.

##########END OF USER SETTINGS##############

main=DirectShowSource( MainVideo ).ConvertToYUY2()
mainW=Width(main)
mainH=Height(main)
PipWidth=int(mainW*PipWidthPercentage/100)
PipHeight=int(mainH*PipHeightPercentage/100)
piptop=int(mainH*PipTopPercentage/100)
pipleft=int(mainW*PipLeftPercentage/100)
PipWidth=int(PipWidth-PipWidth%2)
PipHeight=int(PipHeight-PipHeight%2)
BorderThickness=int(BorderThickness*PipWidth/100)

PipVideo=DirectShowSource( PipVideo ).bicubicresize(PipWidth,PipHeight).AddBorders(BorderThickness,BorderThickness,BorderThickness,BorderThickness, BorderColour).bicubicresize(PipWidth,PipHeight).ConvertToYUY2()

Layer(main,PipVideo,"add",255,pipleft,piptop)

IanB
15th February 2009, 22:54
...
StartF = Round(8*FrameRate(main)) # 8 seconds of frames
MainStart = Trim(main, 0, StartF)
MainEnd = Trim(main, StartF+1, 0)

MainStart ++ Layer(MainEnd, PipVideo, "add", 255, pipleft, piptop)or...
StartF = Round(8*FrameRate(main)) # 8 seconds of frames
PipVideo = PipVideo.Loop(StartF, 0, 0) # Duplicate frame 0 for 8 seconds
Layer(main, PipVideo, "add", 255, pipleft, piptop)

raslvideos
16th February 2009, 00:14
Hi,

I used the code:
...
StartF = Round(8*FrameRate(main)) # 8 seconds of frames
PipVideo = PipVideo.Loop(StartF, 0, 0) # Duplicate frame 0 for 8 seconds
Layer(main, PipVideo, "add", 255, pipleft, piptop)

But, VirtualDub returns:
Avisynth open failure:
Script error: Invalid arguments fo function "Loop"

IanB
16th February 2009, 04:40
... means include the the text I elided.

Loop takes 1 clip then 3 ints as args, i.e. clip.Loop(count, start, end). Is PipVideo a valid clip at this point in the script.

raslvideos
17th February 2009, 11:44
PipVideo is a valid clip at that point in the script.

Guest
17th February 2009, 14:21
PipVideo was assigned as a string at the start and later as a clip. I don't know if that is valid. Why not try different variables?

Gavino
17th February 2009, 15:55
PipVideo was assigned as a string at the start and later as a clip. I don't know if that is valid.
Yes, it is valid. Variables don't have a fixed type.

But your observation could be a clue to the problem. Perhaps raslvideos has deleted the line "PipVideo=DirectShowSource(PipVideo)..." or (more likely) has inserted the new code before it instead of after it.

Kein
11th March 2015, 16:38
What would be the most efficient way to make a silent 5-10 seconds pause with 1 specific frame. I want to add some on-screen text in that range to make an explanation of something. For now I'm using very ugly method:


y = Trim(209,209).Loop(120,1,1).Amplify(0) #creating 5 seconds loop clip of a frame 209 with silenced audio
z = Trim(0,209) ++ y ++ Trim(209,970) (joining the main input source with spoken silent freeze-clip)
# doing more processing

I was hoping that

Loop().Amplify(0)

would apply only to "Loop()" part but it obviously didn't. Is there a way to make a loop and apply other filter to it, not affecting whole input (besides using ugly method with variables and trim as I did)?

poisondeathray
11th March 2015, 18:51
What would be the most efficient way to make a silent 5-10 seconds pause with 1 specific frame. I want to add some on-screen text in that range to make an explanation of something. For now I'm using very ugly method:


y = Trim(209,209).Loop(120,1,1).Amplify(0) #creating 5 seconds loop clip of a frame 209 with silenced audio
z = Trim(0,209) ++ y ++ Trim(209,970) (joining the main input source with spoken silent freeze-clip)
# doing more processing

I was hoping that

Loop().Amplify(0)

would apply only to "Loop()" part but it obviously didn't. Is there a way to make a loop and apply other filter to it, not affecting whole input (besides using ugly method with variables and trim as I did)?




One way to do it is use a helper function, using applyrange() and amplify() . This only makes sense to me if you were going to be using it more than once , otherwise the "ugly" method isn't that bad and is more flexible because you can use other filters whereas applyrange() doesn't work for everything

Pause(start frame, number of times)

For your example

Pause(209,120)





function Pause(clip c, int "start", int "times")
{
Loop(c, times, start, start)
ApplyRange(last, start+1, start+times-1, "amplify", 0)

}