Author Topic: Issue with encoding on mac  (Read 68 times)

scarboni

  • Posts: 32
Issue with encoding on mac
« on: 6 Jan '21 - 13:27 »
Hello !

I have a code that works fine on windows to cast from a mixer to shoutcast 1, 2, and icecast serveur.
However, from mac, my encoder dies as soon as I start to cast, the server react for a moment, and before I can listen to anything, the encoder dies out. I receive BASS_ENCODE_NOTIFY_ENCODER this signal from
Code: [Select]

    // BASS_Encode_Start
    this._encoder = this.objBass.BASS_Encode_Start(
      this.mixer.enc, //mixer to encode
      `${this.lamepath} -r -m s -s ${this.SAMPLE_RATE} -b ${this.BIT_RATE} -`,
      this.objBass.BASS_Encode_Startflags.BASS_ENCODE_NOHEAD
    );

    // error management
    if (this._encoder === 0) {
      console.log("error);
      //error
      this.stopStreamingInt(event);
      return;
    } else {
      console.log("Encoder channel: " +this._encoder);
    }

    const bam = this;

    var watchConnection = this.objBass.BASS_Encode_SetNotify(
      this._encoder,
      function (handle, status, user) {
        // bam.stopStreamingInt(event);
        console.log("server connection is dead :" + status);
        for (let prop in bam.objBass.EncoderNotifyStatus) {
          if (bam.objBass.EncoderNotifyStatus[prop] === status) {
            console.log(prop);
          }
        }
        // }
      }
    );

    // BASS_Encode_CastInit

    if (!this.encoderProtocol) {
      this.stopStreamingInt(event);
      return;
    }
    const isCast = this.objBass.BASS_Encode_CastInit(
      this._encoder,
      this.streamURL,
      this.streamID,
      this.objBass.BASS_Encode_CastInitcontentMIMEtypes.BASS_ENCODE_TYPE_MP3,
      "",
      "",
      "",
      null,
      null,
      this.BIT_RATE,
      true
    );


    if (!isCast) {
      console.log("error at BASS_Encode_CastInit: " + this.objBass.BASS_ErrorGetCode());
      this.stopStreamingInt(event);
      return;
    } else {
      console.log("CastInit success" +"listen @ " +this.streamURL);
    }

....

  stopStreamingInt(event) {
    if (this._encoder) this.objBass.BASS_Encode_Stop(this._encoder);
    this._encoder = null;
  }

I get this output :
Encoder channel:  12289
CastInit success listen @ serveradress:port/PUB
server connection is dead :1
BASS_ENCODE_NOTIFY_ENCODER

Everythin related to encoding is here. The encoder seems to work on command line in the terminal, I took it on https://www.rarewares.org/mp3-lame-bundle.php
I have an apple chip, and took the LAME 3.100 for Apple Silicon (arm64) processors.

I wanted to try your code example given with bassenc.dylib (to check if the issue is from my lame executable or somewhere else), but, I'm new to xcode and I did not succeed in trying it out. I have added the needed dylib, but not lame yet, I get this message when I successfully compile (but I can not find the executable?)  :
"
2021-01-06 13:33:32.139015+0100 convert[12106:316632] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x10051ae40> F8BB1C28-BAE8-11D6-9C31-00039315CD46
BASSenc transcoding example
---------------------------
usage: convert [-e#] <file> [encoder options]
-e = encoder: 0=wav, 1=aiff, 2=lame, 3=oggenc, 4=opusenc, 5=flac, 6=aac, 7=alac
Program ended with exit code: 126
"

I do not understand this message, what should I do here ?

Ian @ un4seen

  • Administrator
  • Posts: 23288
Re: Issue with encoding on mac
« Reply #1 on: 6 Jan '21 - 14:20 »
You should find your compiled executable in a sub-folder of the "build" folder, eg. "build/Release". As it's a console app, you will need to open a Terminal window there to run it.

Regarding installing the LAME executable, you can do that by putting it in the "/usr/local/bin" folder. For simplicity, I would recommend using the BASSenc_MP3 add-on instead, eg. BASS_Encode_MP3_Start instead of BASS_Encode_Start.

scarboni

  • Posts: 32
Re: Issue with encoding on mac
« Reply #2 on: 6 Jan '21 - 16:30 »
Thank you, I will look into that. So, just to be sure with BASSenc_MP3, I have no need at all for lame? Is it right ? I will work on adding it on my wrapper. :)

Ian @ un4seen

  • Administrator
  • Posts: 23288
Re: Issue with encoding on mac
« Reply #3 on: 6 Jan '21 - 17:01 »
Yes, that is correct. BASSenc_MP3 has the LAME encoder built-in, so you don't need a separate LAME executable when using it.