Log in

View Full Version : Editing video


tengo6dedos
5th June 2010, 19:55
Hello, avisynth wiki seems to have trouble i cant get in. The question i have is how to edit videos with avisynth directly.

For example i have a 500 frames video, i want the video to start from frame 50 to 100, and repeat this frame sequence and whatever appears in it a couple of times, then jump to frame 300 let go of it till frame 400 and then ending the video with the 50->100 sequence 1 more time. I hope this is clear.

I also have question about doing zoom with avisynth, should i just resize and crop?

Thanks

poisondeathray
5th June 2010, 19:59
a = AVISource("video.avi").Trim(50,100)
b = AVISource("video.avi").Trim(300,400)

a++a++a++b++a

A zoom can be done with a resize and crop. You could upscale with NNEDI2 for example (less aliasing than a regular resize with lanczos or spline )

Keiyakusha
5th June 2010, 20:11
hmm, not sure if i understand your terminology, but somehow I got this:
a=trim(49,99) #countdown starts from 0
b=a.loop(6) #repeat any number of times
c=b.Trim(299,399)++a
return c

Gavino
5th June 2010, 20:20
a = AVISource("video.avi").Trim(50,100)
b = AVISource("video.avi").Trim(300,400)

a++a++a++b++a
Better not to repeat the AviSource.

v = AVISource("video.avi")
a = v.Trim(50,100)
b = v.Trim(300,400)
a.Loop(3)++b++a

@tengo6dedos
This assumes you are counting the first frame as 0, which is what Avisynth does.
Keiyakusha's solution assumes the first frame is numbered 1 in your terminology.

poisondeathray
5th June 2010, 20:21
Just curious , does the double AVISource call use more memory , or negatively impact performance?

I like Gavino's code; it's way more sexy than my crude notation :)

Gavino
5th June 2010, 20:26
Just curious , does the double AVISource call use more memory , or negatively impact performance?
More memory, as each instance will have its own buffers, etc.
It probably doesn't matter much with a simple script like this, but it's a good habit to get into.

poisondeathray
5th June 2010, 20:27
^Thanks for the tips :)

tengo6dedos
6th June 2010, 04:24
Thanks all for the help, i understand it vey clear. I hold one more question, how to do slowmotion?. I want to convert 1 second into 4. I have a 25fps video, should i just use convertfps(100) at the end of the script?. What if i want different sections to have different speed?, Should i just add corresponding .convertfps(xx) to "a" and "b"?. Saving in xvid AVI different framerate and played in computer should be ok or not?

So if i want all video to be 4 times slower ends like this?

v = AVISource("video.avi")
a = v.Trim(50,100)
b = v.Trim(300,400)
a.Loop(3)++b++a
convertfps(100)


and different speeds for sections end like this?

v = AVISource("video.avi")
a = v.Trim(50,100).convertfps(100)
b = v.Trim(300,400).convertfps(50)
a.Loop(3)++b++a


Thanks



EDIT: The convertfps method dont seem to work for the slowmotion, maybe im doing something wrong? the avi ends with original speed but in avsp ends fine. Im encoding xvid avi in virtualdub.

Here is my script, im trying to double the time, that is 2 times slower. This should be 1 section that im trying to encode, section "b" of the scripts above, after getting slowmotion right ill addapt it to "a.loop(3)++b++a" script.

DirectshowSource("D:/G/Sugh.flv",audio=false)
ApplyRange(3967,4070,"FilterChain1")
trim(3500,4070)
greyscale()
crop(200,200,-280,100)
nnedi2_rpow2(rfactor=4,cshift="lanczosresize")
convertfps(50)
addgrainc(100,100)


function FilterChain1(clip c) {
c
Tweak(bright=-255)
return last
}



EDIT2: I see i should be using Assumefps and not convertfps, i also realised that i should be reducing fps not rising them, how stupid of me. Then ends like Assumefps(12.5). Im very confused and tired right now, im gonna stop and see what you guys write tomorrow, Good night.

Gavino
6th June 2010, 10:13
I see i should be using Assumefps and not convertfps, i also realised that i should be reducing fps not rising them, how stupid of me. Then ends like Assumefps(12.5).
You need to use both AssumeFPS and ConvertFPS. And you want the final rate to be the same as the original (25).
To double the time, do either
ConvertFPS(50).AssumeFPS(25)
or
AssumeFPS(12.5).ConvertFPS(25)
These are exactly the same.

You can also replace ConvertFPS by ChangeFPS to just repeat frames instead of blending them, or by MFlowFPS (from mvtools) for a full motion-compensated interpolation, but the basic principle (using in conjunction with AssumeFPS) would still be the same.

tengo6dedos
6th June 2010, 22:10
I see. I ended up using MFlowFPS+AssumeFPS. The sections are done and ended great, now i just have to join them with the "a.Loop(3)++b++a" script for the final video output.

Thanks a lot, really appreciate all the help given.