View Full Version : Trouble extracting audio from avi file with AviSynth
martinjkelly
21st February 2012, 18:00
Hi All,
I'm fairly new to using FFMpeg and AviSynth and I've been encountering one issue over and over again without resolution for a few weeks now, any assistance or advice would be greatly appreciated..
http://www.martinjkelly.co.uk/audio.avi <2Mb
I have attached a link to a file called audio.avi (right click, save target as), This file is from a DVR device that records video and audio. I am building some software to merge 4 of these video files together into a single file and take the audio stream from the first file only. the problem i am having is when i try to extract the audio (using AviSource, FFMpegSource2, WAVSource etc) for some reason it plays the audio for a couple of seconds and then the audio stops.
When this happens in windows media player, if i stop the file playing and then start it again it works as you would expect.
I just cant get it to read the full audio stream on the first attempt
Anyone have any ideas? Thanks
PS... Please ignore the radio music in background - dunno where that come from lol
tebasuna51
22nd February 2012, 00:33
The audio stored in your .avi is PCM (uncompressed)
BitDepth: 16 bit int
Channels: 1
SampleRate: 8000 Hz
Duration: 17.68 sec.
You can use VirtualDubMod to extract (Streams -> Stream list... -> Save WAV)
Also work with a audio.avs:
AviSource("D:\audio.avi")
and
wavi audio.avs audio.wav
Or using SoundOut() plugin.
martinjkelly
22nd February 2012, 10:09
Hi,
Thanks for your help, as already stated I have already tried to use AviSource and WAVSource get the audio stream. It does seem to read the audio but only plays the first few seconds the first time I play it. If I replay the file it seems to work.
I do need it to work on the first attempt though, as I am generating and running these avs scripts on the fly and merging these files in a batch.
I will have a play with SoundOut and see if that helps but I'm not actually trying to extract it. I am trying to merge 4 video streams into one and only use the audio stream from the first one
Thanks again
tebasuna51
22nd February 2012, 10:57
Please put your avs script and batch file to try reproduce your problem.
Maybe some players have troubles with audio Samplerate 8 KHz or H264 video in avi container.
martinjkelly
22nd February 2012, 11:13
I am currently playing with AviSource and WavSource and applying various and random filters and settings etc to try and resolved the problem. The best way to replicate this issue is to simply use either of these in your avs script....
audio = WavSource("c:\audio.avi")
return audio
When you open this in Windows media player it will play about a second of audio and then stop. If you then click play again it will play the full audio stream (mmmm, wonder if it is just my machine... maybe a codec or something missing??)
The code for the main project is something like this.....
LoadCPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\ffms2.dll")
audio = WavSource("C:\audio1.avi")
a = FFMpegSource2("C:\audio1.avi").BicubicResize (352,288)
b = FFMpegSource2("C:\audio2.avi").BicubicResize (352,288)
c = FFMpegSource2("C:\audio3.avi").BicubicResize (352,288)
d = FFMpegSource2("C:\audio4.avi").BicubicResize (352,288)
row1 = StackVertical(a,c)
row2 = StackVertical(b,d)
mosaic = stackhorizontal (row1, row2)
video = AudioDub(mosaic, audio)
return video
Thanks
PS.. This project will be running on Windows Server 2008 and is being developed on Windows 7. AviSource does not seem to work on either for me. DirectShowSource does not work on the Win Server machine (I think it may be because its a VPS without dedicated hardware)
martinjkelly
22nd February 2012, 16:31
Just a quick update...
I've been trying allsorts today to resolve this issue and am no further unfortunately. I've tried loads of different methods of reading the audio stream and tried multiple settings/filters in avisynth to get it work and all have failed, It's very strange. Any help would be greatly appreciated.
Midzuki
22nd February 2012, 19:40
...
When you open this in Windows media player it will play about a second of audio and then stop. If you then click play again it will play the full audio stream (mmmm, wonder if it is just my machine... maybe a codec or something missing??)
Apparently the problem is in Windows Media Player itself. :rolleyes: I've just tried the script:
WavSource("audio.avi")
and it played fine "at the first click" :) in both Media Player Classic HC and MPlayer.
Only WMP11 finished the playback before it could even start. :scared:
tebasuna51
22nd February 2012, 20:20
Like Midzuki say seems a problem with WMP.
The avs play fine for me with MPC-HC and VirtualDub.
Try only:
WavSource("audio.avi").ssrc(48000)
martinjkelly
23rd February 2012, 10:15
Ah that seems to work fine, I will integrate this into my project today and test it fully
Thanks alot for all your help guys, I've been pulling my hair out with this one... and such an easy fix
martinjkelly
23rd February 2012, 14:15
Yeah it plays the AVS perfectly every time now, thanks alot for you help everyone...
I dont suppose anyone knows how i can get my avs file to a avi or even better a flv file with audio do they? i cant seem to get audio working with avs2avi. Someone advised me that it doesnt do audio at all :(
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.