Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th August 2004, 03:55   #1  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
ChangeSpeed(): Fast motion...

Right now I was wondering how I could take a video and speed up the video without changing the FPS on the video. The trick is I want something like so:

ChangeSpeed(orig_percent, change_percent, frames)

orig_percent: This is the original percent for the video.
default: 100%
change_percent: This is the percent to change to from the orig_percent value.
default: 200%
frames: Number of frames.
default: number of frames in clip.

Here is an example:

ChangeSpeed(orig_percent=100,change_percent=400,frames=560)

What that would do is within 560 frames it would create a motion transition from 100% to 400% so what in reality it would do is take a video and make it faster gradually to 400%.

I am not talking about immediately to 400%, making the entire video 400%, but starting at frame 1 with orig_percent (100 in this case) and increasing it until frame 560 at change_percent (400 percent in this case). Everything beyond 560 would be 400% as well. If frames was not specified then it would simply take the entire length of the clip to gradually increase to 400% speed.

That would be perfect. I do not need a deinterlacer built into it, because I am using bobmatcher as well as dgbob as an overlay at 30% opacity. So I'm good with that and I am pleased with the results. Which brings me to 60p or 30p using Decimate(2).

If someone could help me find or code something like this, that would be awesome!

Thanks!
- joshbm

Last edited by joshbm; 18th August 2004 at 04:05.
joshbm is offline   Reply With Quote
Old 18th August 2004, 04:39   #2  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
I believe this is my start on the script:

function ChangeSpeed(clip a, int orig_percent, int change_percent, int frames)
{
frames = default(frames,a.framecount)
orig_percent = default(orig_percent,100)
change_percent = default(change_percent,200)

# Etc... Script in developement still
}
joshbm is offline   Reply With Quote
Old 18th August 2004, 05:02   #3  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
look at the Function, I posted there : http://forum.doom9.org/showthread.ph...changespeed%2A
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 18th August 2004, 07:53   #4  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
Okay great! That's a great start, except now I want to gradually slow down/speed up the video.

I have modified my script to fit yours:

Code:
function ChangeSpeed(clip a, float "orig_percent", float "change_percent", int "frames", int "mode")
{
  frames = default(frames,a.framecount)
  orig_percent = default(orig_percent,100)
  change_percent = default(change_percent,200)

  ord = getparity(a) ? 1 : 0
  orig_framerate = framerate(a)
  percent_change = (change_percent>orig_percent) ? (change_percent/orig_percent) : (orig_percent/change_percent)
  new_framerate = (change_percent>orig_percent) ? (orig_framerate/percent_change) : (orig_framerate*percent_change)

  newmode = (percent_change<1) ? 2 : 0
  mode = default(mode,newmode)

  #debug
  #Subtitle(String(var))

  #process the video
  clipa=a.ConverttoYUY2
  clipa=(mode == 0) ? clipa.changefps(new_framerate) : (mode == 1) ? clipa.convertfps(new_framerate) : clipa.converttoyv12.mvconvertfps(fps=new_framerate).converttoyuy2
  clipa=clipa.assumefps(orig_framerate,true)
  return clipa
}
All I need now is to like I said find out how to start at 100% and gradually increase to 400%.

Thanks
- joshbm
joshbm is offline   Reply With Quote
Old 18th August 2004, 07:58   #5  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
Any ideas?
joshbm is offline   Reply With Quote
Old 18th August 2004, 09:52   #6  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
This should be possible with Animate

http://www.avisynth.org/Animate

# changespeed(1, 0, 8) # at 100%
# changespeed(0.25, 0, 8) # at 400%

clip = ...
Animate(0, 149, "changespeed", clip, 1, 0, 8, clip, 0.25, 0, 8)

didn't try it though.
Wilbert is offline   Reply With Quote
Old 18th August 2004, 15:33   #7  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
hm.. no time now, but wilberts idea seems to be a good start, but it will not work, caus it will destroy the interlacing.

I'll test the later.
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 18th August 2004, 17:45   #8  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
I think you are playing with fire here.

In principle this shouldn't be possible, since there is no way to assure you get the correct framecount - or at best the correct frames.

AFAICT there is no way to do a gradual slowdown/speedup in AviSynth. I think a plugin would have to be written, for you yo do this.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 18th August 2004, 18:03   #9  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
I have already deinterlaced the source to from 60i to 60p. So I have no problems with screwing up interlacing.
joshbm is offline   Reply With Quote
Old 18th August 2004, 18:19   #10  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
hehe, indeed, it IS fire.

a short test like this, will show:

a=last
animate(1,200,"changefps",a,3,a,30)
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 18th August 2004, 18:23   #11  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Quote:
Originally posted by scharfis_brain
hehe, indeed, it IS fire.
Funny effect, though
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 18th August 2004, 20:27   #12  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
So it does work then? changefps?

Well how could I incorporate it with your script? Thanks!
joshbm is offline   Reply With Quote
Old 19th August 2004, 05:08   #13  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
just try that line, and see yourself
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 19th August 2004, 07:40   #14  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Quote:
Originally posted by sh0dan
In principle this shouldn't be possible, since there is no way to assure you get the correct framecount - or at best the correct frames.

AFAICT there is no way to do a gradual slowdown/speedup in AviSynth. I think a plugin would have to be written, for you yo do this.
For sure a plugin would be the best solution, no doubt.

But what about using SelectEvery() inside of ScriptClip() & Co.? There, one could call SelectEvery() with per-frame-variable parameters, based on current frame number.
BTW, the audio could be rather easily processed to stay in-synch through CoolEdit, as it offers the possibility to do sliding pitch/speed changes.

This should be possible to do. (However I won't do it - I'm preparing a trip to POV-Ray land )

- Didée
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 19th August 2004, 15:37   #15  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
Thanks guys for all of your replies! Out of this I have created 2 functions (which I wanted to combine both, but they happen to be separate):

Code:
function ChangeSpeed(clip a, float "percent", int "mode", float "fps", float "frames", float "seconds")
{
  a.AssumeFrameBased()
  percent=default(percent,0)
  fps=default(fps,framerate(a))
  seconds=default(seconds,0)
  frames=default(frames,a.framecount)

  ord=getparity(a) ? 1 : 0
  fpsdiv=framerate(a)/1./fps
  defpercent=(1./fpsdiv)*100

  getframes=(seconds==0) ? frames*fpsdiv : seconds*framerate(a)
  percent=(percent==0) ? (a.framecount/1./getframes)*100 : percent
  percent=(percent==0) ? defpercent : Abs(percent)
  original_percent=percent
  percent=float(percent*fpsdiv)

  percent_change=(percent/100.)
  new_framerate=(framerate(a)/1./percent_change)
  newmode=(percent_change<1) ? 2 : 0
  mode=default(mode,newmode)

  clipa=a.ConverttoYUY2(interlaced=false)
  clipa=(round(percent)!=100) ? (mode == 0) ? clipa.changefps(new_framerate) : (mode == 1) ? clipa.convertfps(new_framerate) : clipa.converttoyv12(interlaced=false).mvconvertfps(fps=new_framerate).converttoyuy2(interlaced=false) : clipa
  clipa=clipa.assumefps(framerate(a)/1./fpsdiv)
  return clipa
}
Code:
function AnimateSpeed(clip a, float "orig_percent", float "change_percent", float "fps", float "start_frame",float "end_frame")
{
  a.AssumeFrameBased()
  orig_percent=default(orig_percent,100)
  fps=default(fps,framerate(a))
  start_frame=default(start_frame,framecount(a))
  end_frame=default(end_frame,1)

  fpsdiv=framerate(a)/1./fps
  defpercent=(1./fpsdiv)*100

  change_percent=default(change_percent,defpercent)
  change_percent=change_percent*fpsdiv
  orig_percent=orig_percent*fpsdiv

  framerate1=(framerate(a)/1./(orig_percent/100.))
  framerate2=(framerate(a)/1./(change_percent/100.))

  return animate(end_frame,start_frame,"changefps",a,framerate1,a,framerate2).assumefps(framerate(a)/1./fpsdiv)
}
ChangeSpeed

percent: The speed of the clip in percent.
default: Checks if frames and seconds are present, if neither are present then it auto-detects based on "fps" (see animate speed "change_percent").
mode: Method for slowing down or speeding up. 0=changefps, 1=convertfps, 2=mvconvertfps
default: auto-detect-- best method
fps: Desired frames per second.
default: Input (clip a) framerate.
frames: Instead of entering percent or seconds, you can enter a desired amount of frames, which will result in the video slowing down or speeding up to accomodate this value.
default: Checks if seconds are present, if none are present 0
seconds: Instead of entering percent or frames, you can enter a desired amount of seconds, which will result in the video slowing down or speeding up to accomodate this value.
default: 0

Example:
ChangeSpeed(percent=20,fps=23.976)
#It would slow the clip down 20% and convert to 23.976 fps.

AnimateSpeed

orig_percent: The starting percent.
default: 100
change_percent: The ending percent.
default: Auto-detects to framerate. Ex. If framerate input is 60p and the "fps" is set to 24p, this value is 40% (24/60).
fps: The desired frames per second.
default: Input (clip a) framerate.
start_frame: Start at frame number "start_frame".
default: 1
end_frame: End at frame number "end_frame".
default: Total frames in input clip (framecount).

Example:
AnimateSpeed(orig_percent=100,change_percent=20,fps=23.976)
#The clip would start at 100% and gradually slow to 20%, and converted to 23.976 fps.

Whew... Those are the two functions I have been working on. I was hoping I could use mvconvertfps with AnimateSpeed, but this will have to do for now.

Thanks all!
- joshbm

Last edited by joshbm; 19th August 2004 at 15:54.
joshbm is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:23.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.