View Full Version : Adding An Audio Track to a Time-lapse Clip?
BlockABoots
28th September 2014, 10:35
I have a capture video that i have sped up the fps to create a time lapse video, i am wanting to add an audio track over the video. This is my current script in AvsPmod.....
video=AVISource("F:\Video Captures\amarec(20140927-2352).avi")
video1=killaudio(video)
audio=audio=mpasource("E:\Music\song.m4a")
video2=trim(video1,509,165686)
video3=AssumeFPS(video2,300)
return video3
But im not getting the audio track, any ideas?
Also would the audio track play too fast because of the AssumeFPS command?, if so how do i get the audio to....
A. play at normal speed
and
B. loop itself?
thanks
StainlessS
28th September 2014, 11:12
audio=mpasource("E:\Music\song.m4a")
And at some point it might be good to AudioDub the audio onto the video. Must be a long song to go with a 165,000 frame clip.
"A. play at normal speed", I guess to do that I would choose a normal speed (300FPS is perhaps not it), what is normal speed?
"B. loop itself",
Return Video3 ++ Video3 ++ Video3 ++ Video3 ++ Video3 ++ Video3 ++ Video3 ++ Video3 ++ Video3, etc
EDIT: Or eg, "Return Video3.Loop(10) # ten times (a really really long clip)".
There's also a 'Sync_Audio' arg to go with AssumeFPS() but I'm not really sure what you are trying to do.
althor1138
28th September 2014, 11:17
try this:
video=avisource("f:\video captures\amarec(20140927-2352).avi",audio=false).trim(509,165686).selectevery(10,0).assumefps("ntsc_video")
audio=mpasource("e:\music\song.m4a")
mix=audiodub(video,audio)
return(mix)
I'm assuming you have a video at 30fps and you wanted it 10 times faster?
You'll have to use audacity or something to create an audio file that matches the length of this video.
Somebody might have a workaround to make it loop etc. but this is the most straightforward way imo.
StainlessS
28th September 2014, 11:42
A bit more added to Althor1138 script
video=avisource("f:\video captures\amarec(20140927-2352).avi",audio=false).trim(509,165686).selectevery(10,0).assumefps("ntsc_video")
audio=mpasource("e:\music\song.m4a")
audio=audio.Loop(1000) # Make sure we got enough :)
audiodub(video,audio) # After here, we use the magic 'Last' clip variable with both video and audio
Trim(0,0) # Trim audio to match video length (chop off excess or pad with digital silence)
Fadeout(60) # fade 60 frames
return Last
althor1138
28th September 2014, 11:53
StainlessS's version is the new straightforward way! I didn't realize you could loop a pure audio file like that. Now it's all in the script and no need to mess with making a custom audio file in another program.
BlockABoots
28th September 2014, 12:37
A bit more added to Althor1138 script
video=avisource("f:\video captures\amarec(20140927-2352).avi",audio=false).trim(509,165686).selectevery(10,0).assumefps("ntsc_video")
audio=mpasource("e:\music\song.m4a")
audio=audio.Loop(1000) # Make sure we got enough :)
audiodub(video,audio) # After here, we use the magic 'Last' clip variable with both video and audio
Trim(0,0) # Trim audio to match video length (chop off excess or pad with digital silence)
Fadeout(60) # fade 60 frames
return Last
Thanks for the detailed reply. Ill give it a go
BlockABoots
28th September 2014, 12:47
Ok have tried a sample encode and the audio but its super sped up and seems to be repeating itself every 2 seconds, any ideas?
StainlessS
28th September 2014, 12:53
There is nothing in that script that alters audio playback speed, it should also play ok without encoding.
The SelectEvery(10,0) speeds up the video by missing out 90% of the frames, AssumeFPS() just gives it a standard rate.
Try comment out "audio=audio.Loop(1000)" line, should not make any difference (short audio of course) but I guess 1000 is a biggish number.
You could also try "Return Last.Info()" to see if it says anything interesting.
EDIT: I saw you later post, try reduce the audio loop count, so long enough for video but not too long.
There is something weird going on there, I still say there is nothing in the script to alter audio speed.
BlockABoots
28th September 2014, 13:24
Altering the loop count to 4 and the super fast audio just loops 4 times and stops.
Here a quick sample of the output file....
https://www.youtube.com/watch?v=B93lUu4cTX4&feature=youtu.be
and here the script used....
video=AVISource("F:\Video Captures\amarec(20140927-2352).avi",audio=false).trim(509,5000).selectevery(10,0).assumefps(29.97)
audio=mpasource("E:\Music\song.m4a")
audio=audio.loop(4)
audiodub(video,audio)
Trim(0,0)
fadeout(60)
return last.info()
creaothceann
28th September 2014, 14:06
Does the song play correctly without the Loop command? Maybe mpasource is buggy or the file is corrupted.
Please use [code] tags.
"return last" is unnecessary because the variable "last" is automatically returned. (Also applies when writing functions.)
vf = "F:\Video Captures\amarec(20140927-2352).avi"
af = "E:\Music\song.m4a"
AVISource(vf, audio=false)
Trim(509, 5000)
SelectEvery(10)
AssumeFPS(30000, 1001) # actually, just "30" would be better in this case
v = last
MPASource(af)
Loop(4)
a = last
AudioDub(v, a)
Trim(0, 0)
FadeOut(60)
Info
StainlessS
28th September 2014, 14:15
BlockABoots link sounds to me like bad/corrupt audio. (EDIT: Just a lot of squealing).
Should MPASource even load *.m4a audio ?
BlockABoots
28th September 2014, 15:03
is there a plugin for m4a audio?
BlockABoots
28th September 2014, 15:42
It would appear that indeed the Mpasource plugin isnt very good, installed NicAudio plugin and used script
audio=NicMPG123Source("E:\Music\song.m4a")
and the audio now works
Reel.Deel
28th September 2014, 15:44
Give LSMASHAudioSource or LWLibavAudioSource a try (http://avisynth.nl/index.php/LSMASHSource). There's also FFAudioSource (https://github.com/FFMS/ffms2/blob/master/doc/ffms2-avisynth.md#ffaudiosource) and BassAudio. I'm sure one will work :)
Gavino
28th September 2014, 16:09
"return last" is unnecessary because the variable "last" is automatically returned.
Just to clarify, that's not strictly accurate in the general case (as I explained here to you once before ) - although it does apply in the specific case here.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.