Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins.bilibili: support for higher stream qualities #5700

Open
4 tasks done
ghost opened this issue Dec 4, 2023 · 11 comments · May be fixed by #5782
Open
4 tasks done

plugins.bilibili: support for higher stream qualities #5700

ghost opened this issue Dec 4, 2023 · 11 comments · May be fixed by #5782
Labels
plugin issue A Plugin does not work correctly

Comments

@ghost
Copy link

ghost commented Dec 4, 2023

Checklist

Streamlink version

6.4.2

Description

You can only get a fixed cookie if you can only get 480P without Cookie. Even if the user does not enter the cookie, it can still be used. This can ensure anonymity

Debug log

streamlink https://live.bilibili.com/545068 best -p mpv --loglevel=debug
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.11.6
[cli][debug] OpenSSL:    OpenSSL 3.0.11 19 Sep 2023
[cli][debug] Streamlink: 6.4.2
[cli][debug] Dependencies:
[cli][debug]  certifi: 2023.11.17
[cli][debug]  isodate: 0.6.1
[cli][debug]  lxml: 4.9.3
[cli][debug]  pycountry: 22.3.5
[cli][debug]  pycryptodome: 3.19.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.31.0
[cli][debug]  trio: 0.23.1
[cli][debug]  trio-websocket: 0.11.1
[cli][debug]  typing-extensions: 4.8.0
[cli][debug]  urllib3: 2.1.0
[cli][debug]  websocket-client: 1.6.4
[cli][debug] Arguments:
[cli][debug]  url=https://live.bilibili.com/545068
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --player=mpv
[cli][info] Found matching plugin bilibili for URL https://live.bilibili.com/545068
[cli][info] Available streams: live_alt, live (worst, best)
[cli][info] Opening stream: live (hls)
[cli][info] Starting player: mpv
[stream.hls][debug] Reloading playlist
[cli][debug] Pre-buffering 8192 bytes
@ghost ghost added the plugin issue A Plugin does not work correctly label Dec 4, 2023
@bastimeyer bastimeyer changed the title plugins.bilibili plugins.bilibili: support for higher stream qualities Dec 4, 2023
@bastimeyer
Copy link
Member

bastimeyer commented Dec 4, 2023

You can only get a fixed cookie if you can only get 480P without Cookie. Even if the user does not enter the cookie, it can still be used. This can ensure anonymity

Not exactly sure what you're trying to say here, but this is probably in regards to your comment here:
#5692 (comment)

No, we won't hardcode any cookie data, and I myself certainly won't use my own phone number on any Chinese sites in order to test logins.

I am aware that you have posted some code in the Go language in #5693 which you have copied from somewhere else and which sets different parameters on the API request compared to the old implementation, but I haven't had a look at this yet.

@ghost
Copy link
Author

ghost commented Dec 4, 2023

Do I mean that there is a way to obtain the highest picture quality without using Cookie? The code of the Go language is tested and can get 720P without using cookies

@ghost
Copy link
Author

ghost commented Dec 4, 2023

If you can't get the highest quality quality without using Cookie, then I have to look at other methods

@steven7851
Copy link
Contributor

The v1 API can still get high quality without cookie, refer here

@ghost
Copy link

ghost commented Dec 7, 2023

The v1 API can still get high quality without cookie, refer here

Can this code be integrated?

@ghost

This comment was marked as duplicate.

@bastimeyer
Copy link
Member

The v1 API can still get high quality without cookie

That is not true. And apart from that, the v1 API only returns FLV container served via progressive HTTP streams instead of TS or fMP4 containers served via HLS or DASH.

Example with room ID 7777:

streamlink \
  --stdout \
  --loglevel=none \
  "$(curl -sSL \
    'https://api.live.bilibili.com/xlive/web-room/v1/playUrl/playUrl?https_url_req=1&cid=7777&qn=1&platform=web&ptype=16' \
    | jq -r '"httpstream://" + .data.durl[0].url' \
  )" \
  best \
  2>/dev/null \
  | ffprobe -v error -show_format -show_streams -print_format json -
{
    "streams": [
        {
            "index": 0,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "sample_fmt": "fltp",
            "sample_rate": "48000",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "initial_padding": 0,
            "missing_streams": "0",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/1000",
            "start_pts": 0,
            "start_time": "0.000000",
            "bit_rate": "262144",
            "extradata_size": 5,
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            }
        },
        {
            "index": 1,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "width": 854,
            "height": 480,
            "coded_width": 854,
            "coded_height": 480,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 2,
            "pix_fmt": "yuv420p",
            "level": 31,
            "color_range": "tv",
            "color_space": "bt709",
            "color_transfer": "bt709",
            "color_primaries": "bt709",
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "missing_streams": "0",
            "r_frame_rate": "30/1",
            "avg_frame_rate": "30/1",
            "time_base": "1/1000",
            "start_pts": 68,
            "start_time": "0.068000",
            "bits_per_raw_sample": "8",
            "extradata_size": 48,
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            }
        }
    ],
    "format": {
        "filename": "fd:",
        "nb_streams": 2,
        "nb_programs": 0,
        "format_name": "flv",
        "format_long_name": "FLV (Flash Video)",
        "start_time": "0.000000",
        "duration": "0.000000",
        "size": "0",
        "probe_score": 100,
        "tags": {
            "displayHeight": "480",
            "level": "",
            "cdn_ip": "10.12.13.22",
            "profile": "",
            "displayWidth": "854",
            "Rawdata": "",
            "encoder": "libobs/28.1.2 LiveHime/4.52.0 (Windows),BILIAVC.1.6.6",
            "fps": "30"
        }
    }
}

@ghost
Copy link

ghost commented Dec 7, 2023

can only return to low quality? I see the buddy above said

@foreveruand
Copy link

foreveruand commented Jan 17, 2024

it seems like the older version of streamlink can still record high quality. I use the streamlink 5.2.1 on Debian 11. when I upgrade to newer 6.5.0-1~bpo12+1. The record is low quality with 854x480 resolution. then I switch back to 5.2.1. the record is 1920x1080.
But the older version 5.2.1 can not get the roomtitle.

@foreveruand
Copy link

foreveruand commented Jan 17, 2024

according to 直播间信息流 获取秘钥需要Cookie, I set --http-cookie in configuration with DedeUserID__ckMd5 DedeUserID SESSDATA bili_jct. Streamlink can get high quality with version 6.5.1

@bastimeyer bastimeyer linked a pull request Jan 18, 2024 that will close this issue
@bastimeyer
Copy link
Member

bastimeyer commented Jan 18, 2024

The plugin implementation prior to Streamlink's 6.4.2 release was based on the site's v1 API. The plugin was rewritten based on the v2 API because the API response changed and the plugin's validation schema broke. v2 is used by their website, hence the plugin-reimplementation on that.

I have no idea about the status of this v1 API and whether it's deprecated and will be shut down in the future.

As you can see in my last post, I had checked the claims of the stream quality, but the results showed low-quality streams. Apparently, this was the wrong v1 URL. The old plugin implementation used a different one.

Please have a look at #5782. I've added back progressive HTTP streams from the previously used v1 API response, which are indeed high quality streams. I decided to not remove the HLS streams.

Please check a couple of streams and see if there are any issues.
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#pull-request-feedback

I won't merge #5782 until I have confirmation that this new plugin implementation is working on all streams.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin issue A Plugin does not work correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants