Author Topic: EncoderLAME with Bass.Net and mono  (Read 1831 times)

teegee

  • Posts: 5
EncoderLAME with Bass.Net and mono
« on: 21 Sep '11 - 13:49 »
Hi,

I'm trying to get my head around encoding mp3 files on linux. I'm simply converting files from .ogg to .mp3.
I added all required bass dll mappings to /etc/mono/config. I'm also using the following dllmap for lame_enc.dll:
Code: [Select]
<dllmap dll="lame_enc.dll" target="mp3lame.so" />and I placed a copy of libmp3lame.so along with lame.exe in the folder where my executable is being generated.
I'm calling BASS_Init() to set up the encoder and when I try to encode a file the Bass splash screen shows up and calling EncodeFile() returns true with the following statement:
Code: [Select]
BaseEncoder.EncodeFile(InputFile, OutputFile, _encoder, new BaseEncoder.ENCODEFILEPROC(EncodeProgressCallback), true, false, true)So far, so good. Unfortunately, the mp3 files aren't written where they should be, in fact, they're not written at all. lsof during the encoding confirms that no mp3 files are open. What am I missing?

Cheers,
  Tom

radio42

  • Posts: 4576
Re: EncoderLAME with Bass.Net and mono
« Reply #1 on: 21 Sep '11 - 19:44 »
Note, that BASSenc doesn't support lame_enc.dll - but only the lame.exe.
So make sure lame.exe (linux version) exists in your executable directory.
I also don't see the code on how you created the '_encoder' instance...are you using 'EncoderLAME' ?

teegee

  • Posts: 5
Re: EncoderLAME with Bass.Net and mono
« Reply #2 on: 22 Sep '11 - 12:19 »
When you say the linux version of lame.exe, do you mean the standard linux lame or something else?
I installed lame and linked it to lame.exe in the executable directory. I also tried without the link. Both times, no file was encoded but EncodeFile() returned true.

Here's the code for creating the _encoder instance. Variables are getting passed in from the config form:
Code: [Select]
_encoder = new EncoderLAME(0);
Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_NOSPEAKER, System.IntPtr.Zero);
_encoder.LAME_Bitrate = (int)_config.MinBitrate; // 112
_encoder.LAME_EnforceCBR = _config.EnforceCBR; // false
_encoder.LAME_LimitVBR = _config.LimitVBR; // true
_encoder.LAME_Mode = _config.Mode; // Stereo
_encoder.LAME_Quality = _config.Quality; // Q4
_encoder.LAME_UseVBR = _config.UseVBR; // true
_encoder.LAME_VBRMaxBitrate = (int)_config.VBRMaxBitrate; // 256
_encoder.LAME_ABRBitrate = _config.ABR; // 128
Cheers,
  Tom

radio42

  • Posts: 4576
Re: EncoderLAME with Bass.Net and mono
« Reply #3 on: 22 Sep '11 - 12:34 »
I am actually not really a Linux pro - so I am not sure what might go wrong in your case...

teegee

  • Posts: 5
Re: EncoderLAME with Bass.Net and mono
« Reply #4 on: 22 Sep '11 - 13:14 »
Could anyone else who has done this before provide a helpful comment, please?

Ian @ un4seen

  • Administrator
  • Posts: 20424
Re: EncoderLAME with Bass.Net and mono
« Reply #5 on: 22 Sep '11 - 15:02 »
I haven't tried encoding with Mono on Linux myself, but to confirm that LAME is installed and working properly, you could try building (open a Terminal and type "make") and running the RECTEST or CONTEST example from the BASSenc package. If that works fine, you could then try using the BASSenc functions directly (eg. BASS_Encode_Start) in your code (as in the examples), and see if you have any luck with that.

teegee

  • Posts: 5
Re: EncoderLAME with Bass.Net and mono
« Reply #6 on: 27 Sep '11 - 11:21 »
I've tried out the contest example for the bass and bassenc package - they both compile and run alright. I have then replaced the simple EncodeFile() command in my code with BASS_StreamCreateFile(), BASS_Encode_Start() and BASS_ChannelGetData() similar to the c examples, and, after tweaking the commandline string a little bit, I got the encoding to work. I suppose that's good and bad news. Since I have no idea how to debug the EncodeFile() and there don't seem to be too many people around with the same problem, I will probably just stick with the more complicated version and rewrite my configuration parser to come up with command line options instead of parameters to pass to an EncoderLAME object.
Unless there are other suggestions how to get the EncodeFile() to work.
Thanks for the suggestion.

radio42

  • Posts: 4576
Re: EncoderLAME with Bass.Net and mono
« Reply #7 on: 27 Sep '11 - 12:21 »
To see what the difference might be, please try the following:
After setting the EncoderLAME properties (i.e. _encoder.LAME_xxx) please call the "EncoderCommandLine" property to retrieve the command-line options effectively being used by the EncoderLAME instance.
And then compare them with your 'own' command-line options.
There must be a noticable difference...

teegee

  • Posts: 5
Re: EncoderLAME with Bass.Net and mono
« Reply #8 on: 27 Sep '11 - 22:04 »
It turns out the commandline is identical and the problem was in front of the screen :/
I realised that executing lame.exe didn't work because ./ wasn't in my search path, so linking lame into the executable directory didn't do anything. With that silly mistake fixed, I got it all working just fine.
Just one suggestion: change the commandline to 'lame ...' instead of 'lame.exe ...' if it's run on a unix system.