Author Topic: youtube streaming problem  (Read 269 times)

Lignuz

  • Posts: 9
youtube streaming problem
« on: 19 Sep '17 - 09:54 »
Hi~
I was trying to play streaming audio from YouTube url with bass lib.
Playing audio was fine using BASS_StreamCreateURL() function.
But, some problems had occurred.

1.
I used the DOWNLOADPROC callback function and saved the streaming data, and gain NOT the same data with download from Browser directly.
It looks like there is no header information.

2.
Seeking the streaming audio make a decoder handle disabled.
It seems to occur if the data for the seeking position is not available (not downloaded yet).
BASS_channelSetPosition() function returns FALSE and BASS_ErrorGetCode() returns -1(BASS_ERROR_UNKNOWN).
And BASS_ChannelIsActive() function returns FALSE, too.
Nothing can do anymore in this situation.

Check this please.
Best regards.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: youtube streaming problem
« Reply #1 on: 19 Sep '17 - 14:39 »
Please give an example URL (used in your BASS_StreamCreateURL call) to have a look at.

Lignuz

  • Posts: 9
Re: youtube streaming problem
« Reply #2 on: 20 Sep '17 - 09:23 »
Youtube Media urls have expire time, ip check, etc...
So, I attached a test program to extract Youtube Media urls from Youtube urls.

(available until 2017.10.27)
http://attach.mail.daum.net/bigfile/v1/urls/d/Ul1vYCofTEu6E7wfE1vXd2ppfsc/s9YeCYQhkp9VDBs1NaEl7g


example)
https://www.youtube.com/watch?v=x0I6mhZ5wMw

https://r7---sn-n3cgv5qc5oq-bh2e6.googlevideo.com/videoplayback?source=youtube&clen=5037273&ei=BSTCWdvVNY_q4ALwppSIBA&ip=218.236.13.98&key=yt6&mm=31&ipbits=0&mn=sn-n3cgv5qc5oq-bh2e6&pl=19&mt=1505895362&dur=275.295&mv=m&initcwndbps=2802500&ms=au&itag=18&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cexpire&id=o-AEX37q-sT1TqlhPDy_82AqE59t_PIPUa3XyA2RHcMwyX&requiressl=yes&mime=video%2Fmp4&gir=yes&ratebypass=yes&lmt=1458209734211964&expire=1505917030&signature=6219010013A385AD2E339E32073A6119617CAB02.795EBB6DBA1FA9828EDC6B3C8A6506A21462F23D

https://youtu.be/x0I6mhZ5wMw

https://r7---sn-n3cgv5qc5oq-bh2e6.googlevideo.com/videoplayback?gir=yes&ipbits=0&requiressl=yes&lmt=1458209734211964&ratebypass=yes&expire=1505917160&source=youtube&mime=video%2Fmp4&clen=5037273&ei=iCTCWayYC5L_qQGF1rLABA&key=yt6&pl=19&ip=218.236.13.98&mm=31&mn=sn-n3cgv5qc5oq-bh2e6&initcwndbps=2785000&itag=18&ms=au&mt=1505895463&mv=m&dur=275.295&id=o-ALp7qru5AuFnpPelhPzd7LGfW_P8B3vQegHAaqi0BtCD&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cexpire&signature=D377B722C8891A1552CCF32BC2BB6DF16C16EE38.81D2677AAA3D420B7F540C6D86C8170D31B70E76

You can make example urls using this program.
Check this please.
Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: youtube streaming problem
« Reply #3 on: 20 Sep '17 - 17:17 »
OK. I didn't try your program, but I believe YouTube usually uses MPEG-DASH, so I guess that will be what the data is. BASS doesn't support MPEG-DASH itself but it is supported on Windows 8 and above via Media Foundation. You can check if Media Foundation is being used with BASS_ChannelGetInfo (see the "ctype" value).

Regarding your first question, if different data is being received from the server, that could be due to the "User-Agent" request header that's used. You can change that via the BASS_CONFIG_NET_AGENT config option, like this:

Code: [Select]
BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, useragent);

You could try setting that to what a browser uses.

Lignuz

  • Posts: 9
Re: youtube streaming problem
« Reply #4 on: 21 Sep '17 - 07:55 »
As mentioned, the ctype value of Youtube Media url returned BASS_CTYPE_STREAM_MF(0x00010008).
I understood that only under Windows 8(8.1) and Windows 10 OS environment, BASS could play Youtube Media urls.

After have called the BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, useragent) function, saved file data via DOWNLOADPROC has not changed.
It was not "Different data", and it was "Data with header data excluded".
In fact, it is not important thing. But I would like to solve the disconnecting channel handle problems at seeking timing. (perhaps when it requested not have been downloaded position yet.)

Do you have any idea about this?
Regards.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: youtube streaming problem
« Reply #5 on: 21 Sep '17 - 16:22 »
It was not "Different data", and it was "Data with header data excluded".

The headers will be received by your DOWNLOADPROC function first, with the "length" parameter set to 0. They are also available from BASS_ChannelGetTags (with tags=BASS_TAG_HTTP).

In fact, it is not important thing. But I would like to solve the disconnecting channel handle problems at seeking timing. (perhaps when it requested not have been downloaded position yet.)

It won't be possible to seek to a position that hasn't been download yet, but attempting that ideally won't end the stream, ie. playback should continue from the current position. Please upload a file that you have downloaded from an affected URL to have look at here:

   ftp.un4seen.com/incoming/