View Single Post
Old 5th April 2020, 14:16   #1  |  Link
PerDeConf
Registered User
 
Join Date: Dec 2017
Posts: 4
Append a still image respecting aspect ratio and possibly adding borders

I'm looking to append a still image to a video clip.
I found an old thread that deals with this issue.
Unfortunately I'm facing distortion problems and can't adapt the script.

Gavino mentioned at the time that this script should be improved...

Quote:
the photo is narrower than the video. When the photo is wider, you want to add borders on the top and bottom instead of the sides
Depending on the initial size of the video, the image is exaggeratedly distorted making its content unreadable.

Can someone show me the way because abstraction is not my strong point? (such scripts probably already exist)



Code:
v=DirectShowSource("F:\Vidéos\Enfants\Minuscule\gay-minus.avi")




pic="D:\pic\screenshot_395.png"
t=10 #[time in sec]
fc=Round(t*FrameRate(v)) #frame count

####################################################
# Option Zoom
d=20 # start zooming
n = 50 # no of frames for still
endzoom = 4.0
####################################################

ImageSource(pic).ConvertToRGB32()
AssumeFPS(v).Loop().Trim(0,fc-1)
#~ Animate(last, d, 119, "SimpleZoomBox", 1.0, 0, 0, endzoom, (endzoom * -0.10), (endzoom * 0.9))      # Option Zoom
AudioDub(BlankClip(v, length=t))
fv=last # frozen vid

vasr=float(v.Height)/float(v.Width) #video aspect ratio
pasr=float(fv.Height)/float(fv.Width) #picture aspect ratio
nW=INT(fv.Width*(pasr*vasr)) #new Width
xx=(v.Width-nW) #sum of the lateral borders
Spline36Resize(nW, v.Height).AddBorders(xx/2,0,xx/2,0)

#~ ConvertToYV12()

#~ v ++ last  #joining both clips
last #only for picture clip
PerDeConf is offline   Reply With Quote