Author Topic: MP3 encoding options - I can't make it work... (SOLVED)  (Read 204 times)


  • Posts: 21
I successfully encode streams into MP3 streams and files, but anything that I enter as options is ignored, and the mp3 is always encoded with the default options.

For example, the default bitrate is 128, and I would like to make smaller files, with a bitrate of 96 or lower, and so I tried using Lame's -b96 command to apply a 96 bitrate, like this...

   BASS_Encode_MP3_Start(HINPUT, '-b96',  0, @Callback, nil);

...but the result is always a file with 128k bitrate.

I use Windows and Pascal. I tried with different strings, with and without spaces (-b 96, -b96), I tried with variable bitrate syntax e.g. --abr 96 and many other Lame parameters and variations that I could find, but the result is always 128k.

What am I doing wrong? What should i write in that string? Can anyone show me the options string to use to get a 96k bitrate, for example, instead of the default? If I can get just one example that works, I can take it from there...

Thank you!
« Last Edit: 15 Nov '21 - 17:19 by ManlioMZ »


  • Posts: 1993
Re: MP3 encoding options - I can't make it work...
« Reply #1 on: 15 Nov '21 - 14:44 »
Are you working with lazarus or with delphi?
which kind of Stream is HInput ?
the optionsstring should to be a PWideChar
if using delphi then with Bass_Unicode(UTF-16), in Lazarus(UTF-8 or ISO-8859-1) without that flag
try it on this way
Code: [Select]
BASS_Encode_MP3_Start(HINPUT,PWideChar('-b 96'), BASS_UNICODE, @Callback, nil); if   (Bass_ErrorGetCode = BASS_ERROR_ILLPARAM) // something in the optionsstring is wrong
« Last Edit: 15 Nov '21 - 14:53 by Chris »


  • Posts: 21
Re: MP3 encoding options - I can't make it work...
« Reply #2 on: 15 Nov '21 - 17:18 »
Thanks Chris! Now it works, the BASS_UNICODE flag was perhaps the problem.

This is the call that works (Lazarus, 32 bit, Windows):

Code: [Select]
    s := '-b ' + IntToStr(BitRate);
    HMP3 := BASS_Encode_MP3_Start(HINPUT, PChar(s), 0, @Callback, nil);

1. Please note that although you said that the options string is PWideChar, that causes a compilation error, since the BASSenc_MP3 unit declares:
Code: [Select]
   function BASS_Encode_MP3_Start(handle:DWORD; options:PChar; flags:DWORD; proc:ENCODEPROCEX; user:Pointer): HENCODE; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external bassencmp3dll;

2. The LAME specs that I saw don't include a space between -b and the bitrate number (e.g: -b96) but BASS accepts it both with and without the space (e.g. both -b96 and -b 96) and it works in both cases, so that's a good thing I suppose!

Thanks again!