Author Topic: BassAac.BASS_MP4_StreamCreateFile  (Read 863 times)

toob

  • Posts: 133
BassAac.BASS_MP4_StreamCreateFile
« on: 27 Sep '10 - 15:31 »
Hi

Is there a better / faster way to encode an .m4a file to mp3 file other than using BassAac.BASS_MP4_StreamCreateFile and BassEnc.BASS_Encode_Start. Currently I stream the file then use lame to encode but it takes as long as it take the track to play to finish.

I've looked into using EncoderMP3 & BaseEncoder.EncodeFile but get error 41 unsupported file format so I guess this means I cant do it without streaming or can I?

thanks


radio42

  • Posts: 4576
Re: BassAac.BASS_MP4_StreamCreateFile
« Reply #1 on: 27 Sep '10 - 16:22 »
You can.
Just create a decoding source stream and call BASS_ChannelGetData in a loop to process all the data of that source.
Note, that BaseEncoder.EncodeFile uses the BASS plugin system - so probably you haven't loaded the aac plugin via BASS_PLuginLoad.

toob

  • Posts: 133
Re: BassAac.BASS_MP4_StreamCreateFile
« Reply #2 on: 28 Sep '10 - 10:00 »
great new and thanks for the reply

this is what I have now

Code: [Select]
Dim pluginMP3 As Integer = Bass.BASS_PluginLoad("bass_aac.dll")
Dim mp3 As New EncoderMP3(0)
mp3.InputFile = "test1.m4a"
mp3.OutputFile = "testmp3.mp3"

Dim encResult = BaseEncoder.EncodeFile(mp3, New BaseEncoder.ENCODEFILEPROC(AddressOf FileEncodingNotification), True, False)

....

Public Sub FileEncodingNotification(ByVal bytesTotal As Long, ByVal bytesDone As Long)
    Me.ProgressBar1.Value = Math.Round(CDbl(bytesDone) / CDbl(bytesTotal), 2) * 100
End Sub


I've downloaded "mp3sEncoder.exe" (544KB) and everything is in the same folder.

The command line variable reads:
"mp3sEncoder.exe -raw -sr 44100 -c 2 -res 16 -q 1 -br 128000 -if "test1.m4a" -of "testmp3.mp3""

When run, the progressbar progresses as if it's doing something and Bass.BASS_ErrorGetCode returns 0 but no output file is created.

I've tried it with full paths to the input and output file but no joy. I don't think it's encoding as there is no disk activity that I can see other that when it opens the input file.

What could be up?

thanks

toob

  • Posts: 133
Re: BassAac.BASS_MP4_StreamCreateFile
« Reply #3 on: 28 Sep '10 - 10:11 »
well that's strange..

I ran it on the command line and it initially displayed a user agreement. This only appears to display once so when I tried it from my bass.net code it worked.

Question, if I distribute "mp3sEncoder.exe" with my app am I not going to run into similar issues and if so what is the solution? I guess it must write something somewhere so it knows the agreement has been read, any ideas?

radio42

  • Posts: 4576
Re: BassAac.BASS_MP4_StreamCreateFile
« Reply #4 on: 28 Sep '10 - 11:09 »
a) yes, that encoder requires an initial agreement to be confirmed by the user before the encoder is actually working
b) when you read the agreement you'll know, that you are not allowed to distribute the encoder with your app
c) that encoder is a 'for private use only encoder'
d) there is nothing to do about this behaviour - so your user have to download and confirm the agreement by theirself

Alternatively you might:
e) use 'lame.exe' (which by the way requires you to have a license from Thompson)
f) use a windows installed ACM MP3 encoder