Log in

View Full Version : Console-Tool to mix 2 audio-streams?


tension76
18th October 2006, 13:01
I got a music-file and a speech-file. One is WAV, the other is MP3.
I need a console-tool to mix them -> like ffmpeg.
Is ffmpeg capable of doing it? If so, how?
If not, what other tool you can recommend?
thanks!
Uli

buzzqw
18th October 2006, 13:49
mix in what container ?

BHH

tension76
18th October 2006, 14:29
What do you mean by "container"? I don't know about an audio-container.
In the end I do want to encode a video-file (AVI, MPG, WMV, etc...), but that is a different task.
First I have to mix the audio stuff.

Inputstream-type doesn't really matter. I can convert it via ffmpeg. But mixing 2 streams into 1 is the problem.

thanks
uli

buzzqw
18th October 2006, 15:14
pardon me but i am a newby at audio

Do you want a unique stream where both audio are overllapped (mixed) ?

if so... i don't command line muxer

you can try AudaCity, SoundForge or goldwave

BHH

tebasuna51
18th October 2006, 15:35
Maybe with AviSynth-Bepipe.

First make a Audio.avs file:
w = WavSource("path\your.wav")
m = NicMPG123Source("path\your.mp3")
MixAudio(w, m, 0.5, 0.5)
And after the command line:
bepipe --script"Import(^Audio.avs^)" | yourEncoder -yourParameters

buzzqw
18th October 2006, 15:51
:goodpost:

in simplicity the best way !

BHH

tension76
18th October 2006, 16:55
@tebasuna51: thanks! looks pretty much like what I'm looking for.
I'm going to try that.
But I already have ffmpeg installed, and it would be much easier if it works with it.
Do you know if it does or not?

oups - I just saw the "-yourencoder -your parameter"-thing.
So I think I missunderstood what avisynth is.... *phew*
I'll go and google...
(but more information is still welcome!)

thanks
uli

raquete
18th October 2006, 16:57
:goodpost:

in simplicity the best way !

BHH
agree and i'm starting to love bepipe/avisynth for audio!

tebasuna again i beg you,
please do guides for use bepipe/avisynth with command lines, i have read that you can do magic with both. :)

tebasuna51
18th October 2006, 17:37
But I already have ffmpeg installed, and it would be much easier if it works with it.
Do you know if it does or not?

oups - I just saw the "-yourencoder -your parameter"-thing.
So I think I missunderstood what avisynth is....
AviSynth is a frame server very used for video purpose but also is useful for audio.

With Bepipe help, AviSynth read audio streams (WavSource is a native function, NicMPG123Source is a decoder plugin: NicAudio.dll), can do native functions like MixAudio, and output one uncompressed audio stream to stdout.

Without encoder the output is a wav file, but you can 'pipe' the output to any encoder if accept stdin input, for instance:
ffmpeg, lame, aften, neroAacEnc, oggenc, ...

tension76
13th November 2006, 18:02
Thanks for your support, folks.
After few weeks I'm back on this issue but still have major probs:

Avisynth 2.5 is installed.
These files are in one folder:
audio.avs
BePipe.exe
source.mp3
source.wav

This is the audio.avs file:
w = WavSource("source.wav")
m = NicMPG123Source("source.mp3")
MixAudio(w, m, 0.5, 0.5)and this is finally what i type into console:bepipe --script"Import(^audio.avs^)"And then windows error-messagebox says:
"Unable to initialize application (0cx0000135)"
:confused:

Looks like bepipe doesn't work somehow. Or is it my fault?
I have WinXP-SP2 (german) installed.

I'm a real noob at audio issues. I read something about "besweet" and "behappy" - but don't understand it. Is it an alternative? how?

I need accurate installation- and proceeding-instructions.
Please help me ones again.
Thanks in advance!
cheers
Uli

tebasuna51
13th November 2006, 20:30
Looks like bepipe doesn't work somehow. Or is it my fault?
- To run Bepipe you need at least .NET FrameWork v1.1
- My fault in syntax: Blank space between --script and "Import...
- Warning: at the end you need redirect the output to a encoder (using the 'pipe' command |) or to a wav file like this:
bepipe --script "Import(^audio.avs^)" > output.wav
Some issues:
- The two audios must have the same samplerate. Use ssrc(new-samplerate) to change if needed.
- The output audio have the shorter duration than two inputs.
- After the mix (50%-50%) you can use Normalize(0.9) to guarantee a 90% volume (or other value at your choice).
For instance:
w = WavSource("source.wav")
m = NicMPG123Source("source.mp3").ssrc(48000)
MixAudio(w, m, 0.5, 0.5)
Normalize(0.9)
Tested and work for me.
I read something about "besweet" and "behappy" - but don't understand it. Is it an alternative? how?
Bepipe is the BeHappy precursor (the two have the same author: Dimzon). And work with AviSynth, the last BeHappy need .NET FrameWork v2.0. BeHappy is a GUI and accept also the same audio.avs like input and work like Bepipe. I suggest you Bepipe because you need a 'console-tool'.

AFAIK BeSweet can't do a mix between two inputs, can concatenate (.lst) or merge channels (.mux) but not mix.

tension76
15th November 2006, 16:09
Hey tebasuna,
thanks for all the hints and very detailed instructions.
Unfortunately Bepipe still doesn't want to start. I installed .NET Framework 1.1. Now a different error message occurs:
Unhandled Exception: System.Security.SecurityException: System.Security.Permissi
ons.SecurityPermission
at BePipe.Main(String[] args)

The state of the failed permission was:
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Ve
rsion=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="UnmanagedCode"/>
It occurs immediatley after I started it. "output.wav" is generated, but with 0 Kb.
The version of bepipe.exe is 1.0.2155.27457

I tried it on 2 different machines. Both with WinXP SP2.
I will try a third one right now.

What info may I provide to be helped?
thanks again!

tebasuna51
15th November 2006, 17:02
Sorry, I can't help you more.

Try with .NET 2.0, disabling antivirus (System.Security?, the user must have permission to write in the folder), use a mix.bat file:
bepipe --script "Import(^audio.avs^)" > output.wav
pause
... I don't know.

Bepipe.exe 1.0.2155.27457 is the last version I know, and use.
Tested with XP SP1/SP2 and by many other users (AFAIK).

tension76
16th November 2006, 17:58
YES!!!
I just installed .NET 2.0 and it worked like a charm :-)
Thanks a lot until this point, tebasuna.

And now the real work starts.
What I want to achieve:
Mix a known music file with an unknown speech file.
The music file is known in length and format (always 16bit, 44Khz, stereo).
The speech file is provided by someone in an unknown format and it is most likely much shorter than the music file. I would like to accept mp3-format, wav-format and maybe aiff-format for speech files. Because the last two mentioned are kind of native formats.

My Script developed to this state:
LoadPlugin("NicAudio.dll")
w = WavSource("source_music.wav")
m = NicMPG123Source("source_speech_st.mp3").ConvertAudioTo16bit.ssrc(44100).DelayAudio(2)
MixAudio(w, m, 1, 1)
Now my only problem is, to find out what input format is provided. But I can convert the input file beforehand with ffmpeg (i guess). So bepipe will only have to deal with 2 wav files.
Or is there an easier way to do it - maybe in one avs-script?
That would be great.

Otherwise: thanks a lot for your support. I really appreciate it.

One more question:
what is the difference betweenMixAudio(w, m, 0.9, 0.9)andMixAudio(w, m, 0.5, 0.5)
Normalize(0.9)

cheers
tension

tebasuna51
16th November 2006, 19:25
MixAudio(w, m, 0.9, 0.9)
can produce overflows, only 0.5, 0.5 (or 0.7, 0.3) guarantee the signal is overflow free. After you can use Normalize to set the global volume level.

There are also other decoder plugin you can use:
BassAudio.dll, in shon3i BeHappy package (http://forum.doom9.org/showthread.php?p=829754#post829754), work with Bass v2.2 libraries (http://www.un4seen.com/) and can open wav, aiff, mp3 and others formats.