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. |
28th January 2012, 20:28 | #1 | Link |
EphMan
Join Date: May 2004
Posts: 737
|
Speeding up video while keeping audio pitch the same
My girlfriend needs to use a 6 minute YouTube video for a presentation for her class. The problem is, they are limited to using 4 minutes worth of video content.
Is there a way w/ AviSynth to speed up the video to make it fit within a 4 minute duration while keeping the audio pitch the same? I don't want to speed it up and have the narrator sound like a chipmunk. |
28th January 2012, 20:57 | #3 | Link |
EphMan
Join Date: May 2004
Posts: 737
|
But how would I script this so that the video and audio match up? I haven't used AviSynth in quite some time.
I could get FFMPEGSource2 so import the FLV file, but I found "Pazera Free FLV to AVI Converter" which was able to decode the FLV to an uncompressed Huffyuv AVI file. Now I can import the video wherever, but I'd rather just do it all within a script. |
28th January 2012, 21:48 | #4 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Code:
... AssumeScaledFPS(6, 4, False) # Run video 6/4 faster TimeStretch(Pitch=100.0*4.0/6.0, Rate=100.0*6.0/4.0) # Set pitch and rate back to normal ... Last edited by IanB; 30th January 2012 at 23:22. Reason: Opps, set audio to 72000 Hz (should be False on Assum..) |
29th January 2012, 15:58 | #5 | Link |
Registered User
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
|
If AssumeScaledFPS(...,..., True) already syncs the audio (with a different pitch), why touch the Rate in TimeStretch?
And wouldn't it be better to adjust the audio in a single step within TimeStretch? Maybe it doesn't matter much, but it feels like the precision would be higher. AssumeScaledFPS(6, 4, False) #speed up video TimeStretch(Rate=100.0*6.0/4.0) #speed up audio |
29th January 2012, 19:32 | #6 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Actually, you're both wrong!
The rate parameter in TimeStretch() doesn't actually change the sampling rate, it changes both pitch and tempo together. In IanB's solution, his AssumeScaledFPS() increases both the pitch and the sampling rate by 50%, while his TimeStretch() has the overall effect of maintaining that increased pitch and sampling rate while increasing the tempo by a further 50% (and losing audio sync). ajp_anton's solution keeps the original sampling rate and maintains audio sync with the faster video, but not the pitch which is raised by 50%. The following code works to speed up both video and audio in sync, maintaining the original sampling rate and pitch: Code:
AssumeScaledFPS(6, 4) # Run video 6/4 faster TimeStretch(tempo=100.0*6.0/4.0) # Run audio 6/4 faster, maintaining pitch If it is desired to keep the original frame rate (probably better for YouTube), you can replace the AssumeScaledFPS() line by: Code:
ChangeFPS(4*FrameRateNumerator(), 6*FrameRateDenominator()).AssumeFPS(last) Last edited by Gavino; 29th January 2012 at 20:11. Reason: minor text changes |
29th January 2012, 23:44 | #7 | Link |
Registered User
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
|
Ah yes, I confused Rate and Tempo. Could've just checked one of my speedup functions to see that it uses Tempo, but I was sure it was Rate so I went with that =).
edit: Oh, and for same-framerate output, I would use the following (even though the result is probably the same): AssumeScaledFPS(6, 4).ChangeFPS(last) Last edited by ajp_anton; 29th January 2012 at 23:49. |
30th January 2012, 23:42 | #9 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Opps I stuffed the audio sample rate, should have been false, post fixed.
AssumeScaledFPS(6, 4, False).ChangeFPS(last) converts the video FPS back by dropping 33% of the frames. Given it's a 50% speed up this is probably okay. If motion mattered then maybe some MVTools magic might be in order. Note: If this was an interlaced project you might want to smart bob it to a double rate stream then zap 33% of those frames and then re-interlace. |
Tags |
audio, pitch, retiming, speed, video |
Thread Tools | Search this Thread |
Display Modes | |
|
|