View Full Version : padding audio
Floatingshed
18th February 2012, 15:00
I have several avi files that I want to join together and save as one file. These are clips that I created some time ago. It would appear that the audio is shorter than the video as, when joined, they gradually drift out of sync. The video lags.
Is it possible with avisynth to pad the audio stream to match the length of the video?
Thanks.
Gavino
18th February 2012, 15:47
It would appear that the audio is shorter than the video as, when joined, they gradually drift out of sync.
Even when joined with '++' (AlignedSplice (http://avisynth.org/mediawiki/Splice)) instead of '+' (UnalignedSplice)?
sneaker_ger
18th February 2012, 17:36
If they all have the same kind of tracks (with same resolution etc.), you should also be able to join them with AVI Mux GUI.
Floatingshed
18th February 2012, 17:55
I'm not joining them with avisynth. I'm using avisynth to open the avi's and resize, normalise etc. Then the saved avs scripts are processed to 264 & aac and joined externally. So "++" doesn't come into play unfortunately. I can't use avisynth to join them as there are 341 of them and I very quickly run out of memory!
If I used Trim(0,0) would that force the streams to match length?
If need be how would I chop say 10 frames from the end of each one? Without changing each script manually! (The scripts are generated in a batch, I can add any number of filters but it must be the same for each script)
Gavino
18th February 2012, 20:37
If I used Trim(0,0) would that force the streams to match length?
Yes, in that case, if the audio is shorter than the video, it will be padded with silence to match.
StainlessS
18th February 2012, 21:34
If need be how would I chop say 10 frames from the end of each one?
Trim(0,FrameCount() -1 - 10)
gyth
19th February 2012, 02:22
I can't use avisynth to join them as there are 341 of them and I very quickly run out of memory
Do you mean that your harddrive is full or that your system can't open that many files at once?
If you have harddrive space you can join 25 together at a time into a lossless intermediate.
@ECHO OFF
SET maxsources=25
SET customsource="C:\Program Files (x86)\anrichan3.3\cs.avs"
SET counter=0
SET counterB=0
CD %~1
IF EXIST "spliced\" (
ECHO Spliced files already exist. OVERWRITING?!?
PAUSE
)
MKDIR "spliced\"
SETLOCAL EnableDelayedExpansion
FOR %%G IN ("*.avi") DO (
IF !counter! EQU 0 (
ECHO import^(%customsource%^) > "spliced\!counterB!.avs"
) ELSE (
ECHO \++\ >> "spliced\!counterB!.avs"
)
ECHO customsource^("%%~fG"^) >> "spliced\!counterB!.avs"
SET /A counter += 1
ECHO !counterB!.!counter! %%~fG
IF !counter! EQU %maxsources% (
SET /A counter = 0
SET /A counterB += 1
)
)
ECHO Encode Files?
PAUSE
CD "spliced"
SET vdub="C:\Program Files (x86)\anrichan3.3\VirtualDub-1.9.7\vdub.exe"
SET vcf="C:\Program Files (x86)\anrichan3.3\spliced.vcf"
FOR %%G IN ("*.avs") DO (
%vdub% "%%G" /i %vcf% "%%~nG.avi"
)
PAUSE
cs.avs
function customsource(string X){
avisource(X).converttorgb32
(height==216) ? addborders(0,4,0,4) : nop()
(width==368) ? lanczosresize(320,224) : spline36resize(320,224)
}
spliced.vcf
VirtualDub.audio.SetSource(1);
VirtualDub.audio.SetMode(0);
VirtualDub.audio.SetInterleave(1,500,1,0,0);
VirtualDub.audio.SetClipMode(1,1);
VirtualDub.audio.SetConversion(0,0,0,0,0);
VirtualDub.audio.SetVolume();
VirtualDub.audio.SetCompression();
VirtualDub.audio.EnableFilterGraph(0);
VirtualDub.video.SetInputFormat(0);
VirtualDub.video.SetOutputFormat(0);
VirtualDub.video.SetMode(1);
VirtualDub.video.SetSmartRendering(0);
VirtualDub.video.SetPreserveEmptyFrames(0);
VirtualDub.video.SetFrameRate2(0,0,1);
VirtualDub.video.SetIVTC(0, 0, 0, 0);
VirtualDub.video.SetCompression(0x7367616c,0,10000,0);
VirtualDub.video.SetCompData(1,"AA==");
VirtualDub.video.filters.Clear();
VirtualDub.audio.filters.Clear();
VirtualDub.SaveAVI(VirtualDub.params[0]);
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.