View Full Version : Audio Only Clip - Trim
speedyrazor
20th January 2016, 23:03
Hi, I am working with an audio only clip, in the Trim wiki it says:
Trim with audio-only clips
In AviSynth v2.60, to trim an audio-only clip, you simply set a fake frame rate with AssumeFPS.
This is my script but its not working:
a1 = LSMASHAudioSource(source="movie.mov", track=1)
a2 = LSMASHAudioSource(source="movie.mov", track=2)
a3 = LSMASHAudioSource(source="movie.mov", track=3)
a4 = LSMASHAudioSource(source="movie.mov", track=4)
a5 = LSMASHAudioSource(source="movie.mov", track=5)
a6 = LSMASHAudioSource(source="movie.mov", track=6)
a7 = LSMASHAudioSource(source="movie.mov", track=7)
a = MergeChannels(a1,a2,a3,a4,a5,a6,a7)
AssumeFPS(24,1)
Trim(19,24)
blackVideo1 = blankclip(a, length=5)
return blackVideo1 + a
This is giving me:
Invalid arguments to function "AssumeFPS"
StainlessS
20th January 2016, 23:23
Probably because you aint got no clip.
Try again AFTER the LSMASH stuff (ie when you do got a clip).
EDIT: You seem to have additional problems with naming clips variables and such
EDIT: No idea what below is intended to do.
a1 = LSMASHAudioSource(source="movie.mov", track=1)
a2 = LSMASHAudioSource(source="movie.mov", track=2)
a3 = LSMASHAudioSource(source="movie.mov", track=3)
a4 = LSMASHAudioSource(source="movie.mov", track=4)
a5 = LSMASHAudioSource(source="movie.mov", track=5)
a6 = LSMASHAudioSource(source="movie.mov", track=6)
a7 = LSMASHAudioSource(source="movie.mov", track=7)
a = MergeChannels(a1,a2,a3,a4,a5,a6,a7).AssumeFPS(24,1) # I assume that this is where ASsumeFPS is required
Trim(19,24) # No idea what this is supposed to affect
blackVideo1 = blankclip(a, length=5) # Or is it supposed to affect above Trim clip ?
return blackVideo1 + a
Above needs more thought.
speedyrazor
20th January 2016, 23:31
Probably because you aint got no clip.
Try again AFTER the LSMASH stuff (ie when you do got a clip).
Moving the AssumeFPS(24,1) below has the same issue.
EDIT: You seem to have additional problems with naming clips variables and such
Could you be more specific please?
speedyrazor
20th January 2016, 23:39
Sorry, im a bit new to all this stuff.
a1 = LSMASHAudioSource(source="movie.mov", track=1)
a2 = LSMASHAudioSource(source="movie.mov", track=2)
a3 = LSMASHAudioSource(source="movie.mov", track=3)
a4 = LSMASHAudioSource(source="movie.mov", track=4)
a5 = LSMASHAudioSource(source="movie.mov", track=5)
a6 = LSMASHAudioSource(source="movie.mov", track=6)
a7 = LSMASHAudioSource(source="movie.mov", track=7)
a = MergeChannels(a1,a2,a3,a4,a5,a6,a7).AssumeFPS(24,1) # I should put the AssumeFPS here?
Trim(19,24) # I want to Trim the audio and only play from frame 19 to frame 24
blackVideo1 = blankclip(a, length=5) # I want to add a 5 frame silence to the beginning of the audio (the return below?)
return blackVideo1 + a
StainlessS
20th January 2016, 23:39
Dont know, perhaps it is just the Trim statement that need removed ? (It dont do nuttin)
EDIT: overlapping posts, perhaps something like below
a1 = LSMASHAudioSource(source="movie.mov", track=1)
a2 = LSMASHAudioSource(source="movie.mov", track=2)
a3 = LSMASHAudioSource(source="movie.mov", track=3)
a4 = LSMASHAudioSource(source="movie.mov", track=4)
a5 = LSMASHAudioSource(source="movie.mov", track=5)
a6 = LSMASHAudioSource(source="movie.mov", track=6)
a7 = LSMASHAudioSource(source="movie.mov", track=7)
a = MergeChannels(a1,a2,a3,a4,a5,a6,a7).AssumeFPS(24,1) # I should put the AssumeFPS here?
a=a.Trim(19,24) # I want to Trim the audio and only play from frame 19 to frame 24
blackVideo1 = blankclip(a, length=5) # I want to add a 5 frame silence to the beginning of the audio (the return below?)
return blackVideo1 + a
EDIT: That should give 5 frame silence, + 5 frame audio, OK ?
speedyrazor
20th January 2016, 23:51
Using this gives me:
Trim: Cannot trim if there is no video.
a1 = LSMASHAudioSource(source="movie.mov", track=1)
a2 = LSMASHAudioSource(source="movie.mov", track=2)
a3 = LSMASHAudioSource(source="movie.mov", track=3)
a4 = LSMASHAudioSource(source="movie.mov", track=4)
a5 = LSMASHAudioSource(source="movie.mov", track=5)
a6 = LSMASHAudioSource(source="movie.mov", track=6)
a7 = LSMASHAudioSource(source="movie.mov", track=7)
a = MergeChannels(a1,a2,a3,a4,a5,a6,a7).AssumeFPS(24,1)
a=a.Trim(19,24)
blackVideo1 = blankclip(a, length=5)
return blackVideo1 + a
raffriff42
20th January 2016, 23:53
in the Trim wiki (http://avisynth.nl/index.php/Trim) it also saysAudioTrim (in Avisynth v2.60) trims a clip based on time, not on frames. This is most useful for audio-only clips, where "frames" have no meaning anyway...
Wilbert
21st January 2016, 00:00
@raffriff42,
AudioTrim should work indeed, but
Trim with audio-only clips
In AviSynth v2.60, to trim an audio-only clip, you simply set a fake frame rate with AssumeFPS.
seems false to me.
StainlessS
21st January 2016, 00:12
@raffriff42,
AudioTrim should work indeed, but
Trim with audio-only clips
In AviSynth v2.60, to trim an audio-only clip, you simply set a fake frame rate with AssumeFPS.
seems false to me.
To me too.
This dont work,
/*
a1 = LSMASHAudioSource(source="movie.mov", track=1)
a2 = LSMASHAudioSource(source="movie.mov", track=2)
a3 = LSMASHAudioSource(source="movie.mov", track=3)
a4 = LSMASHAudioSource(source="movie.mov", track=4)
a5 = LSMASHAudioSource(source="movie.mov", track=5)
a6 = LSMASHAudioSource(source="movie.mov", track=6)
a7 = LSMASHAudioSource(source="movie.mov", track=7)
a = MergeChannels(a1,a2,a3,a4,a5,a6,a7).
*/
a = Avisource("D:\V\cabaret.avi").Trim(10000,0).KillVideo # Test audio clip
a = a.AssumeFPS(24,1) # Synthesize a dummy Framerate for edits.
a = a.Trim(19,24) # Select required audio, 6 frames # BANG !!!, 'Trim: Cannot trim if there is no video.'
K = blankclip(a, length=5) # Black clip of 5 frames silence
return K + a # Append audio to 5 frames of silence
Getting same as Speedy Razor, ie
Trim: Cannot trim if there is no video.
EDIT: Speedy, suggest that in future, you try add comments like above, so that you can easily track what each variable holds.
raffriff42
21st January 2016, 00:33
Yup, I get that too. The wiki is wrong. AudioTrim does work thoughColorBars
Trim(0, 42)
A = Tone(length=3600).AudioTrim(0, -1*Float(FrameCount)/FrameRate)
#A = Tone(length=3600).AssumeFPS(Last).Trim(0, 42) ## error
AudioDub(A)
return Info
EDIT the source code (http://avisynth2.cvs.sourceforge.net/viewvc/avisynth2/avisynth/src/filters/edit.cpp?view=markup#l154) seems pretty clear on this
Trim::Trim(int _firstframe, int _lastframe, bool _padaudio, PClip _child, int mode, IScriptEnvironment* env)
: GenericVideoFilter(_child)
{
int lastframe = 0;
if (!vi.HasVideo())
env->ThrowError("Trim: Cannot trim if there is no video.");
...
StainlessS
21st January 2016, 00:36
Yup, I get that too. The wiki is wrong.
Also builtin docs wrong.
raffriff42
21st January 2016, 00:54
I will excise that statement from the wiki. It's been there a long time; I'm surprised nobody caught it. The sneaky devil!
EDIT it's my understanding the builtin docs are generated from the wiki, so they will be updated automatically at some future date.
Music Fan
21st January 2016, 02:25
What happens if you put blankclip on the first line (and thus before sound and trim) ?
StainlessS
21st January 2016, 03:24
Something like this
FPS = 24
KLen = 5
TRIM_S = 19
TRIM_E = 24 # 24-19 + 1 = 6 frames
# Test audio clip, 10 secs of FPS frames, then Kill Video
a = Avisource("D:\V\cabaret.avi").Assumefps(FPS).Trim(10000,-Int(Ceil(FPS*10))).KillVideo
K = blankclip(a,Width=640,height=480,length=KLen,fps=FPS) # Black clip of KLen frames silence, default video CS
Frames = Int(Ceil(a.AudioDuration * FPS)) # Round UP, whole frames
v = blankclip(K, length=Frames) # Number of video frames to match i/p audio duration
va = AudioDub(v,a) # Dummy Video (with audio) clip of frames, same duration as AudioDuration
aTrim = va.Trim(TRIM_S,TRIM_E) # Select required audio (6 video frames worth)
K ++ aTrim # Append audio to silence (assign v+a to Implicit Last)
Info # KLen(5) + (TRIM_E - TRIM_S + 1) = 11 Frames worth of Video + Audio
EDIT: Got to give Width/Height for k=BlankClip(a) else null video
Wilbert
21st January 2016, 19:44
EDIT it's my understanding the builtin docs are generated from the wiki, so they will be updated automatically at some future date.
No, they are not.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.