Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st February 2012, 18:00   #1  |  Link
martinjkelly
Registered User
 
Join Date: Dec 2011
Posts: 6
Trouble extracting audio from avi file with AviSynth

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

Last edited by martinjkelly; 22nd February 2012 at 10:13.
martinjkelly is offline   Reply With Quote
Old 22nd February 2012, 00:33   #2  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
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.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 22nd February 2012, 10:09   #3  |  Link
martinjkelly
Registered User
 
Join Date: Dec 2011
Posts: 6
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
martinjkelly is offline   Reply With Quote
Old 22nd February 2012, 10:57   #4  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
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.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 22nd February 2012, 11:13   #5  |  Link
martinjkelly
Registered User
 
Join Date: Dec 2011
Posts: 6
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....

Code:
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.....

Code:
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)

Last edited by martinjkelly; 22nd February 2012 at 14:07.
martinjkelly is offline   Reply With Quote
Old 22nd February 2012, 16:31   #6  |  Link
martinjkelly
Registered User
 
Join Date: Dec 2011
Posts: 6
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.
martinjkelly is offline   Reply With Quote
Old 22nd February 2012, 19:40   #7  |  Link
Midzuki
Unavailable
 
Midzuki's Avatar
 
Join Date: Mar 2009
Location: offline
Posts: 1,480
Quote:
Originally Posted by martinjkelly View Post
...
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. I've just tried the script:

Code:
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.
Midzuki is offline   Reply With Quote
Old 22nd February 2012, 20:20   #8  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
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)
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 23rd February 2012, 10:15   #9  |  Link
martinjkelly
Registered User
 
Join Date: Dec 2011
Posts: 6
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 is offline   Reply With Quote
Old 23rd February 2012, 14:15   #10  |  Link
martinjkelly
Registered User
 
Join Date: Dec 2011
Posts: 6
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
martinjkelly is offline   Reply With Quote
Reply

Tags
audio

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:34.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.