Hi,
I'd like to make an avisynth script to encode automaticaly my video to get a kind of zoom mixed with letterbox aspect.
n=number of frames
the initial script isn't the point; let's start with this simple script :
v = dss2("vid.ts", fps=25)
a = DirectShowSource("vid.ts", video=False)
AudioDub(v,a)
Frame Sart (frame 0)
video occupies full player screen like this :
I frame 0 >> frame 60
video dimension is smoothly shifting to letterbox aspect
II frame 60 >> frame n-60
v = dss2("vid.ts", fps=25)
a = DirectShowSource("vid.ts", video=False)
AudioDub(v,a)
vid=LanczosResize(last,500,280)
vid=AddBorders(vid,70,40,70,40)
return vid
III frame n-60 to frame n
video smoothly return to initial dimension and will look again like this :
The crucial parts I'd like to get some help are I & III
Thanks,
Sorry for my bad english
+ Reply to Thread
Results 1 to 7 of 7
-
-
It's easier to do in a NLE, but you can try something like animate() in avisynth
http://avisynth.org/mediawiki/Animate
eg. maybe this will give you ideas, just adjust to however you want (replace colorbars with your clip, adjust the dimensions)
Code:clip = colorbars clip = clip.BicubicResize(640,360) clip = clip.ConvertToRGB() black = BlankClip(clip) resize(black, clip, 101, 640, 360, 200, 480, 272, clip.width/2, clip.height/2) trim(0,200) a=last resize(black, clip, 0, 480, 272, 100, 640, 360, clip.width/2, clip.height/2) trim(0,100) b=last a++b function res(clip clip, clip "LClip", int "width", int "height", int "centerX", int "centerY") { LClip = BicubicResize(LClip, width, height) Overlay(clip, LClip, centerX-LClip.width/2, centerY-LClip.height/2) } function resize(clip clip, clip "LClip", int "start_frame", int "start_width", int "start_height", \ int "end_frame", int "end_width", int "end_height", int "centerX", int "centerY") { return Animate(start_frame, end_frame, "res", clip, LClip, start_width, start_height, centerX, centerY, \ clip, LClip, end_width, end_height, centerX, centerY) }
-
That's great poisondeathray,
Maybe, my script could be more simple; here's the result :
Code:v = dss2("vid.ts", fps=25) a = DirectShowSource("vid.ts", video=False) AudioDub(v,a).ConvertToRGB32 #dss2trim("vid.ts") # Trim de sécurité dss2 trim(22723, 30475) fc = FrameCount clip =last black = BlankClip(clip) n = 20 resize(black, clip, 0, 640, 360,n, 500, 280, clip.width/2, clip.height/2) trim(0,n) a=last LanczosResize(clip,500,280).AddBorders(70,40,70,40) trim (n,fc-50) b=last resize(black, clip,fc-n, 500, 280, fc, 640, 360, clip.width/2, clip.height/2) trim(fc-n,fc) c=last a ++ b ++ c function res(clip clip, clip "LClip", int "width", int "height", int "centerX", int "centerY") { LClip = BicubicResize(LClip, width, height) Overlay(clip, LClip, centerX-LClip.width/2, centerY-LClip.height/2) } function resize(clip clip, clip "LClip", int "start_frame", int "start_width", int "start_height", \ int "end_frame", int "end_width", int "end_height", int "centerX", int "centerY") { return Animate(start_frame, end_frame, "res", clip, LClip, start_width, start_height, centerX, centerY, \ clip, LClip, end_width, end_height, centerX, centerY) }
Last edited by kaskaï; 17th Jun 2013 at 09:50.
-
Hi,
Something strange with the audio at the very beginning and at the end of my test video (see attached test.avi).
I can't fix it. Maybe it's obvious for you to see where is the mistake in this code :
Code:Import("G:\doc\PortableApps\AvsGen\templates\plugins\dss2trim.avsi") ## Source v = dss2("I:\Atelier\lang.mp4", fps=25) a = DirectShowSource("I:\Atelier\lang.mp4", video=False) AudioDub(v,a) dss2trim("I:\Atelier\jack.mp4") # Trim de sécurité dss2 #trim trim(22753,23981) ConvertToRGB32.LanczosResize(640,360) fc = FrameCount clip =last black = BlankClip(clip) n = 57 resize(black, clip, 50, 640, 360, n, 500, 280, clip.width/2, clip.height/2) trim(0,n) a=last LanczosResize(clip,500,280).AddBorders(70,40,70,40) trim (n,fc-50) b=last resize(black, clip,fc-n, 500, 280, fc-50, 640, 360, clip.width/2, clip.height/2) trim(fc-n,fc) c=last vid = a ++ b ++ c return vid function res(clip clip, clip "LClip", int "width", int "height", int "centerX", int "centerY") { LClip = BicubicResize(LClip, width, height) Overlay(clip, LClip, centerX-LClip.width/2, centerY-LClip.height/2) } function resize(clip clip, clip "LClip", int "start_frame", int "start_width", int "start_height", \ int "end_frame", int "end_width", int "end_height", int "centerX", int "centerY") { return Animate(start_frame, end_frame, "res", clip, LClip, start_width, start_height, centerX, centerY, \ clip, LClip, end_width, end_height, centerX, centerY) }
Last edited by kaskaï; 17th Jun 2013 at 09:49.
-
It might have to do with VBR audio and trimming . Try loading audio with FFAudioSource() instead of DirectShowSource
a = FFAudioSource("I:\Atelier\lang.mp4")
You can also add EnsureVBRMP3Sync() before the trimming (doesn't matter if audio is MP3 or AAC or something else)
http://avisynth.org/mediawiki/EnsureVBRMP3Sync
What function is dss2trim.avsi ? It's not commented out this time -
Let's forget the type of vid (mp4 is just taken for an example)
I think the point is audiodub in part a and part c
So I tried to replace this line
Code:resize(black, clip, 50, 640, 360, n, 500, 280, clip.width/2, clip.height/2) trim(0,n) a=last
Code:audiodub(resize(black, clip, 50, 640, 360, n, 500, 280, clip.width/2, clip.height/2),a) trim(0,n) a=last
I think i'm closer ...
What function is dss2trim.avsi ? It's not commented out this time
EDIT :
I've no idea what's exactly the aim of this avsi :
Code:# FFmpegSource 1.21 syntax compatibility # Created by TheFluff function FFmpegSource2(string source, int "vtrack", int "atrack", bool "cache", \ string "cachefile", int "fpsnum", int "fpsden", string "pp", int "threads", \ string "timecodes", int "seekmode", bool "overwrite", int "width", int "height", \ string "resizer", string "colorspace", int "rffmode", int "adjustdelay") { vtrack = default(vtrack,-1) atrack = default(atrack,-2) cache = default(cache,true) cachefile = default(cachefile,source+".ffindex") fpsnum = default(fpsnum,-1) fpsden = default(fpsden,1) pp = default(pp,"") threads = default(threads,-1) timecodes = default(timecodes,"") seekmode = default(seekmode,1) overwrite = default(overwrite,false) width = default(width,-1) height = default(height,-1) resizer = default(resizer,"BICUBIC") colorspace = default(colorspace,"") rffmode = default(rffmode,0) adjustdelay = default(adjustdelay,-1) ((cache == true) && (atrack <= -2)) ? ffindex(source=source, cachefile=cachefile, \ indexmask=0, overwrite=overwrite) : (cache == true) ? ffindex(source=source, \ cachefile=cachefile, indexmask=-1, overwrite=overwrite) : nop v = ffvideosource(source=source, track=vtrack, cache=cache, cachefile=cachefile, \ fpsnum=fpsnum, fpsden=fpsden, pp=pp, threads=threads, timecodes=timecodes, \ seekmode=seekmode, rffmode=rffmode, width=width, height=height, resizer=resizer, \ colorspace=colorspace) a = (atrack <= -2) ? blankclip(audio_rate=0) : ffaudiosource(source=source, \ track=atrack, cache=cache, cachefile=cachefile, adjustdelay=adjustdelay) return audiodubex(v,a) } function FFImageSource(string source, int "width", int "height", string "resizer", string "colorspace") { width = default(width,-1) height = default(height,-1) resizer = default(resizer,"BICUBIC") colorspace = default(colorspace,"") return FFVideoSource(source, cache=false, seekmode=-1, width=width, height=height, resizer=resizer, colorspace=colorspace) } function FFCopyrightInfringement(string source) { ################################################################ # Violates copyright # * With audio # * No annoying lawyers # * Simple syntax # * Do not use on Britney Spears' music videos or sex tapes # # And whatever you do: # DO NOT TELL NEURON2 THAT YOU USED THIS FUNCTION ################################################################ FFIndex(source=source) return audiodubex(FFVideoSource(source=source), FFAudioSource(source=source)) } function FFFormatTime(int ms) { s = ms / 1000 ms = ms % 1000 m = s / 60 s = s % 60 h = m / 60 m = m % 60 return string(h) + ":" + string(m,"%02.0f") + ":" + string(s,"%02.0f") + "." + string(ms,"%03.0f") } function FFInfo(clip c, bool "framenum", bool "frametype", bool "cfrtime", bool "vfrtime") { framenum = default(framenum,true) frametype = default(frametype,true) cfrtime = default(cfrtime,true) vfrtime = default(vfrtime,true) global fftempclip = c fftempclip = frameevaluate(fftempclip, """ fftempstring = "" """) fftempclip = framenum ? frameevaluate(fftempclip, """fftempstring = fftempstring + "Frame Number: " + string(current_frame) + " of " + string(fftempclip.framecount) + "\n" """, after_frame=true) : fftempclip fftempclip = frametype ? frameevaluate(fftempclip, """fftempstring = fftempstring + "Picture Type: " + chr(FFPICT_TYPE) + "\n" """, after_frame=true) : fftempclip fftempclip = cfrtime ? frameevaluate(fftempclip, """fftempstring = fftempstring + "CFR Time: " + FFFormatTime(int((current_frame * 1000) / fftempclip.framerate)) + "\n" """, after_frame=true) : fftempclip fftempclip = vfrtime ? frameevaluate(fftempclip, """fftempstring = fftempstring + "VFR Time: " + FFFormatTime(FFVFR_TIME) + "\n" """, after_frame=true) : fftempclip return scriptclip(fftempclip, "subtitle(fftempclip, fftempstring, lsp = 1)", after_frame=true) }
Last edited by kaskaï; 17th Jun 2013 at 11:34.
-
These lines are fine for the job :
Code:resize(black, clip, 50, 500, 280, n, 640, 360, clip.width/2, clip.height/2) audiodub(last,clip).trim(0,n) a=last
Similar Threads
-
Avisynth subtitle() + zoom + overlay, is there any simpler way to do this?
By gzaloprgm in forum EditingReplies: 2Last Post: 22nd May 2012, 07:10 -
How do I zoom out and move picture with avisynth
By xicudiz in forum EditingReplies: 6Last Post: 31st Mar 2011, 17:28 -
Need Help with My AviSynth Script
By Enkidu in forum Newbie / General discussionsReplies: 3Last Post: 21st Jan 2011, 21:37 -
Avisynth Script Help
By jamhat in forum Video ConversionReplies: 2Last Post: 29th Nov 2009, 06:13 -
Avisynth script
By daz2712 in forum Video ConversionReplies: 2Last Post: 19th Aug 2009, 11:08