Author Topic: Streaming to ICEcast not working: Error_EncoderError  (Read 999 times)

-lukas-

  • Posts: 23
Hello,
please help with the streaming to Icecast.

I have this VB.net code:
Code: [Select]
    Dim _recHandle As Integer
    Dim _broadCast As BroadCast

    Public Sub StreamTest()

        _recHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_DEFAULT, Nothing, 0)
        Bass.BASS_ChannelPlay(_recHandle, False)

        Dim lame As New EncoderLAME(_recHandle)
        With lame
            .InputFile = Nothing
            .OutputFile = Nothing
            .LAME_Bitrate = CInt(EncoderLAME.BITRATE.kbps_48)
            .LAME_Mode = EncoderLAME.LAMEMode.Mono
            .LAME_TargetSampleRate = CInt(EncoderLAME.SAMPLERATE.Hz_44100)
            .LAME_Quality = EncoderLAME.LAMEQuality.Quality
        End With

        Dim icecast As New ICEcast(lame, True)
        With icecast
            .ServerAddress = "123.123.123.123"
            .ServerPort = 1234
            .Password = "somepsw"
            .MountPoint = "point.mp3"
            .Username = "source"
            .StreamName = "VPS"
            .PublicFlag = False
        End With

        _broadCast = New BroadCast(icecast)
        _broadCast.AutoReconnect = True
        AddHandler _broadCast.Notification, AddressOf OnBroadCast_Notification
        _broadCast.AutoConnect()

    End Sub

    Private Sub OnBroadCast_Notification(ByVal sender As Object, ByVal e As BroadCastEventArgs)

        If _broadCast Is Nothing Then
            Return
        End If

        If _broadCast.IsConnected Then

        Else

        End If

        MsgBox(_broadCast.Server.LastError.ToString & ": " & _broadCast.Server.LastErrorMessage)

    End Sub

... In the function OnBroadCast_Notification I returned this error code:
"Error_EncoderError: Encoder not active or a connction to the server could not be established!"

Do you have any tips, please, what's the problem?

I have a bass + bass.net in the current version. Connecting to the server I tested the with software b.u.t.t (with the same login) and works without problems...

Thanks,
-lukas-

radio42

  • Posts: 4573
Do you have the lame.exe in the same folder as the bass.dll and bassenc.dll?
Also try to add a slash infront of the mountpoint, i.e. "/point.mp3"

-lukas-

  • Posts: 23
Yes, lame.exe is in the same folder as bass.dll and bassenc.dll.
(Mp3 playback and recording in other parts of my program works well.)

Ian @ un4seen

  • Administrator
  • Posts: 20389
To help narrow down what the problem is, please see if you can reproduce it with the pre-compiled CAST.EXE example that's included in the BASSenc package (C\BIN folder).

radio42

  • Posts: 4573
And also try to add a slash infront of the mountpoint, i.e. "/point.mp3" - as suggested above

-lukas-

  • Posts: 23
I added a slash at the beginning. The error no longer occurs, the connection is bound for a while, but for the moment falls...

Thanks for the tip on cast.exe. I like to give it a try. Somehow I can not understand how to use it. When I run it, it appears to me this message:
Application (0xc000007b) failed to start correctly. Click OK to exit the application.
Does it start with a parameter? Or how to do it? :)

Ian @ un4seen

  • Administrator
  • Posts: 20389
No, you don't need to provide any parameters; you can just double-click on the CAST.EXE file. Regarding the error message, please check that you copied the 32-bit (not x64) BASS.DLL and BASSENC.DLL files into the same folder as the EXE.

-lukas-

  • Posts: 23
Thanks! With cast.exe it works :-) ... but not with my code  :'(

I created a new "clean" project with this code. Please what is wrong in this code?  ???

Code: [Select]
Imports Bass = Un4seen.Bass.Bass
Imports Un4seen.Bass

Public Class Form1

    Dim _recHandle As Integer
    Dim _broadCast As Misc.BroadCast

    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Bass.LoadMe()
    End Sub

    Private Sub StartStream(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        _recHandle = Bass.BASS_RecordStart(44100, 1, BASSFlag.BASS_DEFAULT, Nothing, 0)
        Bass.BASS_ChannelPlay(_recHandle, False)

        Dim lame As New Misc.EncoderLAME(_recHandle)
        With lame
            .InputFile = Nothing
            .OutputFile = Nothing
            .LAME_Bitrate = CInt(Misc.EncoderLAME.BITRATE.kbps_48)
            .LAME_Mode = Misc.EncoderLAME.LAMEMode.Mono
            .LAME_TargetSampleRate = CInt(Misc.EncoderLAME.SAMPLERATE.Hz_44100)
            .LAME_Quality = Misc.EncoderLAME.LAMEQuality.Quality
        End With

        Dim icecast As New Misc.ICEcast(lame, True)
        With icecast
            .ServerAddress = "123.123.123.123"
            .ServerPort = 8000
            .Password = "1234"
            .MountPoint = "/point.mp3"
            .Username = "source"
            .StreamName = "VPS"
            .PublicFlag = False
        End With

        _broadCast = New Misc.BroadCast(icecast)
        _broadCast.AutoReconnect = True
        AddHandler _broadCast.Notification, AddressOf OnBroadCast_Notification
        _broadCast.AutoConnect()

    End Sub

    Private Sub OnBroadCast_Notification(ByVal sender As Object, ByVal e As Misc.BroadCastEventArgs)
        BroadcastDiag()
    End Sub

    'Every 1,5 sec call BroadcastDiag
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        BroadcastDiag()
    End Sub
   
    'Print debug info to console
    Public Sub BroadcastDiag()

        If _broadCast Is Nothing Then Return

        System.Diagnostics.Trace.Write(_broadCast.Status.ToString & ";  Listeners: " & _broadCast.GetListeners("1234") & ";  Sent: " & _broadCast.TotalBytesSend & "; Seconds: " & CInt(_broadCast.TotalConnectionTime.TotalSeconds))

        'On Error, print it to console
        If _broadCast.Server.LastError <> Misc.StreamingServer.STREAMINGERROR.Ok Then
            System.Diagnostics.Trace.Write("; " & _broadCast.Server.LastError.ToString & ": " & _broadCast.Server.LastErrorMessage)
        End If
        System.Diagnostics.Trace.Write(vbCrLf)

    End Sub

End Class

Function BroadcastDiag me periodically prints the status and the results are just following errors:
Code: [Select]
NotConnected;  Listeners: -1;  Sent: -1; Seconds: 0; Error_EncoderError: Some mystery problem occurred when trying to start the encoder!
NotConnected;  Listeners: -1;  Sent: -1; Seconds: 1; Error_EncoderError: Some mystery problem occurred when trying to start the encoder!
NotConnected;  Listeners: -1;  Sent: -1; Seconds: 3; Error_EncoderError: Some mystery problem occurred when trying to start the encoder!
...
« Last Edit: 9 Mar '16 - 14:13 by -lukas- »

-lukas-

  • Posts: 23
Please have you an idea what to do? What to try?  :-[

Ian @ un4seen

  • Administrator
  • Posts: 20389
I notice you're currently not providing a RECORDPROC callback function in your BASS_RecordStart call. Please try adding that (it can simply "return true"). If you don't use a RECORDPROC function, you will need to repeatedly call BASS_ChannelGetData on the recording handle instead, otherwise the recorded data won't get processed (eg. encoded).

-lukas-

  • Posts: 23
Re: Streaming to ICEcast not working: Error_EncoderError
« Reply #10 on: 9 Mar '16 - 17:37 »
Ian, Thank you very much for your response!

I modified the code:
Code: [Select]
    _recHandle = Bass.BASS_RecordStart(44100, 1, BASSFlag.BASS_DEFAULT, AddressOf RecordProc, 0)
    ...
    Private Function RecordProc(ByVal handle As Integer, ByVal buffer As IntPtr, ByVal length As Integer, ByVal user As IntPtr) As Boolean
        Return True
    End Function

On error but nothing changed :( Still the same error: Error_EncoderError: Some mystery problem occurred when trying to start the encoder!

radio42

  • Posts: 4573
Re: Streaming to ICEcast not working: Error_EncoderError
« Reply #11 on: 9 Mar '16 - 18:55 »
What version of lame.exe are you using?

-lukas-

  • Posts: 23
Re: Streaming to ICEcast not working: Error_EncoderError
« Reply #12 on: 9 Mar '16 - 19:45 »
radio42, thank you very much for the quick response.

Version lame.exe is: LAME 32bits version 3.98.2 (http://www.mp3dev.org/)
I tried now also this version: LAME 32bits version 3.99.5 (http://lame.sf.net)

Result is in both cases identical :(

radio42

  • Posts: 4573
Re: Streaming to ICEcast not working: Error_EncoderError
« Reply #13 on: 10 Mar '16 - 12:22 »
One more thing which just came into my mind.
Could you may be try some other lame settings, e.g. 44100Hz, Joint-stereo and 128kbps

As far as I recall has lame a few restrictions on certain combinations of settings - so maybe your combo of mode, bitrate and mono/stereo is not valid?

MPEG-1   layer III sample frequencies (kHz):  32  48  44.1
bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320

MPEG-2   layer III sample frequencies (kHz):  16  24  22.05
bitrates (kbps):  8 16 24 32 40 48 56 64 80 96 112 128 144 160

MPEG-2.5 layer III sample frequencies (kHz):   8  12  11.025
bitrates (kbps):  8 16 24 32 40 48 56 64

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: Streaming to ICEcast not working: Error_EncoderError
« Reply #14 on: 10 Mar '16 - 15:05 »
Still the same error: Error_EncoderError: Some mystery problem occurred when trying to start the encoder!

To confirm whether the problem is indeed happening when trying to start the encoder, what happens if you try starting the LAME encoder yourself (via lame.Start) without the broadcast stuff? If that fails (returns false), please also call BASS_ErrorGetCode straight after to get the error code.

-lukas-

  • Posts: 23
Re: Streaming to ICEcast not working: Error_EncoderError
« Reply #15 on: 10 Mar '16 - 21:44 »
radio42 and Ian, Thank you very much for your answers!

I tried these changes and tests:

1) I tried to change the combination of frequency, mono / stereo / dual mono / ... It had no effect on the non-functioning.

2) Instead of recording from a microphone:
Code: [Select]
_recHandle = Bass.BASS_RecordStart(44100, 1, BASSFlag.BASS_DEFAULT, AddressOf MyRecording, IntPtr.Zero)...I tried to put file playback as follows:
Code: [Select]
_recHandle = Bass.BASS_StreamCreateFile("song.mp3", 0, 0, BASSFlag.BASS_MUSIC_FLOAT)Result is: Stream runs perfectly :o ...but from the file and not from a microphone. So the problem is probably somewhere in the input device? But the microphone in the Windows operating normally...

3) I tried to edit the code, me to learned something about the input devices like this:
Code: [Select]
        If Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero) = False Then
            Me.Close()
        End If

        Trace.WriteLine("BASS_GetDeviceCount: " & Bass.BASS_GetDeviceCount)
        Trace.WriteLine("BASS_GetInfo: " & Bass.BASS_GetInfo.ToString)
        Trace.WriteLine("BASS_RecordGetDeviceCount: " & Bass.BASS_RecordGetDeviceCount)
        Trace.WriteLine("BASS_RecordGetDeviceInfo: " & Bass.BASS_RecordGetDeviceInfo(0).ToString)
        Trace.WriteLine("BASS_RecordGetInput: " & Bass.BASS_RecordGetInput(0).ToString)
With these results:
Quote
BASS_GetDeviceCount: 2
BASS_GetInfo: Speakers=2, MinRate=100, MaxRate=200000, DX=9, EAX=False
BASS_RecordGetDeviceCount: 1
BASS_RecordGetDeviceInfo: Microphone (Audio Device)
BASS_RecordGetInput: BASS_INPUT_NONE
Is last line "BASS_RecordGetInput: BASS_INPUT_NONE" ok?

4) I tried to run directly lame.Start and read the error:
Code: [Select]
        _recHandle = Bass.BASS_RecordStart(44100, 1, BASSFlag.BASS_DEFAULT, AddressOf MyRecording, IntPtr.Zero)
        Trace.WriteLine("_recHandle: " & _recHandle)

        Dim lame As New Misc.EncoderLAME(_recHandle)
        With lame
            .InputFile = Nothing
            .OutputFile = Nothing
            .LAME_Bitrate = CInt(Misc.EncoderLAME.BITRATE.kbps_48)
            .LAME_Mode = Misc.EncoderLAME.LAMEMode.Mono
            .LAME_TargetSampleRate = CInt(Misc.EncoderLAME.SAMPLERATE.Hz_44100)
            .LAME_Quality = Misc.EncoderLAME.LAMEQuality.Quality
        End With
        Bass.BASS_ChannelPlay(_recHandle, False)

        Trace.WriteLine("lame.Start: " & lame.Start(Nothing, IntPtr.Zero, False))
        Trace.WriteLine("BASS_ErrorGetCode: " & Bass.BASS_ErrorGetCode.ToString)
With these results:
Quote
_recHandle: 0
lame.Start: False
BASS_ErrorGetCode: BASS_ERROR_HANDLE

Many times, many thanks for your help!

radio42

  • Posts: 4573
Re: Streaming to ICEcast not working: Error_EncoderError
« Reply #16 on: 11 Mar '16 - 08:05 »
Did you actually call BASS_RecordInit to initialize your recording device ?!
If not... please do so... ;-)

-lukas-

  • Posts: 23
Re: Streaming to ICEcast not working: Error_EncoderError
« Reply #17 on: 11 Mar '16 - 14:48 »
Oh yeah :( Such a small thing! ::) I am ashamed... ;) I thank you for your patience!

Is enough add a little line before others:
Code: [Select]
Bass.BASS_RecordInit(-1)