Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

Pages: (2) [1] 2  ( Go to first unread post )
Speeding Up Sections Of A Video.
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
Virtualnoob123
Posted: Sep 25 2013, 06:28 PM


Member


Group: Members
Posts: 11
Member No.: 37179
Joined: 25-September 13



Hi all,

Yeah, I want to increase the frame rate for a section of video, but can't seem to get any answers on how to do it. It has audio that will need speeding up too.

I can speed up the hole video using Virtualdub's Video Frame Rate Control tab. And I know how to sync the audio too using the Input > Stretch > Output, but I can't seem to increase the fps for a section of video.

I tried to cut the clips into section and then edit the frame rates, then tried to stick them back together with append AVI segments. That never worked either. Kept getting an error.

Can anyone tell me how to do this?

Thanks.
 
     Top
Altaf
Posted: Sep 25 2013, 07:58 PM


Advanced Member


Group: Members
Posts: 75
Member No.: 36396
Joined: 9-April 13



Example 23.97600<25.00000:
user posted image
 
     Top
raffriff42
Posted: Sep 25 2013, 08:02 PM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



I can get it to work like this, but I recommend another way (see my Avisynth script below)
  • select clip to be changed
  • add Interpolate filter; scale frame rate by 1 / (new speed)
    in other words, to speed up by 30%, new speed is 1.30;
    so scale frame rate by (1/1.30) or 0.77
    EDIT Altaf's frame rate conversion above does the same thing, but without frame blending.
  • save using a lossless codec; this video will have a slower frame rate (tempfile_1)
    (assuming your normal frame rate is 30, new rate = 30 * 0.77 = 23.1 fps)
  • open tempfile_1 in VirtualDub; Video menu, Frame rate, convert input to 30
  • save again using a lossless codec; this video will be 30fps with a fast motion effect (tempfile_2)
  • now you can add tempfile_2 together with your normal-speed clips.
(totally ignoring audio here)

OK, now let's do it the Avisynth way - in fact let's do a slowdown and a speedup, with matching audio speed changes @ constant pitch, all with no temp files:
  • Install Avisynth;
  • Copy this code and save as "something.avs" (as plain text of course)
  • Edit "D:\<path>\test.avi" to point to your source video
  • Open in VirtualDub. Compress. Done!
CODE
#avisynth
## speed change test:
##   half speed from frame 0 to frame 29;
##   130% speed from frame 30 to frame 149
##   normal speed to end of video

V=AviSource("D:\<path>\test.avi")
return UUChangeSpeed(Trim(V, 0, 29), 0.5)
\    + UUChangeSpeed(Trim(V, 30, 149), 1.3)
\    + Trim(V, 150, 0)

function UUChangeSpeed(clip c, float factor)
{
  oldRate = FrameRate(c)
  newVid = AssumeFPS(c, oldRate * factor)
  return AudioDub(ChangeFPS(newVid, c), c.TimeStretch(tempo=100*factor))
}


UPDATE - new change speed function
http://forums.virtualdub.org/index.php?act...t=0&#entry95457

This post has been edited by raffriff42 on Feb 20 2014, 01:32 PM
 
     Top
Virtualnoob123
Posted: Sep 25 2013, 08:11 PM


Member


Group: Members
Posts: 11
Member No.: 37179
Joined: 25-September 13



QUOTE (Altaf @ Sep 25 2013, 07:58 PM)
Example 23.97600<25.00000:
user posted image

I'm not sure what you're trying to tell me there, m8 smile.gif


 
     Top
Virtualnoob123
Posted: Sep 25 2013, 08:23 PM


Member


Group: Members
Posts: 11
Member No.: 37179
Joined: 25-September 13



QUOTE (raffriff42 @ Sep 25 2013, 08:02 PM)
I can get it to work like this, but I recommend another way (see my Avisynth script below)
  • select clip to be changed
  • add Interpolate filter; scale frame rate by 1 / (new speed)
    in other words, to speed up by 30%, new speed is 1.30;
    so scale frame rate by (1/1.30) or 0.77
    EDIT Altaf's frame rate conversion above does the same thing, but without frame blending.
  • save using a lossless codec; this video will have a slower frame rate (tempfile_1)
    (assuming your normal frame rate is 30, new rate = 30 * 0.77 = 23.1 fps)
  • open tempfile_1 in VirtualDub; Video menu, Frame rate, convert input to 30
  • save again using a lossless codec; this video will be 30fps with a fast motion effect (tempfile_2)
  • now you can add tempfile_2 together with your normal-speed clips.
(totally ignoring audio here)

OK, now let's do it the Avisynth way - in fact let's do a slowdown and a speedup, with matching audio speed changes @ constant pitch, all with no temp files:
  • Install Avisynth;
  • Copy this code and save as "something.avs" (as plain text of course)
  • Edit "D:\<path>\test.avi" to point to your source video
  • Open in VirtualDub. Compress. Done!
CODE
#avisynth
## speed change test:
##   half speed from frame 0 to frame 29;
##   130% speed from frame 30 to frame 149
##   normal speed to end of video

V=AviSource("D:\<path>\test.avi")
return UUChangeSpeed(Trim(V, 0, 29), 0.5)
\    + UUChangeSpeed(Trim(V, 30, 149), 1.3)
\    + Trim(V, 150, 0)

function UUChangeSpeed(clip c, float factor)
{
  oldRate = FrameRate(c)
  newVid = AssumeFPS(c, oldRate * factor)
  return AudioDub(ChangeFPS(newVid, c), c.TimeStretch(tempo=100*factor))
}

Ok, I downloaded that software and copied and pasted the code into a text file.

I edited the the file path, saved, but I'm unsure what you mean by open Virtualdub and compress.

I'm a bit of a noob, so you'll need to explain a bit more.

If you mean open that avs file with Virtualdub then I get an error about line 7 column 14.

Code is like this atm:

CODE

#avisynth
## speed change test:
##   half speed from frame 0 to frame 29;
##   130% speed from frame 30 to frame 149
##   normal speed to end of video

V=AviSource D:\Movie Folder\Kharg Island\Scout vs stinger noob 45fps
return UUChangeSpeed(Trim(V, 0, 29), 0.5)
\    + UUChangeSpeed(Trim(V, 30, 149), 1.3)
\    + Trim(V, 150, 0)

function UUChangeSpeed(clip c, float factor)
{
 oldRate = FrameRate(c)
 newVid = AssumeFPS(c, oldRate * factor)
 return AudioDub(ChangeFPS(newVid, c), c.TimeStretch(tempo=100*factor))
}


 
     Top
raffriff42
Posted: Sep 25 2013, 08:45 PM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



You open "something.avs" in VirtualDub as if it was a video file. Avisynth reads the source, does the processing according to the instructions in the script, and passes the video to VirtualDub (or other Avisynth-compatible program), a frame at a time.

It's called frameserving, and it's kind of hard to get your head around, I admit. It helps to read some of the introductory articles at avisynth.nl
 
     Top
Virtualnoob123
Posted: Sep 25 2013, 08:48 PM


Member


Group: Members
Posts: 11
Member No.: 37179
Joined: 25-September 13



QUOTE (raffriff42 @ Sep 25 2013, 08:45 PM)
You open "something.avs" in VirtualDub as if it was a video file. Avisynth reads the source, does the processing according to the instructions in the script, and passes the video to VirtualDub (or other Avisynth-compatible program), a frame at a time.

It seems the code is wrong somehow. I'm getting errors.

Is the code correct:

CODE

#avisynth
## speed change test:
##   half speed from frame 0 to frame 29;
##   130% speed from frame 30 to frame 149
##   normal speed to end of video

V=AviSource (D:\Movie Folder\Kharg Island\Scout vs stinger noob 45fps)

return UUChangeSpeed(Trim(V, 0, 29), 0.5)
\    + UUChangeSpeed(Trim(V, 30, 149), 1.3)
\    + Trim(V, 150, 0)

function UUChangeSpeed(clip c, float factor)
{
 oldRate = FrameRate(c)
 newVid = AssumeFPS(c, oldRate * factor)
 return AudioDub(ChangeFPS(newVid, c), c.TimeStretch(tempo=100*factor))
}


I get a line 7 column 15 error with that code now.
 
     Top
raffriff42
Posted: Sep 25 2013, 08:49 PM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



(deleted - see my next post)

This post has been edited by raffriff42 on Sep 25 2013, 09:00 PM
 
     Top
Virtualnoob123
Posted: Sep 25 2013, 08:51 PM


Member


Group: Members
Posts: 11
Member No.: 37179
Joined: 25-September 13



QUOTE (raffriff42 @ Sep 25 2013, 08:49 PM)
What error message, exactly?

Virtualdub error

Script error expected a, or )
(:\User\Gareth\Desktop\test.avs, line 7, column 15)
 
     Top
raffriff42
Posted: Sep 25 2013, 08:53 PM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



You didn't add quote marks around your file path, and you don't have a file extension
old:
V=AviSource (D:\Movie Folder\Kharg Island\Scout vs stinger noob 45fps)
new:
V=AviSource ("D:\Movie Folder\Kharg Island\Scout vs stinger noob 45fps.avi")

This post has been edited by raffriff42 on Sep 25 2013, 09:00 PM
 
     Top
Virtualnoob123
Posted: Sep 25 2013, 08:53 PM


Member


Group: Members
Posts: 11
Member No.: 37179
Joined: 25-September 13



Ahh, that fixe it. Ok, now I go to compression tab?
 
     Top
raffriff42
Posted: Sep 25 2013, 08:59 PM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Right. Not sure what "compression tab" you mean, but just make your final video as usual.
 
     Top
Virtualnoob123
Posted: Sep 25 2013, 09:08 PM


Member


Group: Members
Posts: 11
Member No.: 37179
Joined: 25-September 13



Ok, so now I have the code working and can save the file.

I need to change the code to fit my video. It has 1859 frames and I have put the code like this:

CODE

#avisynth
## speed change test:
##   half speed from frame 0 to frame 29;
##   130% speed from frame 30 to frame 149
##   normal speed to end of video

V=AviSource ("D:\Movie Folder\Kharg Island\Scout vs stinger noob 45fps.avi")

return UUChangeSpeed(Trim(V, 0, 500), 0)
\    + UUChangeSpeed(Trim(V, 500, 1000), 1.3)
\    + Trim(V, 1000, 1859, 0)

function UUChangeSpeed(clip c, float factor)
{
 oldRate = FrameRate(c)
 newVid = AssumeFPS(c, oldRate * factor)
 return AudioDub(ChangeFPS(newVid, c), c.TimeStretch(tempo=100*factor))
}


But I get errors like the last one.

I want to have normal speed up to 500 frames then from 500 to 1000 3 times faster. And from 1000 to the end of the video normal.

What do I need to do to get the code to work?
 
     Top
raffriff42
Posted: Sep 25 2013, 09:15 PM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Trim runs to the end of the video when the second number is zero, so this
\ + Trim(V, 1000, 1859, 0)
should be
\ + Trim(V, 1000, 0)

Also: delete the first UUChangeSpeed for normal speed.
Also: if 1st part ends @ frame 500, next one starts @ 501
CODE
return Trim(V, 0, 500)
\    + UUChangeSpeed(Trim(V, 501, 1000), 1.3)
\    + Trim(V, 1001, 0)
 
     Top
Virtualnoob123
Posted: Sep 25 2013, 09:23 PM


Member


Group: Members
Posts: 11
Member No.: 37179
Joined: 25-September 13



Ok, this seems to work just fine now:

CODE

#avisynth
## speed change test:
##   half speed from frame 0 to frame 29;
##   130% speed from frame 30 to frame 149
##   normal speed to end of video

V=AviSource ("D:\Movie Folder\Kharg Island\Scout vs stinger noob 45fps.avi")

return UUChangeSpeed(Trim(V, 0, 500), 1)
\    + UUChangeSpeed(Trim(V, 501, 1000), 4)
\    + Trim(V, 1000, 0)

function UUChangeSpeed(clip c, float factor)
{
 oldRate = FrameRate(c)
 newVid = AssumeFPS(c, oldRate * factor)
 return AudioDub(ChangeFPS(newVid, c), c.TimeStretch(tempo=100*factor))
}


But for some reason instead of being 4 speed from 501-1000 frames it goes back to normal at around 600-650 frames. And stays normal speed to the end of the video.

 
     Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
23 replies since Sep 25 2013, 06:28 PM Track this topic | Email this topic | Print this topic
Pages: (2) [1] 2 
<< Back to Newbie Questions