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.

 
[speeding Up Video] Error Avysinth Code
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
tigretones
Posted: Feb 19 2014, 07:55 PM


Newbie


Group: Members
Posts: 6
Member No.: 23229
Joined: 13-March 08



Hi everybody,

I'm trying to speed up just some parts of a video, and I found great help in this post in the forum. But unfortunately I can't get my code to work, VirtualDub always shows me the same warning message:

AvySinth open failure:
Evaluate: operands of '+' must both be numbers, strings or clips
(C:\Documents and Settings\Pc1\Escritorio\Tapon14-02-17\Nuevo Avysinth Script.avs, line 11)


The code is:

CODE
#avisynth
## speed change test:
##   speed x 50 from frame 0 to frame 26464;
##   normal speed from frame 26465 to frame 26883
##   speed x 50 to end of video

V=AviSource ("C:\Documents and Settings\Pc1\Escritorio\Tapon14-02-17<!--POST BOX-->Punto de partida.avi")

return UUChangeSpeed(Trim(V, 0, 26464), 50)
\  + Trim(V, 26465, 26883)
\  + UUChangeSpeed(Trim(V, 26884, 0), 50)

function UUChangeSpeed(clip c, float factor)
{
oldRate = FrameRate(c)
newVid = AssumeFPS(c, oldRate * factor)
}


As you can see, I'm trying to speed up the video from the beggining to frame 26464, then return to normal speed until frame 26883, and finally speed up again the video until the end.

Any ideas about what am I doing wrong?

Thanks in advance.
 
     Top
dloneranger
Posted: Feb 19 2014, 08:05 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



the function doesn't return anything
add return newvid at the end

....then you'll get a framerates don't match error instead

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
malky
Posted: Feb 19 2014, 10:42 PM


Advanced Member


Group: Members
Posts: 290
Member No.: 22386
Joined: 6-November 07



newVid = AssumeFPS(c, oldRate * factor)
return AudioDub(ChangeFPS(newVid, c, linear=false),c.TimeStretch(tempo=100*factor))

}

I inserted the "return Audiodub" line.
The 'linear=false' is required when the float factor is more than 10;your scripts shows a factor of 50.
 
    Top
tigretones
Posted: Feb 20 2014, 10:37 AM


Newbie


Group: Members
Posts: 6
Member No.: 23229
Joined: 13-March 08



Thank you very much for your answers guys, I really appreciate your help.

@Malky: the video has no audio. If I include the "return Audiodub" line in the code, VirtualDub returns me the following error message:

Avysinth open failure:
AudioDub: need an audio and a video track


So I decided to delete that line, now I see that was a bit radical, the function needs an end.

@Dlonerange: I've just added the end of function you suggest, and it works... partially, because now I get a new error message:

Avysinth open failure:
Splice: video framerate doesn't match
(C:\Documents and Settings\Pc1\Escritorio\Tapon14-02-17\Nuevo Avysinth Script.avs, line 11)


At this point, the code is
QUOTE
#avisynth
## speed change test:
##  speed x 50 from frame 0 to frame 26464;
##  normal speed from frame 26465 to frame 26883
##  speed x 50 to end of video

V=AviSource ("C:\Documents and Settings\Pc1\Escritorio\Tapon14-02-17<!--POST BOX-->Punto de partida.avi")

return UUChangeSpeed(Trim(V, 0, 26464), 50)
\  + Trim(V, 26465, 26883)
\  + UUChangeSpeed(Trim(V, 26884, 0), 50)

function UUChangeSpeed(clip c, float factor)
{
oldRate = FrameRate©
newVid = AssumeFPS(c, oldRate * factor)
return newVid
}


Anyone knows where's the new mistake?
 
     Top
dloneranger
Posted: Feb 20 2014, 12:55 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



It's not a mistake, just a limit on joining video together
Avisynth will only join them if they're the same size and fps

You should be able to just remove the audiodub from malky's suggestion
(I don't have avisynth here atm so can't check)

newVid = AssumeFPS(c, oldRate * factor)
return ChangeFPS(newVid, c, linear=false)
}

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
raffriff42
Posted: Feb 20 2014, 01:29 PM


Advanced Member


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



Sorry, that code was written in a hurry, and not tested at the extremes. Thanks for the input.
Here's a new, improved function that blends frames when possible. It handles video-only clips and any reasonable conversion factor:

EDIT: additional debugging; pitch correction now optional; added frame blending in fast forward.
CODE
#######################################
### change speed over a wide range
### with frame blending in fast forward by default.
##
## @ factor - 0.33 for 1/3 speed, etc;
##    min = 0.001; max = min(FrameCount, 1000)
##    (if > FrameCount, duration would be 0);
##    if argument is out of range, an error occurs.
##
## @ pitchfix - if true, maintain audio pitch with speed
##    (default false; allow pitch to rise or fall)
##
## @ noblend - if true, never blend frames (default false)
##
## @ raffriff42 24-Feb-2014
##
function UUChangeSpeed2(
\           clip C, float factor,
\           bool "pitchfix", bool "noblend")
{
   Assert(factor>=0.001,
   \  "UUChangeSpeed2 bad argument: factor<0.001")
   Assert(factor<=1000.0,
   \  "UUChangeSpeed2 bad argument: factor>1000")
   Assert(factor<=C.FrameCount,
   \  "UUChangeSpeed2 bad argument: factor>FrameCount")

   pitchfix = Default(pitchfix, false)
   noblend  = Default(noblend, false)

   AS = C.AssumeFPS(C.FrameRate * factor)

   temprad = Round(0.5 * factor)
   TS = (factor<1.0 || temprad==0 || noblend)
   \  ? AS
   \  : Overlay(
   \       AS,
   \       AS.TemporalSoften(
   \           temprad, 255, 255, 48, 2),
   \       opacity=0.7)

   (factor<1.5 && noblend==false)  
   \  ? AS.ConvertFPS(C)
   \  : TS.ChangeFPS(C.Framerate, linear=(factor<10.0))

   A = (pitchfix)
   \  ? C.TimeStretch(tempo=factor*100.0)
   \  : C.TimeStretch(rate=factor*100.0)

   return (C.HasAudio==false) ? Last : Last.AudioDub(A)
}


This post has been edited by raffriff42 on Feb 28 2014, 01:10 AM
 
     Top
tigretones
Posted: Feb 20 2014, 07:52 PM


Newbie


Group: Members
Posts: 6
Member No.: 23229
Joined: 13-March 08



@Dloneranger: It worked! I added those new lines and the video loaded in VirtualDub, with no errors and the speed changes I wanted! Thank you sooooooooooo much, that script has saved me a lot of time!

I copy the right code here, just in case it may be useful to any newbie like me:

QUOTE
#avisynth
## speed change test:
##  speed x 50 from frame 0 to frame 26464;
##  normal speed from frame 26465 to frame 26883
##  speed x 50 to end of video

V=AviSource ("C:\Documents and Settings\Pc1\Escritorio\Tapon\2014-02-17\00Punto de partida.avi")

return UUChangeSpeed(Trim(V, 0, 26464), 50)
\  + Trim(V, 26465, 26883)
\  + UUChangeSpeed(Trim(V, 26884, 0), 50)

function UUChangeSpeed(clip c, float factor)
{
oldRate = FrameRate©
newVid = AssumeFPS(c, oldRate * factor)
return ChangeFPS(newVid, c, linear=false)
}


@raffriff42:Thanks to you too! I can't tell you if the new code works because I haven't tested it yet. I'll need some time to understand it, seems quite more difficult...
 
     Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
6 replies since Feb 19 2014, 07:55 PM Track this topic | Email this topic | Print this topic

<< Back to Newbie Questions