24 May '13 - 09:58 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: How to Encode WMA Internet stream without ChannelPlay  (Read 2137 times)
audiowally
Posts: 6


« on: 4 Mar '06 - 19:15 »
Reply with quoteQuote

How would one go about encoding a WMA internet stream without using channelplay? What I really would like to do is just decode the WMS stream only and pass it to a WMA encoder routine so I do not need a sound card. Is it possible with the channelgetdata and if so how would I do that with a callback routine?
Thanks
Logged
Ian @ un4seen
Administrator
Posts: 15270


« Reply #1 on: 5 Mar '06 - 15:00 »
Reply with quoteQuote

You would create a decoding channel (BASS_STREAM_DECODE), and call BASS_ChannelGetData and BASS_WMA_EncodeWrite in a loop to decode and re-encode the data...

BASS_Init(0,44100,0,0,0); // "no sound" device - no soundcard needed

HSTREAM decoder=BASS_WMA_StreamCreateFile(FALSE,url,0,0,BASS_STREAM_DECODE); // open stream
BASS_CHANNELINFO info;
BASS_GetChannelInfo(decoder,&info); // get stream format info
HWMENCODE encoder=BASS_WMA_EncodeOpenFile(info.freq,info.chans,0,bitrate,filename); // setup encoder

while (BASS_ChannelIsActive(decoder)) { // haven't reached the end...
BYTE buffer[20000];
int c=BASS_ChannelGetData(decoder,buffer,20000); // decode some data
if (c>0) BASS_WMA_EncodeWrite(encoder,buffer,c); // got some - encode it
else Sleep(100); // no data - wait a bit
}
Logged
audiowally
Posts: 6


« Reply #2 on: 5 Mar '06 - 19:56 »
Reply with quoteQuote

 Smiley  Ian, Thank you very much. That works to perfection. I've included the same snippet written for us more verbose VB developers with a slight twist. In the VB example below, I'm encoding to a network port but the results are the same. Your  code works beautifully.

Dim _Stream As Integer
Dim info As New BASS_CHANNELINFO
Dim enc As Integer

_Stream = BassWma.BASS_WMA_StreamCreateFile(url, 0, 0, BASSStream.BASS_STREAM_DECODE)

Bass.BASS_ChannelGetInfo(_Stream, info) ' get stream format info
enc = BassWma.BASS_WMA_EncodeOpenNetwork(info.freq, _
      info.chans, _
      BASSWMAEncode.BASS_WMA_ENCODE_DEFAULT, _
      64000, _
      8080, _
      3)

While Bass.BASS_ChannelIsActive(_Stream)
   Dim c As Integer = Bass.BASS_ChannelGetData(_Stream, _recbuffer, 20000)

   If c > 0 Then
         BassWma.BASS_WMA_EncodeWrite(enc, _recbuffer, c)
   Else
         Thread.Sleep(100)
   End If

End While

Again, thanks for all your help.   
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines