View Full Version : Good Practices Question: Simple Video, Audio, Photos
tacman1123
19th May 2008, 18:47
What's a good way to achieve the relatively simple sequence
* video starts, with sound
* cut to a picture, keep the voiceover from the video
My first attempt is:
a=DirectShowSource("video.avi")
img = ImageSource("picture.jpg")
AudioDub(a.Trim(0, 50) + img.Loop(50), a)
But that gives a Splice error, since you can't mix clips with and without audio.
So I reorder things to
a.Trim(0, 50) + img.Loop(50).AudioDub(a.Trim(50, 100))
Now the VideoFormats are incorrect, so I take a wild stab and append a YUY2 converter to each, and adjust the framerate, until I get to:
a.Trim(0, 50).ConvertToYUY2() + img.Loop(50).AudioDub(a.Trim(50, 100)).ConvertToYUY2().AssumeFPS(a)
which works.
My question is about good practices -- is this a good way to code a video followed by a photo with voiceover? The YUY2 is a stab based on looking at other code samples, which all seem to have lots of conversions and frame rate adjustments.
Anyway, I'm jazzed that this works, hopefully it'll be useful to someone else needing this, and if any of the experts on this forum could suggest better ways to do this, it'd be much appreciated.
Tac
gzarkadas
19th May 2008, 22:29
You could do something like this (beware, I have not tested it) and avoid the conversion of a to YUY2, since it is most probably YV12 (also results in shorter lines of code):
a = DirectShowSource(...)
img = ImageSource(...).Loop(a.Framecount).ConvertToYV12()
img = AudioDub(img, a)
a.Trim(0, 50) + img.Trim(51, 100)
This gives you also the ability to use Dissolve for a smoother transition in the last line
Dissolve(a.Trim(0, 50), img.Trim(51, 100), 10)
And it is easier if you want to insert a picture in the middle (say if a.Framecount == 201, at the last line again):
a.Trim(0, 50) + img.Trim(51, 100) + a.Trim(101, 200)
--or--
Dissolve(a.Trim(0, 50), img.Trim(51, 100), a.Trim(101, 200), 10)
tacman1123
19th May 2008, 23:00
Thanks, indeed my next steps involve dissolve and other things, and I know avoiding color space conversions is a good thing.
Is there some equivalent to AssumeFPS like AssumeColorSpace(clip)? The code you suggested isn't working, but probably one of the conversions will. The "pixel type" of the video is yuv411p (captured with a Canon DV Camcorder), but aligning it with a clip that's been created with ConvertToYV12() fails with "Video Formats Don't Match". So I'm trying to figure out what the call should be to convert the image to the same video format as the avi.
Thanks for any suggestions. Color spaces and FrameRate are definitely the biggest hurdles to get over.
Tac
Gavino
20th May 2008, 01:04
img = ImageSource(...).Loop(a.Framecount).ConvertToYV12()
I've seen this construct (ImageSource followed by Loop) in several posts recently and it seems wrong to me.
By default, ImageSource produces a clip of 1001(!) frames, so surely you need to explicitly set end=0 in ImageSource, or else just set end=frameCount-1 and remove the Loop altogether?
It doesn't actually matter here because you end up trimming the result anyway, but tacman1123's original solution (img.Loop(50)) produces a clip of over 50000 frames when he was probably expecting 50.
gzarkadas
20th May 2008, 22:01
I've seen this construct (ImageSource followed by Loop) in several posts recently and it seems wrong to me.
By default, ImageSource produces a clip of 1001(!) frames, so surely you need to explicitly set end=0 in ImageSource, or else just set end=frameCount-1 and remove the Loop altogether?
It doesn't actually matter here because you end up trimming the result anyway, but tacman1123's original solution (img.Loop(50)) produces a clip of over 50000 frames when he was probably expecting 50.
Well, it is wrong without the things you mention, but I didn't actually deal with it (hence the three dots inside the call) because it wasn't the main issue of the first post; just copied from the example.
tacman1123
20th May 2008, 22:10
Thanks for pointing that out! I wonder which is better, letting the clip stay at 1000 frames or trimming it. I'm guessing that there's no reason to trim it, but indeed I had thought that imageSource loaded a single frame.
I'm still not sure which ColorSpace to use. Would one choose a color space based on output? For example, right now I have a bunch of clips (interviews) made with my Canon ZR500. One set of clips needs to go on a DVD, and other set I'd like to put into flv so they can be streamed to Flash (or mpegs, and streamed with Wowza to a flash client). Should I be choosing one Color Space over another based on the output? How about framerate? Should I stick with that framerate (that's what the camera uses) if the output is going to DVD (North America), or can I switch to 25 fps and am some sanity when I'm dealing with converting to time?
Thanks for any advice and suggestions!
Tac
gzarkadas
20th May 2008, 22:33
...Is there some equivalent to AssumeFPS like AssumeColorSpace(clip)?...
No, you just have to use one of the ConvertTo... methods; see the Convert (http://avisynth.org/mediawiki/Convert) page in Avisynth wiki for details.
...The code you suggested isn't working, but probably one of the conversions will. The "pixel type" of the video is yuv411p (captured with a Canon DV Camcorder), but aligning it with a clip that's been created with ConvertToYV12() fails with "Video Formats Don't Match". So I'm trying to figure out what the call should be to convert the image to the same video format as the avi...
Yes, since your imput format is YV411 and not YV12, as I assumed, it doesn't. Your options are:
1. Use an extra argument pixel_type="yv12" in the DirectShowSource call to convert your clip to the closest format that Avisynth up to v2.58 supports. Then the code I posted should, hopefully, work.
2. Get Avisynth 2.6, which as the documentation states supports yv411 and use the ConvertToYV411 function in the script example instead of ConvertToYV12.
Now, this is not exactly an easy task since there isn't an official 2.6 build; one is reported at this thread (http://forum.doom9.org/showthread.php?t=135333) but its quality is questioned. To get a 2.6 build you will either have to search for it (maybe someone is kind enough to post a link here :)) or get the code from Avisynth CVS and build one your own.
gzarkadas
20th May 2008, 22:46
...I'm still not sure which ColorSpace to use. Would one choose a color space based on output? ... How about framerate? ...
In general it is best to avoid colorspace and framerate conversions as much as you can, because you loose information (ie video quality) in the process.
IMHO you should input your video into your script in its native colorspace (or the closest one supported by your version of AviSynth), process it in that colospace and leave it as is. Let the encoder decide if it needs to make a conversion. If you need to convert fps, do it as the last step of your script.
mikeytown2
21st May 2008, 09:11
My first attempt at using AviSynth as a NLE (http://en.wikipedia.org/wiki/Non-linear_editing_system) was successful (2.5 hrs down to 4 min with voice over; 662 lines of code, 2 camera's of different formats/frame rates, and lots of pics). If you are not using an IDE (http://en.wikipedia.org/wiki/Integrated_development_environment) like AvsP, then i highly recommend you use AvsP (http://avisynth.org/qwerpoi/).
Some of my tricks that i used
Set some Global Variables to keep track of my output, and have output auto convert to it, because it's going to happen anyway in the end; do it after video processing(denoise, ect...). Except for frame rate, do this after your trims!
Global W = 640
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
Global Resizer = "BlackmanResize"
Global Blank = BlankClip(1, W, H, "YV12", F, stereo=true, audio_rate=R).Loop()
The code that i used heavily was my ZoomBox (http://forum.doom9.org/showthread.php?p=1111789#post1111789) code, as a resizer. You can center, and resize the clip without much thought. It will take into account the PAR/DAR of a clip as well by "converting" it to square pixels. So When i loaded my source this is what i used
Global HDV = AudioDub(MPEG2Source("01-03.d2v").AssumeTFF(), MPASource("01-03 MPA PID 814 DELAY 3ms.mpa")).AssumeTFF()
Global HDV_Full = HDV.TDeint().ZoomBox(W, H, Resizer, DisplayAR=1920.0/1080.0, Align=-5 )
Global HDV_Full_Crop = HDV.TDeint().ZoomBox(W, H, Resizer, DisplayAR=1920.0/1080.0, Align=5 )
Global HDV_Fast = HDV.SeparateFields().SelectEven().ZoomBox(W, H, Resizer, DisplayAR=1920.0/1080.0, Align=-5 )
Global HDV_Fast_Crop = HDV.SeparateFields().SelectEven().ZoomBox(W, H, Resizer, DisplayAR=1920.0/1080.0, Align=5 )
Global CStart = AVISource("Cold vid3.avi").ZoomBox(W, H, Resizer, DisplayAR=1920.0/1080.0, Align=5 ).ConvertToYV12()
When loading audio, I gave it a video track. All my audio tracks where stereo. I also set the frame rate to 4x ntsc so trimming of my audio was more precise, not sure if i would do 4x again...
Global VoiceOver = WAVSource("5-17-08.wav").SSRC(R)
Global VoiceOver = AudioDub(Blank.AssumeFPS("ntsc_quad"), VoiceOver)
Made a function with a description for each clip that i wanted.
Function Moving3()
{
HDV_Full_Crop
Trim(266210,266900)
}
Function ColdestS()
{
CStart
Trim(220, 520)
ConvertFPS(F)
}
For pictures, i found that using loop() seemed to be faster... still not sure. This is what i did.
Function IntroPicA()
{
ImageReader("2.jpg",0,0).AssumeFPS(F).Loop(Round(F*5))
KenBurnsEffect(last, 930, 0, 3300, 0, 0, 0, 3300, 0, W, H, 4, useZoomBox=2, ResizeMethod=Resizer)
ConvertToYV12()
AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
}
Sound editing was done by playing the clip with AudioGraph() in virtual dub. Once i found the correct frames to trim i made a function to host them
Function SndThanks()
{
VoiceOver
Trim(32050,34400)
}
Putting it all together. I use a call to BlankClip to pad the audio if needed (remember, the audio has a "blank" video track as well!).
Function Part7()
{
TUp().Normalize(0.90)
Dissolve(last, Moving3())
v=last
SndTUp1VoiceOver().Normalize(0.90)
last ++ BlankClip(last, 700)
last ++ SndTUp2VoiceOver().Normalize(0.90)
last ++ SndMoveTVoiceOver().Normalize(0.90)
a = last
a=MixAudio(v,a,0.15,0.85)
AudioDub(v,a).Normalize(0.90)
}
Combine all parts and save file
Part1().FadeIn(10)
Dissolve(last, Part2(), 5)
Dissolve(last, Part3(), 5)
Dissolve(last, Part4(), 5)
Dissolve(last, Part5(), 5)
Dissolve(last, Part6(), 5)
Dissolve(last, Part7(), 5)
Dissolve(last, Part8(), 5)
Good luck, for complicated projects, it is not easy, but you do have total control over it. Go easy with Normalize, it can slow the start of a clip down by a couple of mins. The audio was a little buggy. Sometimes it would crash VirtualDub, sometimes it wouldn't. For you i wouldn't worry about the audio crashing, i don't think you are doing what i did. I hope this answers your question, this is what worked for me when editing a video over a long period of time, and being able to change the FrameSize and Aspect Ratio very easily.
My question is about good practices
Not sure if what i did is considered "good practices", but it did work for me.
About colorspace, if your compressing the video, in the end, i would pick YV12
tacman1123
21st May 2008, 12:34
My response to this either disappeared or didn't make it, so I'll try again.
First, thanks for those suggestions, which I'm still digesting. And thank you for your work with the KenBurnsEffect script -- a wonderful addition to AviScript (and I see that it's been recently updated).
Is your 4.5 minute final video available on online (e.g. youtube)? I'd love to see the final product, and a link from there to the 662 lines of code would be a great example of how to use AviSynth to create a short film, if you'd be willing to share the full code. I know several of us are trying to script entire videos, with varying degrees of success. I'd love to see an AviSynth script that could generate a Ken-Burns type documentary (or a mockumentary in KB style, such as Negro Space Programme - A Ken Burns Parody (http://www.youtube.com/watch?v=lxjV74pfevA)). Is there anything that AviSynth can't do to create that movie? I'm guessing that the titles and other text would be difficult to re-create, but all the other elements (music, voiceover, photos, videos, transitions) should be completely reproducible, yes?
Tac
mikeytown2
21st May 2008, 19:17
Is your 4.5 minute final video available on online (e.g. youtube)? I'd love to see the final product, and a link from there to the 662 lines of code would be a great example of how to use AviSynth to create a short film, if you'd be willing to share the full code. I know several of us are trying to script entire videos, with varying degrees of success. I'd love to see an AviSynth script that could generate a Ken-Burns type documentary (or a mockumentary in KB style, such as Negro Space Programme - A Ken Burns Parody (http://www.youtube.com/watch?v=lxjV74pfevA)). Is there anything that AviSynth can't do to create that movie? I'm guessing that the titles and other text would be difficult to re-create, but all the other elements (music, voiceover, photos, videos, transitions) should be completely reproducible, yes?
Tac
The video is not online yet... it still needs a little bit more work (i'm going to use deshaker for 4 sections of it). I will put it online, and i'll post the code here, if it fits, once the video is up.
That mockumentary is funny. Everything i saw, u can do in AviSynth. Even the titles, you can do, but i haven't seen any good examples in AviSynth of people using titles. Creating a function for each block of text, then using layers (http://avisynth.org/mediawiki/Layer), would probably be the way to do it. Scrolling text/credits could be done by using KBE on a very tall clip. So text is very doable, just no one has done it yet. I would start here http://avisynth.org/mediawiki/External_filters#Subtitling, http://avisynth.org/mediawiki/Subtitle, http://avisynth.org/mediawiki/ConditionalReader
tacman1123
21st May 2008, 20:02
SubtitleEx is an absolute necessity for accented characters, plus has a whole bunch of other features.
I've been toying with how to collect useful "samples" along with their outputs (probably in flash), just to have snippets to see how they work. Like an AviSynth cookbook.
Even doing something simple, like "pan from left to right" would be worthwhile. I put together a function that adds a 2-line caption, with a faint background to provide contrast, so that I could quickly add a name and title. I did another one that was a video followed by a photo with continued voice-over narration. Although I'm sure these things are simple to you, as a newbie it took me longer than I'd care to admit to develop.
Tac
PS Looking forward to seeing the video and code, even with the shake!
mikeytown2
21st May 2008, 21:14
tacman1123
Good find with SubtitleEx I added some info to the wiki. I can't find a home page for it though, so one of the links, in the wiki, is to the helpfile download.
I try to develop what i find useful on the wiki; if your collecting info, you might want to add it to the wiki as well.
Gavino
21st May 2008, 21:57
For pictures, i found that using loop() seemed to be faster... still not sure.
In principle, there should be no performance difference between
ImageSource("xxx.jpg", end=0).Loop(n)
and
ImageSource("xxx.jpg", end=n-1)
at least since ImageSource (http://avisynth.org/mediawiki/ImageSource) was optimised for single images in v2.56.
However, one place it definitely makes sense to use Loop is when you have a filter chain applied to the resulting clip, in which case the Loop should come at the very end of the chain. Eg
ImageSource("xxx.jpg", end=0).SomeSlowFilter().Loop(n)
ensures that SomeSlowFilter is applied to one frame rather than to n identical frames.
mikeytown2
21st May 2008, 22:22
Try this example (http://forum.doom9.org/showthread.php?p=1138231#post1138231), with and without the loop. i found that even though the loop is before the resize, it still made a difference. It's a very rare case. In vdub i go from 18 fps to about 27fps.
Edit, that example could be caused from the BilinearResize... Gavino is correct with the putting the loop after. it makes it go much faster!
tacman1123
21st May 2008, 22:24
Speaking of ImageSource, what's the best way to simply import an image and make it "fit" with whatever the dimensions are of the current clip. In a typical slideshow application, images are rescaled to fit, centering the rescaled image and putting black borders on either the top and bottom or right and left.
I looked at the .avs generated by DVD Slideshow, but it appears that the images are prepared and saved as ebmp's all in the proper size as part of the export process. I keep thinking that this should be pretty straightforward (load up a bunch of photos, display them for 3 seconds each...).
I'm still trying to wrap my mind around the coordinate system to use for the KenBurnsEffect, and getting use to the long list of numbers in the parameters.
Thanks for all the sample code, it's been very helpful.
Tac
mikeytown2
21st May 2008, 22:31
Speaking of ImageSource, what's the best way to simply import an image and make it "fit" with whatever the dimensions are of the current clip.
Use of zoombox
No black border example:
ImageReader("92.JPG",0,0).AssumeFPS(F)
ZoomBox(W, H, ResizeMethod=Resizer, Align=5).Loop(Round(F*3))
ConvertToYV12()
black border example:
ImageReader("92.JPG",0,0).AssumeFPS(F)
ZoomBox(W, H, ResizeMethod=Resizer, Align=-5).Loop(Round(F*3))
ConvertToYV12()
I'm still trying to wrap my mind around the coordinate system to use for the KenBurnsEffect, and getting use to the long list of numbers in the parameters.
KBE/ZB is still being developed, I'm working on ways to eliminate the # of parameters passed. Making it easier to use is one of my main goals.
mikeytown2
22nd May 2008, 23:19
I had to remove my VideoAll() and SoundAll() functions to make it fit. Here is the whole script. The ColdStart avi is from a 640x480 10fps video from a point and shoot camera. The rest of the footage comes from my HDV cam. The script is setup for 720x480 for 16/9 DVD output (anamorphic widescreen). Change the width/height/AR, and it comes out looking great. This is about 40GB of data, so i don't think i will upload the raw footage. Output from this script is here
H.264 - 320x240: http://www.mediafire.com/?jfpg44eriz9
LoadPlugin("immaavs.dll")
SetMemoryMax(768)
Global W = 320
Global H = 240
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global D = 0
Global R = 48000
Global PicLen = Round(F*5)
Global Resizer = "BlackmanResize"
Global Div = 4.0
Global HDV_DAR = 1920.0/1080.0
Global Target_DAR = 0
Global S = 0.5
Global HDV = AudioDub(MPEG2Source("01-03.d2v").AssumeTFF(), MPASource("01-03 MPA PID 814 DELAY 3ms.mpa")).AssumeTFF()
Global HDV_Full = HDV.TDeint().ZoomBox(W, H, Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR)
Global HDV_Full_Crop = HDV.TDeint().ZoomBox(W, H, Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR, align=5)
Global HDV_Fast = HDV.SeparateFields().SelectEven().ZoomBox(W, H, Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR)
Global HDV_Fast_Crop = HDV.SeparateFields().SelectEven().ZoomBox(W, H, Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR, align=5)
Global ColdStart = AVISource("Cold vid3.avi").ZoomBox(W, H, Resizer, TargetDAR=Target_DAR, Align=5)
Global HDV_Full_Crop_FuelPour = AVISource("FuelPourCloseUpDeshaked.avi").AssumeTFF().TDeint().ZoomBox(W, H, Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR, align=5)
Global HDV_Full_Crop_OilPour = AVISource("OilPourCloseUpDeshaked.avi").AssumeTFF().TDeint().ZoomBox(W, H, Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR, align=5)
Global HDV_Full_Crop_ThrottleUp = AVISource("ThrottleUpDeshaked.avi").AssumeTFF().TDeint().ZoomBox(W, H, Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR, align=5)
Global Blank = BlankClip(30, W, H, "YV12", F, stereo=true, audio_rate=R).Trim(0,-1).DeleteFrame(0)
Global BlankPic = BlankClip(1, W, H, "RGB32", F, stereo=true, audio_rate=R).Loop()
Global VoiceOver = WAVSource("Train 5-17-08.wav")
Global VoiceOver = AudioDub(BlankPic.AssumeFPS("ntsc_quad"), VoiceOver)
Global HDV_Full_Crop = HDV_Fast_Crop
Part1().FadeIn(10)
Dissolve(last, Part2(), 5)
Dissolve(last, Part3(), 5)
Dissolve(last, Part4(), 5)
Dissolve(last, Part5(), 5)
Dissolve(last, Part6(), 5)
Dissolve(last, Part7(), 5)
Dissolve(last, Part8(), 5).FadeOut(20)
##Final##
Function Part1()
{
IntroPicA()
last ++ IntroPicB()
last ++ CiRail()
last ++ TrainPicsB()
last ++ TrainPicsC()
last ++ TrainPicsD()
last ++ TrainPicsA()
v=last
IntroPicA()
Dissolve(last,IntroPicB(), 10)
Dissolve(last,CiRail(), 10)
Dissolve(last,TrainPicsB(), 10)
Dissolve(last,TrainPicsC(), 10)
Dissolve(last,TrainPicsD(), 10)
Dissolve(last,TrainPicsA(), 10)
v=last
SndIntro()
last ++ SndCIRInvite()
last ++ SndEngineDis()
last ++ BlankAudio(last, 10)
a=last.SSRC(R)
AudioDub(v,a)
}
Function Part2()
{
TrainStart().Trim(0,500).Normalize(0.90)
v=last
BlankAudio(SndTrainStart(), 10)
last ++ SndTrainStart()
a=last.SSRC(R)
a=MixAudio(v,a,0.35,0.65)
AudioDub(v,a)#
}
Function Part3()
{
CloseUpOilPour().Trim(0,135)
last ++ CloseUpFuelPour()
last ++ OilFuelPour().Trim(140,0)
last ++ DirtyTrain4()
v = last
CloseUpOilPour().Trim(0,135)
Dissolve(last,CloseUpFuelPour(), 10)
Dissolve(last,OilFuelPour().Trim(140,0), 10)
Dissolve(last,DirtyTrain4(), 10)
v = last
SndTreatment()
last ++ SndUnderTreatment()
a = last.SSRC(R)
AudioDub(v,a)
}
Function Part4()
{
DirtyTrain7()
Dissolve(last,DirtyTrain1A(),30)
Dissolve(last,DirtyTrain1B(),5)
v = last
SndDirty()
a = last.SSRC(R)
AudioDub(v,a)
}
Function Part5()
{
TrainMoving1()
Dissolve(last,TrainMoving2().Trim(100,0), 10)
v=last
SndResults()
a = last.SSRC(R)
AudioDub(v,a)
}
Function Part6()
{
NewTone().Normalize(0.90)
v=last
SndNewTone1()
last ++ BlankAudio(last, 1500)
last ++ SndNewTone2()
a = last.SSRC(R)
a=MixAudio(v,a,0.15,0.85)
AudioDub(v,a)
}
Function Part7()
{
ThrottleUp()
Dissolve(last, TrainMoving3(), 5)
v=last
SndThrottleUp1()
last ++ BlankAudio(last, 700)
last ++ SndThrottleUp2()
last ++ SndMoveTrain()
a = last.SSRC(R)
a=MixAudio(v,a,0.15,0.85)
AudioDub(v,a)
}
Function Part8()
{
ColdestStart().Normalize(0.90)
Dissolve(last,ColdestFullThrottle(),30).Normalize(0.90)
v = last
SndColdStart1()
last ++ SndColdStart2()
last ++ SndColdStart3()
last ++ SndColdStart4()
last ++ SndColdStart5()
last ++ SndColdStart6()
last ++ SndColdStart7()
last ++ SndColdStart8()
last ++ SndThanks()
a = last.SSRC(R)
a=MixAudio(v,a,0.15,0.85)
AudioDub(v,a)
}
##VIDEO##
Function IntroPicA()
{
ImageReader("deisel main_treat sheet-2.jpg",0,0, pixel_type="RGB32").AssumeFPS(F).Loop(Round(F*5))
KenBurnsEffect(startAlign=3, startZoomFactor=250, endAlign=8, width=W, height=H, useZoomBox=0, targetDAR=Target_DAR, ResizeMethod=Resizer, cubic=1, speed=S)
ConvertToYV12()
}
Function IntroPicB()
{
ImageReader("deisel fuel treat sheet-1.jpg",0,0).AssumeFPS(F).Loop(Round(F*6))
KenBurnsEffect(startAlign=4, startZoomFactor=150, endAlign=-5, endZoomFactor=110, width=W, height=H, ResizeMethod=Resizer, targetDAR=Target_DAR)
ConvertToYV12()
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
#Old
}
Function CiRail()
{
HDV.TDeint()
Trim(620,770)
ConvertToRGB("PC.709")
KenBurnsEffect(startAlign=5, endX1=200, endY1=300, endY2=-370, endAlign=4, width=W, height=H, ResizeMethod=Resizer, SourceDAR=HDV_DAR, targetDAR=Target_DAR, useZoomBox=0, cubic=1, speed=S)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
ConvertToYV12()
KillAudio()
}
Function TrainPicsA()
{
ImageReader("Stil\DSCN1103.JPG",0,0).AssumeFPS(F).Loop(Round(F*4))
KenBurnsEffect(startX1=0, startY1=200, startX2=1950, endX1=700, endY1=230, endX2=2050, width=W, height=H, ResizeMethod=Resizer, targetDAR=Target_DAR)
ConvertToYV12()
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
}
Function TrainPicsB()
{
ImageReader("Stil\DSCN1091.JPG",0,0).AssumeFPS(F).Loop(Round(F*5))
KenBurnsEffect(startAlign=5, endAlign=1, endZoomFactor=115, width=W, height=H, ResizeMethod=Resizer, targetDAR=Target_DAR)
ConvertToYV12()
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
}
Function TrainPicsC()
{
ImageReader("Stil\DSCN1097.JPG",0,0).AssumeFPS(F).Loop(Round(F*6.5))
KenBurnsEffect(startX1=660, startY1=280, startX2=2040, endAlign=5, width=W, height=H, ResizeMethod=Resizer, targetDAR=Target_DAR)
ConvertToYV12()
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
}
Function TrainPicsD()
{
ImageReader("Stil\DSCN1100.JPG",0,0).AssumeFPS(F).Loop(Round(F*5))
KenBurnsEffect(startAlign=4, startZoomFactor=125, endAlign=3, endZoomFactor=125, width=W, height=H, ResizeMethod=Resizer, targetDAR=Target_DAR)
ConvertToYV12()
}
Function TrainStart()
{
HDV.TDeint()
ZoomBox(W, H, Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR, Align=3, zoomFactor=112.5)
Trim(2700,3390)
}
Function CloseUpOilPour()
{
HDV_Full_Crop
Trim(50200,50354)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
HDV_Full_Crop_OilPour
Trim(100,0)
KillAudio()
}
Function CloseUpFuelPour()
{
HDV_Full_Crop
Trim(50400,50670)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
HDV_Full_Crop_FuelPour
Trim(100, 370)
KillAudio()
}
Function OilFuelPour()
{
HDV_Full_Crop
Trim(52450,52900)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
KillAudio()
}
Function DirtyTrain1A()
{
ImageReader("Stil\DSCN1092.JPG",0,0).AssumeFPS(F)
ZoomBox(W, H, Resizer, TargetDAR=Target_DAR, Align=5).Loop(Round(PicLen/2))
ConvertToYV12()
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
}
Function DirtyTrain1B()
{
ImageReader("Stil\DSCN1098.JPG",0,0).AssumeFPS(F)
ZoomBox(W, H, Resizer, TargetDAR=Target_DAR, Align=5).Loop(Round(PicLen/2))
ConvertToYV12()
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
}
Function DirtyTrain2()
{
HDV_Full_Crop
Trim(9100,9220)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
KillAudio()
}
Function DirtyTrain3()
{
HDV_Full_Crop
Trim(28100,28220)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
KillAudio()
}
Function DirtyTrain4()
{
HDV_Full_Crop
Trim(122400,122520)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
KillAudio()
}
Function DirtyTrain5()
{
HDV_Full_Crop
Trim(189000,189120)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
KillAudio()
}
Function DirtyTrain6()
{
HDV_Full_Crop
Trim(191600,191720)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
KillAudio()
}
Function DirtyTrain7()
{
HDV_Full_Crop
Trim(192100,192300)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
KillAudio()
}
Function DirtyTrain8()
{
HDV_Full_Crop
Trim(194700,194820)
#AudioDub(last, BlankPic.Trim(0, last.Framecount()-1).KillVideo())
KillAudio()
}
Function DirtyTrainSplitScreen1()
{
SplitScreen(W, H, 6, DirtyTrain4().ConvertToRGB32(), DirtyTrain5().ConvertToRGB32(), DirtyTrain2().ConvertToRGB32(), DirtyTrain3().ConvertToRGB32())
}
Function NewTone()
{
sound = WavSource("Before-After2.wav") #305 Frames
sound = ConvertToMono(sound)
sound = MonoToStereo(sound,sound)
pic = ImmaRead("spectrogram3300.jpg").AssumeFPS(F)
a = pic.ZoomBox(W, H, Resizer, TargetDAR=Target_DAR, Align=-5).Subtitle("Before After",align=5, size=Round(H/10)).Loop(PicLen)
a = a.AudioDub(BlankPic.Trim(0, a.Framecount()-1).KillVideo())
b = pic.Loop(Round(PicLen/3)).KenBurnsEffect(startAlign=-5, endAlign=0, endX1=-520, endY1=200, endX2=940, endY2=-95, width=W, height=H, ResizeMethod=Resizer, endFrame=Round(PicLen/3)-Round(PicLen/4), targetDAR=Target_DAR)
b = b.AudioDub(BlankPic.Trim(0, b.Framecount()-1).KillVideo())
c = pic.Loop(305).KenBurnsEffect(startAlign=0, endAlign=0,startX1=-520, startY1=200, startX2=940, startY2=-95, endX1=2400, endY1=200, endX2=3860, endY2=-95, width=W, height=H, ResizeMethod=Resizer, targetDAR=Target_DAR)
c = c.AudioDub(sound).Trim(0,305).SSRC(R)#.AudioGraph(20)
c = Layer(c, SoundOverlay().KillAudio(), x=Round((W-(width(SoundOverlay())))/2.0))
c = AudioDub(c, SoundOverlay().KillVideo()).Trim(0,305)
d = pic.Loop(Round(PicLen/3)).KenBurnsEffect(startAlign=0, startX1=2400, startY1=200, startX2=3866, startY2=-95, endAlign=-5, width=W, height=H, ResizeMethod=Resizer, startFrame=Round(PicLen/4), targetDAR=Target_DAR)
d = d.AudioDub(BlankPic.Trim(0, d.Framecount()-1).KillVideo())
e = pic.ZoomBox(W, H, Resizer, TargetDAR=Target_DAR, Align=-5).Subtitle("Before After",align=5, size=Round(H/10)).Loop(PicLen*4)
e = e.AudioDub(BlankPic.Trim(0, e.Framecount()-1).KillVideo())
a++b++c++d++e
ConvertToYV12()
}
Function SoundAfter()
{
HDV.SeparateFields().SelectEven().ZoomBox(Round(W/Div), Round(H/Div), Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR, Align=5)
ShowSMPTE(size=Round(H/26))
Trim(181600,182500)
}
Function SoundBefore()
{
HDV.SeparateFields().SelectEven().ZoomBox(Round(W/Div), Round(H/Div), Resizer, SourceDAR=HDV_DAR, TargetDAR=Target_DAR, Align=5)
ShowSMPTE(size=Round(H/26))
Trim(40300,40900)
}
Function SoundOverlay()
{
BlankClip(BlankPic,width=Round(W/Div),height=Round(H/Div)).Trim(0,5).AddBorders(1,1,1,1, $000000)
Mask(BlankClip(BlankPic,width=Round(W/Div),height=Round(H/Div)).Trim(0,5).AddBorders(1,1,1,1, $000000))
ConvertToRGB32()
sb = SoundBefore().Trim(0,149).Subtitle("Before",align=8).ConvertToRGB24().AddBorders(1,1,1,1, $FFFFFF).ConvertToRGB32()
sa = SoundAfter().Trim(0,149).Subtitle("After",align=8).ConvertToRGB24().AddBorders(1,1,1,1, $FFFFFF).ConvertToRGB32()
sb ++ last.Trim(0,5) ++ sa
}
Function ThrottleUp()
{
HDV_Full_Crop
Trim(189450,191800)
a = last
HDV_Full_Crop_ThrottleUp
Trim(100,2450)
b = last
AudioDub(b,a)
Trim(0,630)
}
Function TrainMoving1()
{
HDV_Full_Crop
Trim(254100,254200)
KillAudio()
}
Function TrainMoving2()
{
HDV_Full_Crop
Trim(257430,257670)
KillAudio()
}
Function TrainMoving3()
{
HDV_Full_Crop
Trim(266210,266900)
#KillAudio()
}
Function ColdestStart()
{
ColdStart
Trim(220, 520)
ConvertToYV12()
ConvertFPS(F)
}
Function ColdestFullThrottle()
{
ColdStart
Trim(1600, 2250)
ConvertToYV12()
ConvertFPS(F)
}
Function ColdestThrottleDown()
{
ColdStart
Trim(2800, 3050)
ConvertToYV12()
ConvertFPS(F)
}
Function ColdestSaysThatAtFull()
{
ColdStart
Trim(3395, 3450)
ConvertToYV12()
ConvertFPS(F)
}
##SOUND##
Function SndIntro()
{
VoiceOver
Trim(0,1240)
Normalize(0.90)
}
Function SndCIRInvite()
{
VoiceOver
Trim(1320,2560)
Normalize(0.90)
}
Function SndEngineDis()
{
VoiceOver
Trim(2700,4250)
Normalize(0.90)
}
Function SndTrainStart()
{
VoiceOver
Trim(4300,4760)
Normalize(0.90)
}
Function SndTreatment()
{
VoiceOver
Trim(4840,6450)
Normalize(0.90)
}
Function SndUnderTreatment()
{
VoiceOver
Trim(6510,7250).Normalize(0.90) ++ Trim(7470, 8160).Normalize(0.90)
}
Function SndDirty()
{
VoiceOver
Trim(8280,9270)
Normalize(0.90)
}
Function SndResults()
{
VoiceOver
Trim(9540,10360)
Normalize(0.90)
}
Function SndNewTone1()
{
VoiceOver
Trim(10600,11050).Normalize(0.90) ++ Trim(11070,11240).Normalize(0.90) #++ Trim(11420, 11610) ++ Trim(11790,12020)
}
Function SndNewTone2()
{
VoiceOver
Trim(13350,14260).Normalize(0.90) ++ Trim(14420,15200).Normalize(0.90) ++ Trim(15290,15810).Normalize(0.90)
}
Function SndThrottleUp1()
{
VoiceOver
Trim(15940,16930)
Normalize(0.90)
}
Function SndThrottleUp2()
{
VoiceOver
Trim(17020,18130)
Normalize(0.90)
}
Function SndMoveTrain()
{
VoiceOver
Trim(18480,20700)
Normalize(0.90)
}
Function SndColdStart1()
{
VoiceOver
Trim(21380,22360)
Normalize(0.90)
}
Function SndColdStart2()
{
VoiceOver
Trim(23020,24100)
Normalize(0.90)
}
Function SndColdStart3()
{
VoiceOver
Trim(24430,25260)
Normalize(0.90)
}
Function SndColdStart4()
{
VoiceOver
Trim(25780,26670)
Normalize(0.90)
}
Function SndColdStart5()
{
VoiceOver
Trim(26890,27640)
Normalize(0.90)
}
Function SndColdStart6()
{
VoiceOver
Trim(27790,28880)
Normalize(0.90)
}
Function SndColdStart7()
{
VoiceOver
Trim(29000,29950)
Normalize(0.90)
}
Function SndColdStart8()
{
VoiceOver
Trim(30280,31900)
Normalize(0.90)
}
Function SndThanks()
{
VoiceOver
Trim(32050,34400)
Normalize(0.90)
}
Function BlankAudio(clip c, int "frames")
{
Default(c, BlankClip())
Default(frames, 30)
BlankClip(c, frames)
}
EDIT
Changed Code to reflect changes made to KBE/ZB.
Gavino
23rd May 2008, 00:53
Thanks for posting your script, obviously a lot of interesting stuff to study there. I'm a bit puzzled by this though:
Function BlankAudio(clip c, int "frames")
{
Default(c, BlankClip())
Default(frames, 30)
BlankClip(c, frames)
}
The Default lines have no effect, you need to assign the result to something, eg frames=Default(frames, 30). Also, c is not an optional parameter so can never be defaulted (except using the implicit last mechanism).
mikeytown2
23rd May 2008, 01:16
Thanks for posting your script, obviously a lot of interesting stuff to study there. I'm a bit puzzled by this though:
The Default lines have no effect, you need to assign the result to something, eg frames=Default(frames, 30). Also, c is not an optional parameter so can never be defaulted (except using the implicit last mechanism).
I was thinking that up before i added video to every audio track. It's one of my incomplete functions that doesn't really serve a purpose. a call to BlankClip is all thats needed, to pad the audio, since all my audio sources have video. The massive script isn't perfect... but keep the comments coming!
I'm currently working with KBE right now because if i change the AR, it actually doesn't work correctly with the DAR. i think i hit a sweet spot with 16/9 and 4/3. So I'm working on adding the Align right now... maybe a day or 2 and I'll have something working.
tacman1123
23rd May 2008, 15:44
Thanks so much for posting this, I'm sure I'm not the only one that will find a lot here to learn from.
Question: what did you use to create the file .mp4 file?
Tac
mikeytown2
23rd May 2008, 19:43
Question: what did you use to create the .mp4 file?
MeGui (http://sourceforge.net/project/showfiles.php?group_id=156112)
Just about anything other then QuickTime will play this file. VLC (http://www.videolan.org/vlc/), MPC (http://tibrium.neuf.fr/) even Flash 9 (http://www.adobe.com/go/getflashplayer). Using the JW Flash Player (http://www.jeroenwijering.com/?item=JW_FLV_Media_Player), you can embed it into a webpage.
tacman1123
25th May 2008, 19:44
Thanks, I've been playing around with MeGUI, and am stuck. I can convert the video okay, but without sound. When I choose Track1 (Audio Input) and add sound (either mp3 or aac), and then AutoEncode (to an mp4 container) I end up with an error when launching the mp4 file (-2010: the movie contains some invalid data (test-muxed.mp4).
In some cases I don't even get to that part, because the encoding fails.
The excellent thing, of course, is that this tool will provide the ability to publish my video as a podcast, or to PSP, etc.
Can you walk me through what you chose to create your files? Or is this one of those things that it depends on what codecs you have installed on your system?
Thx,
Tac
mikeytown2
25th May 2008, 21:18
Can you walk me through what you chose to create your files? Or is this one of those things that it depends on what codecs you have installed on your system?
You probably want to search/ask for help in the MPEG-4 Encoder GUIs Forum (http://forum.doom9.org/forumdisplay.php?f=78). But real quickly, for audio, make sure its stereo; and i use the Nero AAC Encoder at 16kbps (lowest setting possible). I use the avs file as input for audio in MeGui. I've never tried to add an mp3 to the mp4 container. For that you might want to search/ask for help in the New and alternative a/v containers forum (http://forum.doom9.org/forumdisplay.php?f=74).
Good Luck!
sidewinder711
3rd June 2008, 11:02
I tried to load an image and to use "ZoomBox (v.June 1st, 2008)", but it doesn't work for me. May I ask for some help how to use this function ?
Global W = 640
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global Resizer = "BilinearResize"
Import("C:\Programme\_video\AviSynth 2.5\plugins\functions\ZoomBox.avs")
ImageReader("1920x1080smptecolorbarsea8.png",0,0).AssumeFPS(F)
ZoomBox(last, 0, 0, 0, 0, W, H, IgnoreAR=1, ResizeMethod=Resizer).Loop(Round(F*3))
#ZoomBox()
ConvertToYV12()
Using the parameters, I get an error message ("invalid arguments to zoombox").
Using the defaults, I get an error message, too ("invalid arguments to float").
mikeytown2
3rd June 2008, 18:43
I tried to load an image and to use "ZoomBox (v.June 1st, 2008)", but it doesn't work for me. May I ask for some help how to use this function ?
Global W = 640
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global Resizer = "BilinearResize"
Import("C:\Programme\_video\AviSynth 2.5\plugins\functions\ZoomBox.avs")
ImageReader("1920x1080smptecolorbarsea8.png",0,0).AssumeFPS(F)
ZoomBox(last, 0, 0, 0, 0, W, H, IgnoreAR=1, ResizeMethod=Resizer).Loop(Round(F*3))
#ZoomBox()
ConvertToYV12()
Using the parameters, I get an error message ("invalid arguments to zoombox").
Using the defaults, I get an error message, too ("invalid arguments to float").
I redid the argument order. Try this
Global W = 640
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Import("C:\Programme\_video\AviSynth 2.5\plugins\functions\ZoomBox.avs")
ImageReader("1920x1080smptecolorbarsea8.png",0,0).AssumeFPS(F)
ZoomBox(W, H, align=5).Loop(Round(F*3))
ConvertToYV12()
I need to hunt down the old examples and change them.
mikeytown2
4th June 2008, 05:21
Using the defaults, I get an error message, too ("invalid arguments to float").
Bug fixed, thanks for letting me know!
sidewinder711
4th June 2008, 11:09
Thanks, mickeytown2, for your help! Your work and help is really appreciated.
I substituted the ZoomBox function with the new version.
- The float error message is gone.
- Please post the "Max" function, because now I'm stuck with zoombox line 63 ("modzoom = Max(Float(c.width())/Float(width),Float(c.height())/Float(height))", that I don't have that function and I can't find it in your threads.
mikeytown2
4th June 2008, 17:22
- Please post the "Max" function, because now I'm stuck with zoombox line 63 ("modzoom = Max(Float(c.width())/Float(width),Float(c.height())/Float(height))", that I don't have that function and I can't find it in your threads.
Didn't realize it, but Min()/Max() wasn't added until version 2.58 (http://avisynth.org/mediawiki/Changelist_25#Additions). If you do not want to install a Release Candidate, change this
modzoom = Max(Float(c.width())/Float(width),Float(c.height())/Float(height))
to this
modzoom = Float(c.width())/Float(width))
Gavino
4th June 2008, 19:34
change this
modzoom = Max(Float(c.width())/Float(width),Float(c.height())/Float(height))
to this
modzoom = Float(c.width())/Float(width))
Doesn't that lead to a different result when the height ratio is the larger one?
You can define Max yourself (at least for the purposes of this code) as
function Max(float a, float b) { a > b ? a : b }
mikeytown2
4th June 2008, 20:01
Doesn't that lead to a different result when the height ratio is the larger one?
Yes, but when the AR is different, using the max code, it still doesn't give the correct result. It's something that needs some tinkering. This is a concern only when zoomFactor is negative. Compare positive and negative align with a negative zoomFactor, when changing AR. you will see what i mean.
ColorBars().Trim(0,-1)
ZoomBox(720,480, Align=-1, zoomFactor=-105)
last + ZoomBox(720,480, Align=1, zoomFactor=-105)
This code should give the same result, because of the negative zoomFactor, but it doesn't. In order to fix it, i need to move modzoom right before zoomFactor is used.
Thanks for the simple Max function! sidewinder711, I recommend using Gavino's Max code.
sidewinder711
5th June 2008, 18:20
Now ZoomBox and KBE are working.... thanks Gavino & mickey. I already started to play around with the before mentioned scripts and the long ZB/KBE example. It looks really promising. Keep up your nice work! :thanks:
cweb
1st September 2008, 21:45
Speaking of ImageSource, what's the best way to simply import an image and make it "fit" with whatever the dimensions are of the current clip. In a typical slideshow application, images are rescaled to fit, centering the rescaled image and putting black borders on either the top and bottom or right and left.
Not sure if this is any "best way", but to do this recently I wrote a utility, still not userfriendly at the moment, which reads in a number of images in a directory, resizes them to a standard clip size, even depending on whether it's a landscape or portrait orientation photo. It uses the devil library for image handling.
Then it generates an avs file which reads the images and adds calls to random transitions.
Wilbert
9th December 2008, 22:21
@tacman1123,
Originally Posted by tacman1123 View Post
Speaking of ImageSource, what's the best way to simply import an image and make it "fit" with whatever the dimensions are of the current clip. In a typical slideshow application, images are rescaled to fit, centering the rescaled image and putting black borders on either the top and bottom or right and left.
Please try: http://forum.doom9.org/showthread.php?p=1222460#post1222460 and let me know whether it suits your needs.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.