### Author Topic: Mixing two stream channels and record result to hard disk/stream to web  (Read 1042 times)

#### kafffee

• Posts: 93
##### Mixing two stream channels and record result to hard disk/stream to web
« on: 14 Apr '22 - 10:58 »
Hello there :-)

I am trying to mix two stream channels and record the result to hard disk and stream it over the internet. Now I've found the following code in this forum:

Code: [Select]
{            var freq = 44100;            var chans = 2;            var files = new string[] { "c:/soundtest/background.mp3", "c:/soundtest/in-1.mp3"};            var decoders = new List<int>();            var mixer = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamCreate(freq, chans, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_MIXER_END); // create a mixer that ends when its sources do                       // create decoders for each of the files            for (int a = 0; a < files.Length; a++)            {                decoders[a] = Bass.BASS_StreamCreateFile(files[a], 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE);            }            // plug the first 2 files into the mixer (assuming they're the main ones)            Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(mixer, decoders[0], 0);            Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(mixer, decoders[1], 0);            BassEnc.BASS_Encode_Start(mixer, "c:/soundtest/background.mp3", BASSEncode.BASS_ENCODE_PCM, null, IntPtr.Zero); // set a WAV writer on the mixer            // processing loop            while (true)            {                byte[] buf = new byte[20000]; // processing buffer                int r = Bass.BASS_ChannelGetData(mixer, buf, sizeof(byte)); // process the mixer                if (r == -1)                {                    break; // done                }            }            BassEnc.BASS_Encode_Stop(mixer); // close the WAV writer
I assume this will pretty much do it, except for the fact, that I want the mixing channel to persist, when one or even two of the songs are stopped. I also want to, when on the the stream channels is stopped, play a new song instead and keep mixing the channels. Can someone please tell me how this is done?

And the second issue:
How can I stream this mixing channel over the internet?:

I've found this in the docs:

Code: [Select]
Private _recHandle As IntegerPrivate _broadCast As BroadCast..._recHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_DEFAULT, Nothing, 0)...' create an encoder instance (e.g. for MP3 use EncoderLAME):Dim lame As New EncoderLAME(_recHandle)lame.InputFile = Nothing 'STDINlame.OutputFile = Nothing 'STDOUTlame.LAME_Bitrate = CInt(EncoderLAME.BITRATE.kbps_56)lame.LAME_Mode = EncoderLAME.LAMEMode.Monolame.LAME_TargetSampleRate = CInt(EncoderLAME.SAMPLERATE.Hz_22050)lame.LAME_Quality = EncoderLAME.LAMEQuality.Quality' create a StreamingServer instance (e.g. SHOUTcast) using the encoder:Dim shoutcast As New SHOUTcast(lame)shoutcast.ServerAddress = "localhost"shoutcast.ServerPort = 8000shoutcast.Password = "changeme"shoutcast.PublicFlag = True' use the BroadCast class to control streaming:_broadCast = New BroadCast(shoutcast)_broadCast.AutoReconnect = TrueAddHandler _broadCast.Notification, AddressOf OnBroadCast_Notification_broadCast.AutoConnect()Private Sub OnBroadCast_Notification(sender As Object, e As BroadCastEventArgs)  ' Note: this method might be called from another thread (non UI thread)!  If _broadCast Is Nothing Then    Return  End If  If _broadCast.IsConnected Then    ' we are connected...  Else    ' we are not connected...  End If End Sub
But thats probably not all. Maybe there is a step by step tutorial or another example code that I did not find?

#### Ian @ un4seen

• Posts: 24427
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #1 on: 14 Apr '22 - 17:22 »
I assume this will pretty much do it, except for the fact, that I want the mixing channel to persist, when one or even two of the songs are stopped. I also want to, when on the the stream channels is stopped, play a new song instead and keep mixing the channels. Can someone please tell me how this is done?

Do you mean you want the mixer to continue producing output (silence) when its sources are finished? If so, you can achieve that by replacing the BASS_MIXER_END flag with BASS_MIXER_NONSTOP in the BASS_Mixer_StreamCreate call. Note that will mean that the "processing loop" never exits and you will end up with a quickly expanding output file from the encoder, but if you add a caster to the encoder then it will by default automatically limit the processing to realtime speed.

How can I stream this mixing channel over the internet?:

I've found this in the docs:
...

I would recommend using the BASSenc_MP3 add-on (which is based on LAME) instead of the LAME executable. For example, you could replace the "create an encoder instance" section with this:

Code: [Select]
encoder = BASS_Encode_MP3_Start(_recHandle, "-b 56", 0, 0, 0);
Likewise, you can replace the rest (setting up the casting) with this:

Code: [Select]
BASS_Encode_Castinit(encoder, "localhost:8000", "changeme", BASS_ENCODE_TYPE_MP3, 0, 0, 0, 0, 0, 56, BASS_ENCODE_CAST_PUBLIC);
Please see the BASSenc and BASSenc_MP3 documentation for details. Although it isn't .Net, the calls will be much the same in any language, so you could also check the CAST example (preferably the C version as it includes BASSenc_MP3 support) included in the BASSenc package for ideas.

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #2 on: 15 Apr '22 - 12:09 »
Hey Ian, thanks for the reply :-)!

Quote
Do you mean you want the mixer to continue producing output (silence) when its sources are finished? If so, you can achieve that by replacing the BASS_MIXER_END flag with BASS_MIXER_NONSTOP in the BASS_Mixer_StreamCreate call. Note that will mean that the "processing loop" never exits and you will end up with a quickly expanding output file from the encoder, but if you add a caster to the encoder then it will by default automatically limit the processing to realtime speed.

I am working on a DJ software which has two "mixing desks", which each one will play an mp3 file. Also I added some effects to each channel like volume, tempo, pitch, equalizer and so on...

Now I want to record the output sound of my entire application (my 2 mixing desks) to hard disk, and its supposed two record all the effects with it.

Of course when the mp3 file of each one of the desks is done playing it will play the next file in playlist.

I want to record the whole thing to hard disk until I hit a button "Stop Recording".

Now I've tried the code below, but as you said it does not work in realtime and I get a huge file of about 40MB, even though the three mp3s only have about 4MP each... It has been recorded until the end of the longest track.

Here's my code so far (VB.NET):

Code: [Select]
Option Strict OnImports Un4seen.BassImports Un4seen.Bass.AddOn.EncPublic Class Form1    Private streamA As Integer    Private streamB As Integer    Private streamC As Integer    Private mixer As Integer    Private DecoderA As Integer    Private DecoderB As Integer    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle)    End Sub    Private Sub btnPlayFile1_Click(sender As Object, e As EventArgs) Handles btnPlayFile1.Click        streamA = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\dancehall\Macka B\01 Macka B - 01.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_PRESCAN)        Bass.BASS_ChannelPlay(streamA, False)    End Sub    Private Sub btnPlayFile2_Click(sender As Object, e As EventArgs) Handles btnPlayFile2.Click        streamB = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\pop\Clueso\Weit Weg\14 Chicago.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_PRESCAN)        Bass.BASS_ChannelPlay(streamB, False)    End Sub    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles btnPlayFile3.Click        Bass.BASS_ChannelStop(streamA)        streamC = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\elektronic\chillout\Dave G\Chill Out In Miami\01 Miles Apart.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_PRESCAN)        Bass.BASS_ChannelPlay(streamC, False)    End Sub    Private Sub btnMixToHD_Click(sender As Object, e As EventArgs) Handles btnMixToHD.Click        mixer = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_MIXER_END)        DecoderA = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\dancehall\Macka B\01 Macka B - 01.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_DECODE)        DecoderB = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\pop\Clueso\Weit Weg\14 Chicago.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_DECODE)        Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(mixer, DecoderA, 0)        Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(mixer, DecoderB, 0)        BassEnc.BASS_Encode_Start(mixer, "F:\Ablage\RecordMixToHDTest.mp3", BASSEncode.BASS_ENCODE_PCM, Nothing, IntPtr.Zero) ' Set a mp3 writer On the mixer        ' processing loop        While True            Dim encBuffer As Byte() = New Byte(20000) {} 'Byte[] buf = New Byte[20000] ' processing buffer            Dim r As Integer = Bass.BASS_ChannelGetData(mixer, encBuffer, 20000) ' process the mixer            If r = -1 Then BassEnc.BASS_Encode_Stop(mixer) ' done        End While    End Sub    Private Sub btnStopRecording_Click(sender As Object, e As EventArgs) Handles btnStopRecording.Click        BassEnc.BASS_Encode_Stop(mixer)    End SubEnd Class
Can you tell me how what I described above can be done? I guess I have to add a caster to the encoder if I understood you right...
What is a caster and how does it work?

And for the second issue (streaming the mixer channel to the internet):

So far I got this:

Code: [Select]
Dim encoder = BassEnc_Mp3.BASS_Encode_MP3_Start(_recHandle, "-b 56", 0, 0, 0)BassEnc.BASS_Encode_CastInit(encoder, strStream1Ip + ":" + strStream1Port, strStream1Password, BASS_ENCODE_TYPE_MP3, strStream1Name, strStream1url, Nothing, Nothing, Nothing, Val(strStream1Bitrate), blStream1)
But thats about it. But how can I get the arguments for BASS_Encode_CastInit, like server, password, name, url, genre, desc, headers, bitrate, pub?

Do I have to register at shoutcast respectively icecast to get these?

Which steps am I missing? I do not really understand the cast example in C from the BassEnc package... Something in C# or VB.NET would help a lot...
« Last Edit: 15 Apr '22 - 13:57 by kafffee »

#### Ian @ un4seen

• Posts: 24427
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #3 on: 15 Apr '22 - 16:33 »
I am working on a DJ software which has two "mixing desks", which each one will play an mp3 file. Also I added some effects to each channel like volume, tempo, pitch, equalizer and so on...

Now I want to record the output sound of my entire application (my 2 mixing desks) to hard disk, and its supposed two record all the effects with it.

Of course when the mp3 file of each one of the desks is done playing it will play the next file in playlist.

I want to record the whole thing to hard disk until I hit a button "Stop Recording".

Now I've tried the code below, but as you said it does not work in realtime and I get a huge file of about 40MB, even though the three mp3s only have about 4MP each... It has been recorded until the end of the longest track.

Do you want to record the mix while it's playing? If so, you could make the normal playback go through a mixer too, and then simply set/remove the encoder on it as wanted. That would mean adding the BASS_STREAM_DECODE flag to the BASS_StreamCreateFile calls and calling BASS_Mixer_StreamAddChannel instead of BASS_ChannelPlay.

Note that a mixer will add latency to changes (eg. a delay to a new file being heard) due to its playback buffer, but you can avoid that by disabling buffering via the BASS_ATTRIB_BUFFER option:

Code: [Select]
BASS_ChannelSetAttribute(mixer, BASS_ATTRIB_BUFFER, 0); // disable playback buffering
In that case, you should also set the BASS_ENCODE_QUEUE flag on the encoder to prevent the encoding delaying playback, because the lack of buffering will make the playback more susceptible to delays causing stuttering.

Can you tell me how what I described above can be done? I guess I have to add a caster to the encoder if I understood you right...
What is a caster and how does it work?

By "caster" I meant sending the encoder output to a Shoutcast/Icecast server, for your "stream this mixing channel over the internet" requirement. BASS_Encode_Castinit sets that up.

And for the second issue (streaming the mixer channel to the internet):

So far I got this:

Code: [Select]
Dim encoder = BassEnc_Mp3.BASS_Encode_MP3_Start(_recHandle, "-b 56", 0, 0, 0)BassEnc.BASS_Encode_CastInit(encoder, strStream1Ip + ":" + strStream1Port, strStream1Password, BASS_ENCODE_TYPE_MP3, strStream1Name, strStream1url, Nothing, Nothing, Nothing, Val(strStream1Bitrate), blStream1)
But thats about it. But how can I get the arguments for BASS_Encode_CastInit, like server, password, name, url, genre, desc, headers, bitrate, pub?

Do I have to register at shoutcast respectively icecast to get these?

Yes, you will need to either setup your own Shoutcast/Icecast server or use one of the server providers, which will give you the "server" and "password" paramaters to use. The other paramaters are up to you, eg. what's your stream called?

If you want to self-host, another option is BASSenc's built-in server which you can setup with BASS_Encode_ServerInit. Please see the documentation for details.

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #4 on: 15 Apr '22 - 20:16 »
OK so now I got the following:

Code: [Select]
Private streamA As Integer    Private streamB As Integer    Private mixer As IntegerPrivate Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle)        mixer = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_MIXER_END)        Bass.BASS_ChannelSetAttribute(mixer, BASSAttribute.BASS_ATTRIB_BUFFER, 0) ' disable playback buffering    End SubPrivate Sub btnPlayFile1_Click(sender As Object, e As EventArgs) Handles btnPlayFile1.Click        streamA = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\dancehall\Macka B\01 Macka B - 01.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_PRESCAN Or BASSFlag.BASS_STREAM_DECODE)        Debug.WriteLine("streamAhandle:" & CStr(streamA) & "Fehler:" & CStr(Bass.BASS_ErrorGetCode))        'there is no error here        Dim success As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, streamA, BASSFlag.BASS_MIXER_NORAMPIN Or BASSFlag.BASS_STREAM_AUTOFREE)Debug.WriteLine(CStr(success))  'there is no error here    End Sub    Private Sub btnPlayFile2_Click(sender As Object, e As EventArgs) Handles btnPlayFile2.Click        streamB = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\pop\Clueso\Weit Weg\14 Chicago.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_PRESCAN Or BASSFlag.BASS_STREAM_DECODE)        Debug.WriteLine("streamBhandle:" & CStr(streamB) & "Fehler:" & CStr(Bass.BASS_ErrorGetCode))   'there is also no error here...       Dim success As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, streamB, BASSFlag.BASS_MIXER_NORAMPIN Or BASSFlag.BASS_STREAM_AUTOFREE)Debug.WriteLine(CStr(success))    'there is no error here    End SubPrivate Sub btnMixToHD_Click(sender As Object, e As EventArgs) Handles btnMixToHD.ClickBassEnc.BASS_Encode_Start(mixer, "F:\Ablage\RecordMixToHDTest.mp3", BASSEncode.BASS_ENCODE_PCM Or BASSEncode.BASS_ENCODE_QUEUE, Nothing, IntPtr.Zero) ' Set a mp3 writer On the mixer        ' processing loop        While True            Dim encBuffer As Byte() = New Byte(20000) {}  ' processing buffer            Dim r As Integer = Bass.BASS_ChannelGetData(mixer, encBuffer, 20000) ' process the mixer            If r = -1 Then BassEnc.BASS_Encode_Stop(mixer) ' done        End WhilePrivate Sub btnStopRecording_Click(sender As Object, e As EventArgs) Handles btnStopRecording.Click        BassEnc.BASS_Encode_Stop(mixer)    End Sub
But I won't hear the mixer playing over my speakers. And the output file is still humongeous. Is it saved in *.wav-format with *.mp3 filename ending? I want to realtime record in mp3 exactly what I hear....
And it would be great if there was no decoding and encoding, but directly write data to the file...
« Last Edit: 15 Apr '22 - 20:36 by kafffee »

#### Chris

• Posts: 2069
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #5 on: 16 Apr '22 - 10:32 »
if I right understand do want to stream to icecast "what you here", so
Recording->Encoding->Sending to Icecast
is a more easy Solution.(the cast demo will show that)

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #6 on: 16 Apr '22 - 14:17 »
Yes I want to optionally (!like on a button click!) stream and/or record to disc exactly what I hear. But so far I dont hear anything, which I dont quite understand. Especially what is done in the while loop... Could you tell me what it does and explain what the condition is to the while-loop, as it only says While True. Isn't there supposed to be a condition, something like:
Code: [Select]
While MyVariable = True...End While
I just downloaded Visual Studio Code in order to better understand the cast exmaple in C, but its just too confusing to me, as I am used to VB.NET and maybe a little bit of C#...

First I want to use my own computer as a stream server with BASS_Encode_ServerInit and when this is working, I might go further and use Icecast as a relay server... Seems to be pretty interesting...

#### Ian @ un4seen

• Posts: 24427
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #7 on: 18 Apr '22 - 18:00 »
Yes I want to optionally (!like on a button click!) stream and/or record to disc exactly what I hear. But so far I dont hear anything, which I dont quite understand. Especially what is done in the while loop... Could you tell me what it does

That BASS_ChannelGetData loop is only needed if the mixer isn't played, ie. it has the BASS_STREAM_DECODE flag set. If you're playing the mixer then you can remove that loop and call BASS_ChannelPlay instead. For example, modify your code like this:

Code: [Select]
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle)        mixer = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_DEFAULT)        Bass.BASS_ChannelSetAttribute(mixer, BASSAttribute.BASS_ATTRIB_BUFFER, 0) ' disable playback buffering        Bass.BASS_ChannelPlay(mixer, False) ' start the mixer    End Sub
Note you don't want to use the BASS_MIXER_END flag on the mixer if it may sometimes have no sources (otherwise the mixer will end then).

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #8 on: 19 Apr '22 - 14:13 »
OK now it records exactly what I'm playing, thanks for that. But I want the output to be an mp3-file. Right now I am getting a 2MB file out of 11 seconds of music. I guess is PCM but with a mp3-filename...

And my Groove-Music app (standard music player on Windows 10) takes forever to load the file and sometimes even hangs up, even after a complete restart of the computer...

Right now I am using the following:

Code: [Select]
EncoderHandle = BassEnc.BASS_Encode_Start(mixer, "F:\Ablage\RecordMixToHDTest.mp3", BASSEncode.BASS_ENCODE_PCM Or BASSEncode.BASS_ENCODE_QUEUE, Nothing, IntPtr.Zero)
How do I have to set the flags and command line in order to get an mp3 file?

When I do this:

Code: [Select]
EncoderHandle = BassEnc.BASS_Encode_Start(mixer, "F:\Ablage\RecordMixToHDTest.mp3", BASSEncode.BASS_ENCODE_LIMIT Or BASSEncode.BASS_ENCODE_AUTOFREE, Nothing, IntPtr.Zero)
There will be no output file at all and ErrorCode2 - File not found...

#### Chris

• Posts: 2069
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #9 on: 19 Apr '22 - 14:32 »
do you want to encode the Mix to a shoutcast/icecast-server ? or only for saving?
by the  way the second parameter is for setup a command line string (if a other Format as Wave is wanted)
but i  would recommend to use "bassenc_mp3"

http://www.un4seen.com/doc/#bassenc_mp3/BASS_Encode_MP3_StartFile.html (encode to a local file)
http://www.un4seen.com/doc/#bassenc_mp3/BASS_Encode_MP3_Start.html (encode to a Server/Shoutcast/Icecast

if you want to encode to a Shout/Ice Server than you do both via BASS_Encode_MP3_Start (sending it to the server and save the sending Mp3 via a EncodeProc
http://www.un4seen.com/doc/#bassenc/ENCODEPROCEX.html

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #10 on: 19 Apr '22 - 14:45 »
I want to combine these options...

Lets say I have two toggle buttons which both can be used independently:

(1) Save mix to disc
(2) Stream mix to icecast server / use own computer as a server

Is this doable?

I managed to stream music via my local Network with BASS_Encode_MP3_Start and Server_Init... Is it normal that with this method I can only stream to LAN or is it possible to stream externally to the Internet if I am able to find out my external IP address?

Or do I have to use Cast_Init if I want to stream externally?
« Last Edit: 19 Apr '22 - 16:02 by kafffee »

#### Ian @ un4seen

• Posts: 24427
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #11 on: 19 Apr '22 - 16:15 »
Lets say I have two toggle buttons which both can be used independently:

(1) Save mix to disc
(2) Stream mix to icecast server / use own computer as a server

Is this doable?

You can use the same encoder to both save a local file and send to a server, but they will need to be started/stopped at the same time. If you want to start/stop them independently then you will need to use separate encoders for each (on the same mixer). Use BASS_Encode_MP3_StartFile for the local file and BASS_Encode_MP3_Start for the server, and BASS_Encode_Stop to stop either.

I managed to stream music via my local Network with BASS_Encode_MP3_Start and Server_Init... Is it normal that with this method I can only stream to LAN or is it possible to stream externally to the Internet if I am able to find out my external IP address?

External clients can connect to the server too if they know your IP address and your firewall isn't blocking them.

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #12 on: 19 Apr '22 - 17:31 »
Okay that sounds good :-)

I will try that.

What I didnt quite understand yet:

When I use _CastInit, I am asked to pass server ip and password. As a server ip, I assume I have to pass my own machine's IP. What about the password? I took a Look at icecast Web Page and couldnt find any option to register. So do I have to download icecasts console App and just add the password of my choice to the config file and run it for once?

#### Chris

• Posts: 2069
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #13 on: 19 Apr '22 - 17:49 »
the Standard Password to connect is hackme
in the icecast.etc File .

Code: [Select]
<authentication>        <!-- Sources log in with username 'source' -->        <source-password>hackme</source-password>        <!-- Relays log in with username 'relay' -->        <relay-password>hackme</relay-password>        <!-- Admin logs in with the username given below -->        <admin-user>admin</admin-user>        <admin-password>hackme</admin-password>    </authentication>
and if other Users will also connect to your local Icecast-Server you must (based on the Icecast.etc Configfile)( in your Router and in your local Firewall) forwarding Port 8000
« Last Edit: 19 Apr '22 - 17:57 by Chris »

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #14 on: 19 Apr '22 - 23:40 »
I don't really understand how this whole thing works:

(1) Do I have to run Icecast console application simultaneously to my own program?
(2) I managed to connect so icecast server with

Code: [Select]
Dim success As Boolean = BassEnc.BASS_Encode_CastInit(EncoderHandle, "xxx.xxx.x.xx:8000/meinstream.mp3", "hackme", BassEnc.BASS_ENCODE_TYPE_MP3, "MeinErsterStream", Nothing, "MeinGenre", "MeineBeschreibung", Nothing, 128, False)
But when I try to listen to xxx.xxx.x.xx:8000/meinstream.mp3, the player app says unable to connect... xxx.xxx.x.xx:8000 is my local (internal) IP address... Are you sure I dont have to pass in my external IP address? How can I obtain the address that listeners can connect to?

What I want is to use icecast as a relay server to relieve my internet upload connection... When I do this, do I still have to worry about my firewall? Because in this case, the problem seems to be obvious...
« Last Edit: 20 Apr '22 - 07:59 by kafffee »

#### Chris

• Posts: 2069
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #15 on: 20 Apr '22 - 09:03 »
Quote
Do I have to run Icecast console application simultaneously to my own program
yes
as i tell you in my last Post
for streaming Online (Outside your network) you  will need open Port 8000
Here are the link for the latest icecast Release
« Last Edit: 20 Apr '22 - 09:26 by Chris »

#### Ian @ un4seen

• Posts: 24427
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #16 on: 20 Apr '22 - 12:24 »
What I want is to use icecast as a relay server to relieve my internet upload connection... When I do this, do I still have to worry about my firewall? Because in this case, the problem seems to be obvious...

You will need to host the Icecast server outside of your local network then, so that it isn't using your connection. There are Icecast service providers that you can use to avoid having to setup everything yourself. Searching for "Icecast host" should give you plenty of such options.

Your firewall shouldn't be an issue when you're not hosting the server locally.

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #17 on: 21 Apr '22 - 07:59 »
@Chris:

OK I freed/forwarded (is there any difference?) Port 8000 on my router and firewall. I managed to connect successfully with:

Code: [Select]
Dim success As Boolean = BassEnc.BASS_Encode_CastInit(EncoderHandle, "xxx.xxx.xx.xx:8000/meinstream.mp3", "hackme", BassEnc.BASS_ENCODE_TYPE_MP3, "MeinErsterStream", Nothing, "MeinGenre", "MeineBeschreibung", Nothing, 128, False)
As an IP address I used the local IP of my computer. Same IP I used in icecast.xml config file:

Code: [Select]
<hostname>xxx.xxx.xx.xx</hostname>
The icecast web GUI tells me everythings fine and even shows the listenurl and the stream description etc...

But when I try to listen to the stream, my listening device is unable to connect...

What might be wrong?

@Ian
OK I searched for some hosts, even though I did not check all of them but they do not seem to be free of charge...

#### Chris

• Posts: 2069
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #18 on: 21 Apr '22 - 08:45 »
if you want to use it (sending and receive) only on your own PC then you can use the IP 127.0.0.1,
if you want to test it on a other PC inside your own network (same Router)  then you can use
your local ip (e.g 192.168.xxx.xxx)   (to find your local ip you can get it with ipconfig

as Hostname you can use localhost.

Of course, an Icecast server on the web is not free
because a root or a Vserver costs money.

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #19 on: 21 Apr '22 - 09:16 »
Either one (127.0.0.1 and 192.168.xxx.xxx) won't work.

Do you think the problem could be on the client side (maybe the device I am trying to play the stream on for some reason blocks?)

And also when I use

<hostname>localhost</hostname> icecast console app tells me to change it for this will cause problems...

If I dont get this working, I am tempted to try shoutcast, this seems easier to configure.

Does shoutcast app have to run simultaneously, too? Or will I be able to run it completely from my own app?

#### Chris

• Posts: 2069
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #20 on: 21 Apr '22 - 10:34 »
Icecast is much modern as Shoutcast (and Shoutcast is only for mp3, aac only with a paid Licence)

I did here a quick test
Installing Icecast win32 (and changing nothing in icecast.xml File

(The Warning in the Terminal about localhost is only if you want streaming public in the YP directory listings)

then i stream with the Cast Demo (Server "localhost:8000/live.mp3")  , Pass: hackme
it Will working fine without any Problems.
(you can test it self with the precompiled Cast Demo from the bass_enc Package. (c->Bin Directory)

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #21 on: 21 Apr '22 - 11:21 »
Ah okay I'm getting closer.

With having nothing changed in the config file, I can stream onto the same machine the stream is coming from...

But when I try to use another device in my (W)LAN, the browser says "Connection refused". Maybe something else in my router/firewall settings? I forwarded/freed port 8000 on either one...

#### Chris

• Posts: 2069
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #22 on: 21 Apr '22 - 11:32 »
in that case you must change 127.0.0.1 to your local Ip (not shure which router you use , i think your are from Germany do you have  a Avm Fritzbox?)
just open a Terminal window via cmd and then just type ipconfig) there you can find your local ip. Should start mostly with 192.168.......

#### kafffee

• Posts: 93
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #23 on: 21 Apr '22 - 12:12 »
Yes I'm from Germany, you, too, right? I am using the standard cable router by Unitymedia respectively Vodafone.

I am getting the following output from command line:

IPv4-address - which is my computer I guess
standard gateway - this must be my router

Neither one nor the other works...

Maybe one of the other addresses (IPv6)?

But they have another format, for instance:

xxxx:xxxx:xxxx:xxxx::x

#### Chris

• Posts: 2069
##### Re: Mixing two stream channels and record result to hard disk/stream to web
« Reply #24 on: 21 Apr '22 - 13:07 »
i have send you an PM