Author Topic: stream prematurely ends  (Read 423 times)

Vaislog

  • Posts: 6
stream prematurely ends
« on: 16 Sep '21 - 15:11 »
Hello! I'm using bass.dll to play streams from vk.com using vb.net in conjunction with bass.net.
There are 3 types of links to the audio file.
1) direct link to mp3 file (just pass the link to BASS_StreamCreateURL and everything works fine)
2) a link to the m3u8 file, but also, it also has an mp3 file at a slightly different address (I can pull out a direct link to an mp3 file or use BASS_HLS_StreamCreateURL), there are no problems with them either, there are just links to .ts segments inside
3) link to m3u8 file in which some segments are encrypted (METHOD = AES-128)
And here is the 3rd option (with encryption), and also, if I use BASS_StreamCreateURL for a regular mp3 file with the BASS_STREAM_BLOCK flag, then the stream may terminate unexpectedly. There is no systematics, it can play all day without any problems, or it can finish playing a track 3 seconds after the beginning, and the next time it is played, it can normally reach the end.
I use the following code

Bass.BASS_PluginLoad ("basshls.dll")
BassHls.LoadMe ()

Bass.BASS_SetConfig (BASSConfig.BASS_CONFIG_NET_BUFFER, 7000)
Bass.BASS_SetConfig (BASSConfig.BASS_CONFIG_NET_READTIMEOUT, 30000)
Bass.BASS_SetConfigString (BASSConfig.BASS_CONFIG_NET_AGENT, "MyUserAgent")

If Bass.BASS_Init (-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero) Then
If isHLS = True Then
stream = BassHls.BASS_HLS_StreamCreateURL (Uri, BASSFlag.BASS_STREAM_AUTOFREE, Nothing, IntPtr.Zero)
Else
stream = Bass.BASS_StreamCreateURL (Uri, 0, BASSFlag.BASS_STREAM_AUTOFREE, Nothing, IntPtr.Zero)
End If
Bass.BASS_ChannelPlay (stream, False)
End if
What can be done to avoid premature termination of the thread?
The length of the stream is determined correctly using Bass.BASS_ChannelGetLength (stream)

Ian @ un4seen

  • Administrator
  • Posts: 23938
Re: stream prematurely ends
« Reply #1 on: 16 Sep '21 - 17:42 »
It is possible that a server will close the connection before the end when using the BASS_STREAM_BLOCK flag due to the download taking too long (BASS_STREAM_BLOCK limits the download rate to the playback rate). After only 3 seconds seems a bit early for that though. Please capture the network traffic with Wireshark and upload that to have a look at here:

   ftp.un4seen.com/incoming/

Please use HTTP rather than HTTPS so that the request and response is visible.

Vaislog

  • Posts: 6
Re: stream prematurely ends
« Reply #2 on: 17 Sep '21 - 13:06 »
I have uploaded some files, but I don't know if it is or not. Please let me know if this is not what you need. I used http to get the m3u8 file itself, but inside it still has https links. I can give you links to several m3u8 files if it helps

Ian @ un4seen

  • Administrator
  • Posts: 23938
Re: stream prematurely ends
« Reply #3 on: 17 Sep '21 - 13:54 »
To reduce the number of connections and other variables involved, could you reproduce the problem with an MP3 file (over HTTP) instead of HLS? If you are having the problem with particular HLS streams then you could also post those URLs to have a look at.

I notice in the captures that you seem to be running on Android? If so, to check that it isn't something specific to that or the device, please also see if you can reproduce it on another platform, eg. Windows/Linux/macOS.

Vaislog

  • Posts: 6
Re: stream prematurely ends
« Reply #4 on: 20 Sep '21 - 08:26 »
As I already wrote, there are no problems with mp3 files (without the BASS_STREAM_BLOCK flag), there is a problem with m3u8 files, in which some .ts segments are encrypted.
I am attaching several links with which there are problems.
Code: [Select]
https://psv4.vkuseraudio.net/audio/ee/bfW7IA8pxy2HFmXt2LD1rUpd_aKAkNf8193syw/5bNjE5Mjw5MTo/dcW31bPURobllObzY/index.m3u8?extra=uVkyyyDarQwn4HXC48XCtD_5mghwQHO9qpZhhz00DRSQ7WuIwTrB3ExDgNwrbxHnh_3mIMuvugsnA-UeECJSywi57zqjWeMMs0d39bR1RxjtrQHosfMOZDu-tKutki6kIsuWWlzL9LTTkYIu8IKLNKQ
https://psv4.vkuseraudio.net/audio/ee/dwxThsQLkMl9eHkbaz_ik_hWziBx_NZOGGIs7g/85NzA4PTY6Pzs/47Mk1IPUw2T2VFOl8/index.m3u8?extra=NFzk1fFJ46QtGu02lUYytM_eWxoA-oUYfFyNpOJvITIIAlWLCe6-UQ8r97Vz7y9fhZKJbBAxmK0QetsFJpa0o9n1eLeo9NpN4xUM3vioV3aiBj16ycA1lcTB31ujd1LlOsBci14Leg8mAluCCII7hjQ
https://psv4.vkuseraudio.net/audio/ee/ysqvX8ks49t4YDiZYTmxVwp6bSqz5m40FcUdew/1eOD8-MD41OTE/c8a0RYW3lceWtCTFw/index.m3u8?extra=U9mHbvKaJzDN1RHdY3exxZPwgbtheZhUTNLAPUQ6WEOixMzXx0OmjNXzxaMg-2wE1ySaAKpnWczSX8k4Q3uREi9NwV2deaZtmEi_HmC0Uzs5VHA9OztAtgmm9iTyZOOBVkm3xr1zCQHz2uDqoscbxTk
https://psv4.vkuseraudio.net/audio/ee/B7iirirGExAEku4A36-5CJqlVQ7WU19xeh0wyw/09NjQ2PDo4MTo/10dTtta09OP3lCPU8/index.m3u8?extra=nZfrVuIBQCWwBKsR5dauzyj2jd2xKJLrUC5yClC_lD6tclqPSpQ5yOzmv1rkE9AFRvuRgY4mFpR0tDzuHbv0-SLfyxYfBoMEqgwPduhJAxqwKf1I8V4ED-EODBLM2B_nxlAdACxRV_PS4jbJMZNCWvM
https://psv4.vkuseraudio.net/audio/ee/XPQcCTRvFdilRtXklYQOE_t7ABG9Y1CeIWRcrg/f2MzU4OTY5ODQ/2bSGd3Skw-TUdldm8/index.m3u8?extra=TivB5VTJ7xrPUWNaIWovJiZ1LKd3-puHvCW3aXVrO7VIpxkF_qjZPvILGg1FnftglEzrLSfIbVc9KYkiNXDkzzrpZnRiyZiDxyFo2MkCd8S0NXDov180KIignpTMGjzYhcqFpPt4JhJJJFOyoRAeLnM
I will also try to reproduce the problem with a regular mp3 file and the BASS_STREAM_BLOCK flag.
Please note that links will be live for about 24 hours
I am developing a windows application, I am not using other platforms
« Last Edit: 20 Sep '21 - 08:53 by Vaislog »

Ian @ un4seen

  • Administrator
  • Posts: 23938
Re: stream prematurely ends
« Reply #5 on: 20 Sep '21 - 17:14 »
The issue with those HLS stream URLs is that they're redirecting (twice) to another URL but BASSHLS is still using the original URL to resolve the absolute path of the media segments, so those download requests are failing. Here's an update that will use the final redirection URL instead:

   www.un4seen.com/stuff/basshls.zip

Another issue I had was that sometimes the media segment requests were timing-out, ie. it was taking a while to connect to the server. Raising the BASS_CONFIG_NET_TIMEOUT setting to 30000 (30s) via BASS_SetConfig seemed to fix that.

Let me know if you still see the problem happen with any URLs. Note this update makes use of the BASS_TAG_LOCATION option, which was introduced in BASS 2.4.16, so these URLs still won't work with older BASS versions.

Vaislog

  • Posts: 6
Re: stream prematurely ends
« Reply #6 on: 21 Sep '21 - 13:50 »
Unfortunately, this did not change the situation.
Streams still don't work :(
The versions of the libraries that I am using:
bass.dll - 2.4.16.7
bass.Net.dll - 2.4.14.1
basshls.dll - 2.4.3.1

Ian @ un4seen

  • Administrator
  • Posts: 23938
Re: stream prematurely ends
« Reply #7 on: 21 Sep '21 - 15:22 »
OK. I will send you a debug BASSHLS version to get more info on what's happening there.

Vaislog

  • Posts: 6
Re: stream prematurely ends
« Reply #8 on: 22 Sep '21 - 08:06 »
Thank you! I'll wait

Ian @ un4seen

  • Administrator
  • Posts: 23938
Re: stream prematurely ends
« Reply #9 on: 22 Sep '21 - 11:54 »
It was sent yesterday. If you don't see it, perhaps it ended up in your spam/junk folder? Let me know if you don't see it there either.

Vaislog

  • Posts: 6
Re: stream prematurely ends
« Reply #10 on: 22 Sep '21 - 12:09 »
Oh, really, the letter flew into spam.
I played 3 tracks, the first 2 ended ahead of time, the third successfully played to the end
Log was sent back to mail