Author Topic: Encode FLAC  (Read 137 times)

rv

  • Posts: 188
Encode FLAC
« on: 5 Sep '17 - 19:00 »
After 3 hours trying to encode my mixer handle (float) using BASS_Encode_Start with flac.exe  / unicode because of.net
Directly to a file "c:\to-to\aaa.flac"

Tried a lot of different command line, but I failed to do it

The file is simply not created, even if I get a handle from  BASS_Encode_Start

Do you have an idea how to encode a stream to a flac file?

Ian @ un4seen

  • Administrator
  • Posts: 20286
Re: Encode FLAC
« Reply #1 on: 6 Sep '17 - 17:56 »
For reference, is FLAC encoding working with the pre-compiled CONTEST.EXE example included in the BASSenc package (C\BIN folder)? If that's working, please confirm what parameters you are using in your BASS_Encode_Start call, and what the call's return value is. The CONTEST example uses the "flac -f -o bass.flac -" command-line for FLAC encoding.

radio42

  • Posts: 4560
Re: Encode FLAC
« Reply #2 on: 6 Sep '17 - 20:06 »
Maybe you can post a bit of your code how you are using it?
Else have you tried this:
http://www.bass.radio42.com/help/html/53d3394f-6acf-c797-c21e-700ce5204826.htm

rv

  • Posts: 188
Re: Encode FLAC
« Reply #3 on: 6 Sep '17 - 23:02 »
BASS_Encode_Start returns different values like  528  1188   1336....
The simple command line "flac -f -o bass.flac -"  did not work

I have tried many many many options but basically my vb.net code is :
_EncoderHandle = BASS_Encode_Start(_AudioStream, "flac -f -o bass.flac", BASS_UNICODE Or BASS_ENCODE_QUEUE Or BASS_ENCODE_AUTOFREE, IntPtr.Zero, IntPtr.Zero)

I don't have bass.net

The difference with the Contest exemple is that the _AudioStream is a Floating Point mixer  and that .net strings are unicode

I still have no output file created very strange...

rv

  • Posts: 188
Re: Encode FLAC
« Reply #4 on: 6 Sep '17 - 23:07 »
Is it a problem if my app is x64 and flac.exe is x32 ?

I don't have any problem using lame.exe 32 bit from 64 bit programs to enconde in mp3

rv

  • Posts: 188
Re: Encode FLAC
« Reply #5 on: 6 Sep '17 - 23:10 »
mmm... look at this :

https://sourceforge.net/p/flac/bugs/447/

Unfortunately, as a vb.net programmer, I can't compile C here... If someone can do it for me to try, from the last FLAC source code ?

Ian @ un4seen

  • Administrator
  • Posts: 20286
Re: Encode FLAC
« Reply #6 on: 7 Sep '17 - 14:31 »
BASS_Encode_Start returns different values like  528  1188   1336....
The simple command line "flac -f -o bass.flac -"  did not work

I have tried many many many options but basically my vb.net code is :
_EncoderHandle = BASS_Encode_Start(_AudioStream, "flac -f -o bass.flac", BASS_UNICODE Or BASS_ENCODE_QUEUE Or BASS_ENCODE_AUTOFREE, IntPtr.Zero, IntPtr.Zero)

I don't have bass.net

The difference with the Contest exemple is that the _AudioStream is a Floating Point mixer  and that .net strings are unicode

I still have no output file created very strange...

Just to be sure, which of those command-lines are you using? The one in the BASS_Encode_Start call doesn't include the trailing '-' character, which is needed. If it still isn't working with that included, is FLAC encoding working with the pre-compiled CONTEST.EXE example from the BASSenc package?

mmm... look at this :

https://sourceforge.net/p/flac/bugs/447/

Unfortunately, as a vb.net programmer, I can't compile C here... If someone can do it for me to try, from the last FLAC source code ?

As you aren't using any funky characters in the command-line, Unicode support shouldn't really be needed in the FLAC encoder.

rv

  • Posts: 188
Re: Encode FLAC
« Reply #7 on: 7 Sep '17 - 15:03 »
From what I understand, from vb.net all strings are unicode based
If I don't use BASS_UNICODE flag, BASS will not understand my strings to send them to FLAC

Ian @ un4seen

  • Administrator
  • Posts: 20286
Re: Encode FLAC
« Reply #8 on: 7 Sep '17 - 15:25 »
Yes, you should use the BASS_UNICODE flag in your BASS_Encode_Start call. The command-line will be converted to ANSI by Windows when the encoder is launched.

I missed your question regarding a 64-bit app using a 32-bit encoder. That will be fine because they are running in separate processes (it would be a problem if the encoder was in a DLL instead of an EXE).

rv

  • Posts: 188
Re: Encode FLAC
« Reply #9 on: 7 Sep '17 - 16:32 »
The Contest exemple does not work neither

I am using the latest official flac.exe official version 1.3.2
https://ftp.osuosl.org/pub/xiph/releases/flac/

Ian @ un4seen

  • Administrator
  • Posts: 20286
Re: Encode FLAC
« Reply #10 on: 7 Sep '17 - 16:56 »
That's strange. I tried the CONTEST.EXE example with FLAC.EXE v1.3.2 just now, and it worked fine, ie. it produced a working BASS.FLAC file. Does it give any error message when you try it?

rv

  • Posts: 188
Re: Encode FLAC
« Reply #11 on: 7 Sep '17 - 18:18 »
AH... In fact contest.exe is well working.  the destination flac folder was simply not the same as the source wav file, but the cmd current directory .

However my program is still not working :(

Can you please try to encode a simple floating point stream to a flac file with a unicode string as the command line ?

rv

  • Posts: 188
Re: Encode FLAC
« Reply #12 on: 7 Sep '17 - 18:22 »
ooooo... it is now working...

Will tell you ...

rv

  • Posts: 188
Re: Encode FLAC
« Reply #13 on: 7 Sep '17 - 18:41 »
BASS_ENCODE_FP_16BIT was the solution  ;D

Ian @ un4seen

  • Administrator
  • Posts: 20286
Re: Encode FLAC
« Reply #14 on: 8 Sep '17 - 14:36 »
Oh yes, I see you said you're using floating-point sample data. FLAC doesn't support floating-point, so you will indeed need to use one of the BASS_ENCODE_FP flags (in the BASS_Encode_Start call) to have BASSenc convert the data to integer before it's sent to the encoder.