Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

 
Display One Video In The Corner Of Another One
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
AceStorM
Posted: Dec 5 2013, 06:57 PM


Newbie


Group: Members
Posts: 2
Member No.: 37530
Joined: 5-December 13



Hi there!
I recorded two videos today and now I'd like to know, if and how it's possible to open two videos at the same time, so that one video is played at the same time, only smaller and in one corner of the other one.

Here's an example of what I have in mind here:
http://www.qpic.ws/images/vdubvideooverlayzuz.png

Of course, they need to be merged together later.

Thanks in advance!
 
     Top
malky
Posted: Dec 5 2013, 11:15 PM


Advanced Member


Group: Members
Posts: 290
Member No.: 22386
Joined: 6-November 07



Using an Avisynth script.

CODE
main=avisource("C:\Users\Superuser\Desktop\clip.avi").ConvertToYUY2()
pip=avisource("C:\Users\Superuser\Desktop\clip_German3.avi", audio=false).ConvertToYUY2().bicubicresize(120,80)
Layer(main,pip,"add",255,1,1)


user posted image
 
    Top
meowmeow
Posted: Dec 5 2013, 11:17 PM


Advanced Member


Group: Members
Posts: 98
Member No.: 37160
Joined: 21-September 13



prepare both videos
need same framrate, same width x heigh, same codec (Lagarith or anything that is fast and lossless)
same number of frames

second video save with filter: interpolate (x2 frame rate, nearest)
with framerate as for video 1 (video/frame rate/change frame rate to (fps):___)
(that doubles number of frames, making video 2x longer to play)

open first video. append first video again. then append second video.
(Example placing smaller, resized picture 320x180 over 640x360 in top-left corner)
filters: (right-click on filter to add inputs and name filters)

t = convert format (YV12)
f = fill (color: #000000) (x2 offset=320, y2 offset=180)
interpolate (x0.50,nearest) -- input for filter: t
resize ( 320x180 with leterbox (640*2-320) x (360*2-180) )
x = null transform (x1 offset = 320, y1 offset=180)
blend layers (screen 100%) -- inputs f & x

picture:
user posted image

also theres is filter called Video Overlay http://www.trevlac.us/FilterDocs/
 
     Top
raffriff42
Posted: Dec 6 2013, 12:53 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



I would probably do it malky's way, but meowmeow's way interests me.

>t = convert format (YV12)
How is this done? I have not seen named filters before. I am on version 1.10.4.

EDIT never mind: add filter; right-click; name.

EDIT trouble:
"Cannot start filters: An instance of filter "blend layers" cannot process its input of 640x480 (YUV-420ib-709-Fr)
(wha?)
user posted image
 
     Top
raffriff42
Posted: Dec 6 2013, 01:52 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Yeah...ingenious use of filters, but Avisynth is easier & more versatile. No need to dub video or match codecs.
Here's a PIP function with simple positioning options (like Subtitle)
CODE
A=AviSource("A.avi")
B=Colorbars ## for example

## PIP, top right corner
UUPip(A, B, align=9, zoom=0.33)


###############################
### picture-in-picture effect
#
#@param A     - main clip
#@param B     - clip to appear over main; resized (see zoom)
#@param align - insert position, using "numeric keypad" notation)
#                       *---------*
#                       | 7  8  9 |
#                       |         |
#                       | 1  2  3 |
#                       *---------*
#@param zoom - [default=0.5; max = 1.0; min = 0.1]
#
#@version 1.1   01-Aug-2011 raffriff
#
function UUpip(clip A, clip B, int "align", float "zoom")
{
   zoom = Min(Max(0.1, Float(Default(zoom, 0.5))), 1.0)

   inWid = A.Width
   inHgt = A.Height

   pipWid = B.Width
   pipHgt = B.Height

   B = BilinearResize(B, Round(zoom * Float(pipWid)), Round(zoom * Float(pipHgt)))

   ### add borders to all sides
   bdr = 6
   B = AddBorders(B, bdr, bdr, bdr, bdr)

   pipWid = B.Width
   pipHgt = B.Height

   pos = Default(align, 7)

   pos = ((pos==8)||(pos==9)||(pos==3)||(pos==2)||(pos==1)) ? pos : 7

   ### create PIP
   iLeft = Round((pos==9) ? (inWid - pipWid + bdr)
             \ : (pos==8) ? (0.5 * inWid - 0.5 * pipWid)
             \ : (pos==7) ? (-bdr)
             \ : (pos==3) ? (inWid - pipWid + bdr)
             \ : (pos==2) ? (0.5 * inWid - 0.5 * pipWid)
             \ : (pos==1) ? (-bdr)
             \ : 0) # not reached

   iTop  = Round((pos==9) ? (-bdr)
             \ : (pos==8) ? (-bdr)
             \ : (pos==7) ? (-bdr)
             \ : (pos==3) ? (inHgt - pipHgt + bdr)
             \ : (pos==2) ? (inHgt - pipHgt + bdr)
             \ : (pos==1) ? (inHgt - pipHgt + bdr)
             \ : 0) # not reached

   return Overlay(A, B, iLeft, iTop)
}
 
     Top
meowmeow
Posted: Dec 6 2013, 04:46 AM


Advanced Member


Group: Members
Posts: 98
Member No.: 37160
Joined: 21-September 13



QUOTE (raffriff42 @ Dec 6 2013, 12:53 AM)
EDIT trouble:
"Cannot start filters: An instance of filter "blend layers" cannot process its input of 640x480 (YUV-420ib-709-Fr)
(wha?)

480<>360
If try to fix cropping in null transform VD crashes.

meowmeow's trip allows also to blend "fill" & "blend layers" filters to make additional effects using curve editor.
Can make second frame smoothly appear and disappear.

Forgot to tell, the paired video starts at N frame and ends and N*2 frame, where N = number of frames in original.

Yep, its hard to use. Waiting for special filter for the tasks...
 
     Top
AceStorM
Posted: Dec 23 2013, 02:05 PM


Newbie


Group: Members
Posts: 2
Member No.: 37530
Joined: 5-December 13



Sorry for the big delay, but I couldn't find any time to try out the script. Now, I tried malky's way, but I'm getting the following error message:

user posted image
 
     Top
raffriff42
Posted: Dec 23 2013, 08:03 PM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Malky assumed some basic knowledge of Avisynth
* install Avisynth
* in Malky's code, substitute your video paths for the ones in the script
* save code as: plain text, named <something>.avs ("<something>" can be any file name)
* Virtualdub File menu, open, <something>.avs

PS of course you won't get another error, but if you do:
View menu, Log, right-click, Copy
(instead of a screen shot)
 
     Top
meowmeow
Posted: Dec 24 2013, 03:46 AM


Advanced Member


Group: Members
Posts: 98
Member No.: 37160
Joined: 21-September 13



this I found
CODE

#la picture-in-picture AviSynth script with option to blend;
#may use VirtualDub FrameServe to FX; finally fill colour and edit curve for pop-ups

#reception

MainClip="video.avi"
FrameClip="pop_up.avi"
MoveFrameRight=0
MoveFrameDown=0
Blend=false

#file program

A=ConvertToRGB32(AviSource(MainClip,audio=true))
B=ConvertToRGB32(AviSource(FrameClip,audio=false))

#blend options

BlendMode="blend"
# (blend, add, substract, multiply, chroma, luma, lighten,
# darken, softlight, hardlight, difference, exclusion)
MaskColor=$000000
MaskTolerance=0
BlendOpacity=1.0

#overlay program

Blend ? Overlay(A, B, mask=ShowAlpha(ColorKeyMask(B,MaskColor,MaskTolerance)), \
MoveFrameRight, MoveFrameDown, mode=Blendmode, opacity=BlendOpacity) : Overlay(A, B, \
MoveFrameRight, MoveFrameDown, opacity=BlendOpacity)
 
     Top
iceblitzed
Posted: Jan 3 2014, 04:25 AM


Newbie


Group: Members
Posts: 5
Member No.: 37536
Joined: 8-December 13



honestly for simplicity i would just use the video overlay as one user above mentioned

http://www.trevlac.us/FilterDocs/
 
     Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
9 replies since Dec 5 2013, 06:57 PM Track this topic | Email this topic | Print this topic

<< Back to Newbie Questions