Author Topic: BASSHLS beta (HTTP Live Streaming add-on)  (Read 13949 times)

drama22

  • Posts: 17
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #25 on: 25 Jan '16 - 22:04 »
i am using delphi c example will not help me

Error

  • Guest
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #26 on: 31 Jan '16 - 12:29 »
And how we can create our own HLS stream? What encoder do i need (on linux, arm)? I  would like to try it out cause jPlayer is not reliable when playing a mp3 stream.

airstep

  • Posts: 2
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #27 on: 24 May '16 - 08:04 »
Hi!

How to use adaptive bitrate streaming provided by HLS?

How to check if it works with your library?

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #28 on: 24 May '16 - 13:19 »
BASSHLS doesn't currently include automated support for adaptive bitrate streaming (it always plays the first available stream/bitrate). You will need to download the master playlist yourself and extract the URL for the bitrate that you want, and pass that to BASSHLS.

airstep

  • Posts: 2
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #29 on: 24 May '16 - 14:09 »
BASSHLS doesn't currently include automated support for adaptive bitrate streaming (it always plays the first available stream/bitrate). You will need to download the master playlist yourself and extract the URL for the bitrate that you want, and pass that to BASSHLS.

ok, thank you!

leonardo

  • Posts: 5
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #30 on: 26 Jun '16 - 01:59 »
http://www.un4seen.com/stuff/basshls-test.zip 404 not found pls re upload.
my StreamCreateURL

c = BASS.BASS_StreamCreateURL(url, 0,
                  BASS.BASS_STREAM_BLOCK | BASS.BASS_STREAM_STATUS | BASS.BASS_STREAM_AUTOFREE, StatusProc, r); // open

how to create
BASS_HLS_StreamCreateURL
BASS_HLS_StreamCreateFile
thanks for help

               

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #31 on: 27 Jun '16 - 16:12 »
That "basshls-test" update has since become the official BASSHLS version and is available in the 1st post.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #32 on: 25 Jul '16 - 17:50 »
An updated BASSHLS version is up now in the 1st post, adding support for the EXT-X-KEY tag and AES-128 encryption.

ak545

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #33 on: 14 Sep '16 - 22:53 »
Hi Ian @ un4seen!

Thanks a lot for this work!

Earlier you wrote:
Quote
but please report if you find any HLS streams that aren't working properly
Yes, there is such a stream.

Content-Type:video/mp2t
https://radio7.ru/
https://hls-01-radio7.emgsound.ru/13/128/playlist.m3u8

This HLS stream is processed with errors.
When you reach the end of each segment - stops playing.


Best Regards,
Andrey Klimov

P.S. Sorry for my bad English.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #34 on: 15 Sep '16 - 13:03 »
That stream seems to be working fine here. To test it, I added a BASS_PluginLoad("basshls.dll") call to the NETRADIO example. Here it is for you to try:

   www.un4seen.com/stuff/netradio-hls.exe

Can you reproduce the problem with that? If not, are you customising any BASS_CONFIG settings in your app?

ak545

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #35 on: 15 Sep '16 - 15:45 »
That stream seems to be working fine here. To test it, I added a BASS_PluginLoad("basshls.dll") call to the NETRADIO example. Here it is for you to try:

   www.un4seen.com/stuff/netradio-hls.exe

Can you reproduce the problem with that? If not, are you customising any BASS_CONFIG settings in your app?

No, this example ( www.un4seen.com/stuff/netradio-hls.exe ) as the stream starts to play, but then after about 8 seconds stops (disconnected).

Code: [Select]
procedure ClosedStream(handle: HSYNC; channel, data: DWORD; user: Pointer); {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
...

procedure ClosedStream(handle: HSYNC; channel, data: DWORD; user: Pointer); {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
begin
   //Oops! WTF???
   // at the end of each piece of management comes here
   // It's only when play from: https://hls-01-radio7.emgsound.ru/13/128/playlist.m3u8
  {
    https://hls-01-radio7.emgsound.ru/commercial/13/1556_aDowU2hvWmJBTFNQSTV0ODZuZUFlRTQy_1/1/30138/out0.ts // after end -> BASS_SYNC_END ???
    https://hls-01-radio7.emgsound.ru/commercial/13/1556_aDowU2hvWmJBTFNQSTV0ODZuZUFlRTQy_1/1/30138/out1.ts // after end -> BASS_SYNC_END ???
    https://hls-01-radio7.emgsound.ru/commercial/13/1556_aDowU2hvWmJBTFNQSTV0ODZuZUFlRTQy_1/1/30138/out2.ts // after end -> BASS_SYNC_END ???
    ...
   }
   FormClockMain.MemoDebug.Lines.Add('THE FINISH!');
end;

...
var   
    G_STREAM_URL: String;
    chan: HSTREAM;

...
    BASS_Init( bla bla bla....);
...
    BASS_PluginLoad("basshls.dll"); // Of course! Ash stump!
...
    G_STREAM_URL := 'https://hls-01-radio7.emgsound.ru/13/128/playlist.m3u8';
    BASS_SetConfig(BASS_CONFIG_NET_BUFFER, 5000);
    BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1);
    chan := BASS_StreamCreateURL(
                                 PAnsiChar(G_STREAM_URL),
                                 0,
                                 BASS_STREAM_BLOCK or BASS_STREAM_STATUS or BASS_SAMPLE_FX or BASS_STREAM_AUTOFREE,
                                 @StatusProc,
                                 nil
                                );
   if (chan <> 0) then
   begin
         BASS_ChannelSetSync(chan, BASS_SYNC_META, 0, @MetaSync, nil);
         BASS_ChannelSetSync(chan, BASS_SYNC_OGG_CHANGE, 0, @MetaSync, nil);
         BASS_ChannelSetSync(chan, BASS_SYNC_HLS_SEGMENT, 0, @MetaSync, nil);
         BASS_ChannelSetSync(chan, BASS_SYNC_END or BASS_SYNC_STALL, 0, @ClosedStream, nil);
         // play it!
         if BASS_ChannelPlay(chan, FALSE) then
         begin
            // ...
         end;
   end;
    //I write this on Lazarus 1.6 and Free Pascal 3.0 for Windows/Linux/MacOS

My code works fine for HLS, from these sources:
www.radiofeeds.co.uk/other.asp
www.addictradio.net/en/labs/
Look: https://youtu.be/7q3KLaOQqHk

but don't work for this:
https://hls-01-radio7.emgsound.ru/13/128/playlist.m3u8
With your example (netradio-hls.exe) there is the same.
+
https://youtu.be/5TpsKc3AP9o

I have attached screenshots (Developer Tools of the Google Chrome) from the site ( https://radio7.ru/ ) to understand how it happens.
I hope for understanding, so very bad speak English.



« Last Edit: 15 Sep '16 - 16:06 by ak545 »

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #36 on: 15 Sep '16 - 16:12 »
That's strange, the stream is still playing fine here. I will send you a debug BASSHLS version to get some more info on what is happening there.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #37 on: 16 Sep '16 - 13:52 »
For anyone else that has had this problem with some HLS streams, a BASSHLS update is now up in the 1st post.


Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #39 on: 5 Oct '16 - 16:52 »
That's strange. Both streams seem to be working fine here, with the netradio-hls.exe example posted above. Can you reproduce the problem with that there, and if so, what is the error code?

Pedro Leonardo

  • Posts: 80
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #40 on: 5 Oct '16 - 17:06 »
Hi,
with the NetRadio-hls.exe example is working. You can send NetRadio-hls sources? Am I doing something wrong..

Regards
Leonardo

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #41 on: 5 Oct '16 - 17:30 »
It is the NETRADIO.C example included in the BASS package, with a BASS_PluginLoad call added in WinMain to load BASSHLS:

Code: [Select]
// check the correct BASS was loaded
if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
MessageBox(0,"An incorrect version of BASS.DLL was loaded",0,MB_ICONERROR);
return 0;
}

BASS_PluginLoad("basshls.dll",0);

Pedro Leonardo

  • Posts: 80
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #42 on: 5 Oct '16 - 18:53 »
Hi,
I develop in Delphi

my TForm1.FormCreate


  // check the correct BASS was loaded
  win := handle;
  if (HIWORD(BASS_GetVersion) <> BASSVERSION) then
  begin
    MessageBox(0, 'An incorrect version of BASS.DLL was loaded', nil, MB_ICONERROR);
    Halt;
  end;
  if (not BASS_Init(-1, 44100, 0, Handle, nil)) then
  begin
    Error('Can''t initialize device');
    Halt;
  end;
  BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1); // enable playlist processing
  BASS_SetConfig(BASS_CONFIG_NET_PREBUF, 0); // minimize automatic pre-buffering, so we can do it (and display it) instead
  BASS_PluginLoad(PChar('basshls.dll'), BASS_UNICODE);


returns error 41 and does not work


Regards
Leonardo

ak545

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #43 on: 6 Oct '16 - 07:25 »
Leonardo

BASS_ERROR_FILEFORM    =41   ;unsupported file format
Error code 41 (is BASS_ERROR_FILEFORM), which means the file format wasn't recognised.

Code: [Select]
File: http://wz5.dnip.com.br/alternativa1fmhd/alternativa1fmhd.stream/playlist.m3u8
Code: 41 (00000029)
Message: Unsupported file format
-------------------------
HTTP/1.1 200 OK
Accept-Ranges: bytes
Server: WowzaStreamingEngine/4.4.1
Cache-Control: no-cache
Date: Thu, 06 Oct 2016 06:32:59 GMT
Content-Type: application/vnd.apple.mpegurl
Content-Length: 102


This problem was in the old version of the basshls.dll
In latest version of the basshls.dll everything works fine.
Look: https://youtu.be/_zHVM_HdR_s

Try add bass_aac.dll
Code: [Select]
BASS_PluginLoad(PChar('bass_aac.dll'), BASS_UNICODE);because Content-Type: application/vnd.apple.mpegurl


P.S.
And just
Before - Plugin Load
Code: [Select]
BASS_PluginLoad(PChar('basshls.dll'), BASS_UNICODE);
After - Bass Init
Code: [Select]
BASS_Init(-1, 44100, 0, Handle, nil);
« Last Edit: 6 Oct '16 - 08:18 by ak545 »

Pedro Leonardo

  • Posts: 80
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #44 on: 6 Oct '16 - 13:25 »
Hi
Thank you. Now it is working well

Regards

melvinlee.yk

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #45 on: 12 Oct '16 - 10:21 »
Hi Ian,

I'm testing out the HLS lib on Android but keep getting Code Error 41 which is unsupported file error. Tried the following few URL but doesn't seems to work, but had verified the source it's working.
http://hls1.addictradio.net/addictalternative_aac_hls/playlist.m3u8
http://db3.indexcom.com/bucket/ram/00/05/05.m3u8

Updated latest libbass.so as well as the libbasshls.so

Here's a brief of my implementation:
Code: [Select]
private void play(Context context, String streamUrl) throws Exception {
        BASS.BASS_Init(-1, 44100, 0);
        BASS.BASS_PluginLoad(context.getApplicationInfo().nativeLibraryDir+"/libbasshls.so", 0); // load BASSHLS

        int audioOutStream = BASSHLS.BASS_HLS_StreamCreateURL(streamUrl, BASS.BASS_STREAM_AUTOFREE, streamDownloadCallback, 0);
        if(audioOutStream == 0){
            throw new Exception("Unable to create stream. BASS Error Code : " + BASS.BASS_ErrorGetCode());
        }

        BASS.BASS_SetConfig(BASS.BASS_CONFIG_NET_PLAYLIST, 1);
        BASS.BASS_ChannelSetSync(audioOutStream, BASS.BASS_SYNC_META, 0, metaSyncCallback, 0);
        BASS.BASS_ChannelSetSync(audioOutStream, BASS.BASS_SYNC_OGG_CHANGE, 0, metaSyncCallback, 0); // Icecast/OGG
        // set sync for end of stream
        BASS.BASS_ChannelSetSync(audioOutStream, BASS.BASS_SYNC_END, 0, endSyncCallback, 0);
        BASS.BASS_ChannelPlay(audioOutStream, false);
}

Appreciate in advance for any advise.

Thanks.


Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #46 on: 12 Oct '16 - 17:16 »
Those streams both use AAC encoding. BASS can use the OS's AAC decoder on OSX, iOS and Windows (Vista and above), but on other platforms the BASS_AAC add-on will need to be loaded via BASS_PluginLoad to play them.

Melvin

  • Guest
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #47 on: 13 Oct '16 - 09:23 »
Those streams both use AAC encoding. BASS can use the OS's AAC decoder on OSX, iOS and Windows (Vista and above), but on other platforms the BASS_AAC add-on will need to be loaded via BASS_PluginLoad to play them.

Thanks Ian, it's working now as per advised. Appreciate it   :)

melvinlee.yk

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #48 on: 14 Oct '16 - 10:03 »
I don't think most HLS streams include metadata. In some cases, a title will be included in the EXTINF tag, which you can get via the new BASS_TAG_HLS_EXTINF option. For example, you could try something like this:

Code: [Select]
BASS_ChannelSetSync(stream, BASS_SYNC_HLS_SEGMENT, 0, HLSSegmentSyncProc, 0); // set sync on new HLS segment

...

void CALLBACK HLSSegmentSyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
const char *extinf=BASS_ChannelGetTags(channel, BASS_TAG_HLS_EXTINF); // get new segment's EXTINF tag
const char *title=strchr(extinf, ','); // look for duration/title separator
if (title && title[1]) SetTitle(title+1); // use title
}

Some streams may also have ID3v2 tags, which you can get via the BASS_TAG_ID3V2 tag option.

Hi Ian,

I've been trying to get the EXTINF from the following stream on Android:
http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8

using the following implementation as referencing to yours,
Code: [Select]
        int audioOutStream = BASSHLS.BASS_HLS_StreamCreateURL(streamUrl, 0, streamDownloadCallback, 0);
        BASS.BASS_ChannelSetSync(audioOutStream, BASSHLS.BASS_SYNC_HLS_SEGMENT, 0, metaSyncCallback, 0);
        BASS.BASS_ChannelSetSync(audioOutStream, BASS.BASS_SYNC_END, 0, endSyncCallback, 0);
        BASS.BASS_ChannelPlay(audioOutStream, false);

Code: [Select]
    private class MetaSyncCallback implements BASS.SYNCPROC {
        @Override
        public void SYNCPROC(int handle, int channel, int data, Object user) {
            Object extinf = BASS.BASS_ChannelGetTags(audioOutStream, BASSHLS.BASS_TAG_HLS_EXTINF);
            Log.i("XXX", "EXTINF : " + extinf)
        }
    }

Just wondering am i missing out anything since the returns of BASS_ChannelGetTags() kept returning null values on it? but I guess the stream above does contains something.

Also, I'm getting something from ID3v2 Tag which has something like this, does it mean I need to further process this ByteBuffer in order to get the metadata?
Code: [Select]
java.nio.DirectByteBuffer[position=0,limit=109,capacity=109]

Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #49 on: 14 Oct '16 - 17:06 »
Not all HLS streams include titles in the EXTINF tags, but that one does. I'm not sure if it will solve the problem you're having, but you should probably cast the BASS_ChannelGetTags return value to a String, like this:

Code: [Select]
String extinf = (String)BASS.BASS_ChannelGetTags(audioOutStream, BASSHLS.BASS_TAG_HLS_EXTINF);

That stream does also include ID3v2 tags (title and artist). You can use the Tags add-on to process them.

Code: [Select]
String title = TAGS.TAGS_Read(audioOutStream, "%ARTI - %TITL");