Log in

View Full Version : select Audio streams from AVI


zerowalker
14th September 2013, 02:01
Is it possible to use 2 Audio Streams within an AVI with Avisynth?

Cause it seems that it isnīt possible from what i can see. As you canīt select streams, so it always use the default stream, which makes it a bit complicated.

So the only way to use the other streams is to extract them and use them that way, with Audiodub/MixAudio or something.

raffriff42
14th September 2013, 02:33
> you canīt select streams, so it always use the default stream
This should select any audio stream from any media file:
FFmpegSource2 (http://ffmpegsource.googlecode.com/svn/trunk/doc/ffms2-avisynth.html)(<path>, atrack=<stream number>)
You have to know, or guess, the stream number.

> Is it possible to use 2 Audio Streams
At the same time? Not sure.

zerowalker
14th September 2013, 03:02
I would prefer not to use ffmpegsource2, as itīs so slow compared to AVISource cause of the Indexing. I would like to get it to work with AVISource.

creaothceann
14th September 2013, 08:05
Demux the audio (could be automated with mkvmerge and mkvextract) and try one of the audio input plugins?

zerowalker
14th September 2013, 10:10
Thatīs what i would like to prevent, as it takes quite awhile on long videos.
A player can easily choose the streams, but Avisynth canīt (with AviSource), and i would like it to work, but as i canīt find any information on it, i guess there is a limitation.

raffriff42
14th September 2013, 13:45
Open in VirtualDub
Audio menu, Source, select stream
Frameserve from vdub to signpost AVI
AviSource(<signpost AVI>)

zerowalker
16th September 2013, 08:53
>Thanks for taking the time to respond to my thread
Don't mention it. Oh, that's right, you didn't.

Itīs not that i didnīt care, i just havenīt tried it yet:)
But i think i got how to do it, i need to use a frameserver, and use that as a "handholder".

Not the ideal approach, would prefer to just use Avisource, and have a setting to choose the Track. Without having to use some third party.

But it will probably work and does let me choose the selected track, so thanks for the tip, will keep it in mind!

raffriff42
16th September 2013, 09:44
Yeah, I know it's a hackish workaround, just throwing it out there as a possibility. Personally I would recommend using FFmpegSource2, and taking a break away from the computer for a few minutes while it indexes ;)

zerowalker
16th September 2013, 11:29
Yeah but ffmpegsource2 has itīs own problems, it does itīs own decoding which isnīt always that good. It often isnīt on par with what AVISource has, even if you skip the indexing part and just looks at the decoding. But itīs often more stable than DirectShowSource.

IanB
21st September 2013, 23:20
Avisynth only supports one audio track per clip. That audio track can of course have multiple channels.

FFmpegSource has options to select the required video and audio track when multiple tracks are present.

DirectshowSource supports custom .GRF files to allow controlling the filter pin connections. Where a DS filter implements multiple streams as separate pins connect all the unwanted pins to null renderers and leave the pin hosting the required stream unconnected, Avisynth will connect to the first unconnected pin providing the appropriate basic format (audio or video). For DS filters that require optional settings to choose streams there is currently no Avisynth interface to support custom settings per filter.

Avisource selects the first video and first audio streams.

This is implemented in avisynth/src/sources/avi/AudioSource.cpp @ 121 pAVIStream = pAVIFile->GetStream(streamtypeAUDIO, 0);


The forum threads are for support, PM's are for the exchange of confidential or personal information.

Wilbert
22nd September 2013, 13:38
Avisource selects the first video and first audio streams.

This is implemented in avisynth/src/sources/avi/AudioSource.cpp @ 121 pAVIStream = pAVIFile->GetStream(streamtypeAUDIO, 0);

I was looking at this last week, but got side tracked with the documentation on avisynth.nl.

Isn't it possible to add an option atrack to AviSource which let you pick

pAVIStream = pAVIFile->GetStream(streamtypeAUDIO, atrack);

and return an error if it doesn't exist. Or are more changes needed for that to work?

zerowalker
22nd September 2013, 17:06
Thanks.

Hmm makes me wonder as Wilbert says, if it tells to select the first track, why shouldnīt it be possible to tell it to select the second track?
Unless there is some fundamental issue which prevents any customization of it.

IanB
22nd September 2013, 23:12
I don't know.

The referenced code is where the audio track is selected from the VFW (Video for Windows) environment. You will need to check how the IAVIReadHandler::GetStream() interface works and how to specify "atrack" to do what you want, if it's at all possible. All I currently know is specifying 0 apparently gets the first track of the type specified.

The sources in avisynth/src/sources/avi/ are code given to BenRG by Avery Lee from VirtualDub's code base circa 2003.

raffriff42
22nd September 2013, 23:32
Should work. Virtualdub code looks for first audio stream with stream number >= argument.
avisynth/src/sources/avi/AVIReadHandler.cpp @ 2181
IAVIReadStream *AVIReadHandler::GetStream(DWORD fccType, LONG lParam) {
. . .
while(pasn_next = pasn->NextFromHead()) {
if (pasn->hdr.fccType == fccType && !lParam--)
break;

pasn = pasn_next;
++streamno;
} (EDIT my source download is old, so line numbers may be off)

zerowalker
23rd September 2013, 00:00
Interesting. Though out of my league sadly. If someone can get it to work or want to get deeper in it, please discuss it hear.
I however canīt be much help, as my programming skills are extremely lacking, i can barely understand the concept.

StainlessS
23rd September 2013, 00:53
Being able to Query contents of source files does not seem too weird. :)

Does however sound like a lot of work. (Permit this to pass).

raffriff42
23rd September 2013, 13:47
FWIW, it looks like the AVI file parser scans for all audio streams just as V-dub does (IOW it does not seem to be crippled)avisynth/src/sources/avi/AVIReadHandler.cpp @1848
bool AVIReadHandler::_parseStreamHeader(
List2<AVIStreamNode>& streamlist, DWORD dwLengthLeft, bool& bIndexDamaged)
. . .
avisynth/src/sources/avi/AVIReadHandler.cpp @ 1960
streamlist.AddTail(pasn);
@ZeroWalker, all this is contingent on a developer taking an interest and having the time.