Tag: bilibili

  • Download Bilibili 4K Videos. The Hard Way

    Requirements:

    • Google Chrome installed
    • Get cookies.txt extension installed
    • youtube-dl installed
    • FFmpeg installed
    • Active bilibili membership (to get 4K streaming perk)
    • Basic JSON and Bash knowledge

    Steps:

    • Open the video page you want to download with Google Chrome
    • Open Web Inspector and refresh the page
    • Change video quality to some lower ones (like 480p) and change back to 4K
    • Search for player/playurl in Inspector
    • You should get a JSON payload returned:

    Then select one of the most recent requests with accept_quality that has 120 in array:

    Then select down to the data.dash.video[0].baseUrl and data.dash.audio[0].baseUrl. Remember these URLs:

    Open Get cookies.txt extension and download your current cookies.

    Download video and audio with youtube-dl:

    youtube-dl --cookies bilibili.com_cookies.txt --referer 'https://www.bilibili.com/video/BV1d5411g7g2' 'https://xxx.mcdn.bilivideo.cn:4483/upgcxcode/12/67/336676712/336676712-1-30232.m4s...'

    Then you will get two files like the following:

    • 20210510 336676712-1-30280 [336676712-1-30280].m4s
    • 20210510 336676712-1-30120 [336676712-1-30120].m4s

    Rename the video extension to mp4 and audio to m4a. Play them to check if everything works.

    Combine these two with FFmpeg:

    ffmpeg -i 20210510\ 336676712-1-30120\ \[336676712-1-30120\].mp4 -i 20210510\ 336676712-1-30280\ \[336676712-1-30280\].m4a -c copy output-combined.mp4