Repository: yt-dlp/yt-dlp

Issue:
[bilibili] Dolby Vision and Dolby Atmos support
### Checklist

- [X] I'm requesting a feature unrelated to a specific site
- [X] I've looked through the [README](https://github.com/yt-dlp/yt-dlp#readme)
- [X] I've verified that I'm running yt-dlp version **2022.05.18** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues including closed ones. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)

### Description

哔哩哔哩现在已经支持杜比视界跟杜比全景声了，希望能新增解析，还有HDR视频也解析不了，还有解析视频的帧率跟编码格式也看不到，希望后续能新增，感谢！感谢！感谢！

### Verbose log

_No response_


Discussion:
![image](https://user-images.githubusercontent.com/10355528/173182040-3532983e-3ba1-4603-93d1-a4c66ffab56b.png)

1. Please use English here. Converting this to site feature request.
2. Paste example URLs that these formats are available and playable in your browser
3. Post your attempt using yt-dlp, by running `yt-dlp -vU <URL>` and **pasting its all of output here**
4. If it requires an account (e.g. paid videos), are you willing to provide account credentials?

Original title: 可以新增支持哔哩哔哩的杜比视界，杜比全景声解析吗？

<details>
<summary>In text</summary>
Can you add Dolby Vision and Dolby Atmos analysis that supports Bilibili?

Bilibili now supports Dolby Vision and Dolby Atmos, I hope to add new resolutions, and HDR video can't be parsed, and the frame rate and encoding format of the parsed video can't be seen, I hope it can be updated in the future. Increase, thanks! grateful! grateful!

</details>

![屏幕截图 2022-06-11 194450](https://user-images.githubusercontent.com/92282389/173186464-9f4cf1a6-5918-4778-821f-2f68d524734b.png)
D:\高清修复音乐录影带>yt-dlp -vU https://www.bilibili.com/video/BV1zv411w7Aj?from=search&seid=40601303958327558&spm_id_from=333.337.0.0&vd_source=0eed57f6237032184baffdf3300efda7
[debug] Command-line config: ['-vU', 'https://www.bilibili.com/video/BV1zv411w7Aj?from=search']
[debug] Encodings: locale cp936, fs utf-8, pref cp936, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.05.18 [b14d523] (win_exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.22000-SP0
[debug] Checking exe version: ffprobe -bsfs
[debug] Checking exe version: ffmpeg -bsfs
[debug] exe versions: ffmpeg 2022-06-06-git-73302aa193-full_build-www.gyan.dev (setts), ffprobe 2022-06-06-git-73302aa193-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.14.1, brotli-1.0.9, certifi-2021.10.08, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.3
[debug] Proxy map: {'http': 'http://127.0.0.1:10809', 'https': 'https://127.0.0.1:10809', 'ftp': 'ftp://127.0.0.1:10809'}
Latest version: 2022.05.18, Current version: 2022.05.18
yt-dlp is up to date (2022.05.18)
[debug] [BiliBili] Extracting URL: https://www.bilibili.com/video/BV1zv411w7Aj?from=search
[BiliBili] 1zv411w7Aj: Grabbing original ID via API
[BiliBili] 250458461: Downloading webpage
[BiliBili] 250458461: Extracting videos in anthology
[BiliBili] Downloading anthology 250458461 - add --no-playlist to just download video
[download] Downloading playlist: 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」
[BiliBili] playlist 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」: Downloading 1 videos
[download] Downloading video 1 of 1
[debug] [BiliBili] Extracting URL: https://www.bilibili.com/video/BV1zv411w7Aj?p=1
[BiliBili] 1zv411w7Aj: Grabbing original ID via API
[BiliBili] 250458461: Downloading webpage
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[BiliBili] 250458461: Extracting videos in anthology
[BiliBili] 250458461: Downloading tags
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 250458461_part1: Downloading 1 format(s): 21+2
[debug] Invoking http downloader on "https://upos-sz-mirrorhwo1.bilivideo.com/upgcxcode/79/81/407508179/407508179_x2-1-30077.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1654954863&gen=playurlv2&os=hwo1bv&oi=0&trid=0f31b632a78d426ea3e6d02eb9556bfeu&mid=0&platform=pc&upsig=2f2c445db4cb75e27d57bbd33e9b1b8c&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&bvc=vod&nettype=0&orderid=0,2&agrr=0&bw=185509&logo=80000000"
[debug] File locking is not supported on this platform. Proceeding without locking
[download] Destination: 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f21.mp4
[download] 100% of 35.38MiB in 00:13
[debug] Invoking http downloader on "https://upos-sz-mirrorcoso1.bilivideo.com/upgcxcode/79/81/407508179/407508179-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1654954863&gen=playurlv2&os=coso1bv&oi=0&trid=0f31b632a78d426ea3e6d02eb9556bfeu&mid=0&platform=pc&upsig=398b582f0bd5ec7b55fa1519a165b317&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&bvc=vod&nettype=0&orderid=0,2&agrr=0&bw=41257&logo=80000000"
[download] Destination: 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f2.m4a
[download] 100% of 7.87MiB in 00:00
[Merger] Merging formats into "【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f21.mp4" -i "file:【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f2.m4a" -c copy -map "0:v:0" -map "1:a:0" -movflags "+faststart" "file:【杜比视界·全景声】00后摄影师带你走近治愈系「秘 境桂林」 [250458461_part1].temp.mp4"
Deleting original file 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f21.mp4 (pass -k to keep)
Deleting original file 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f2.m4a (pass -k to keep)
[download] Finished downloading playlist: 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」
'seid' 不是内部或外部命令，也不是可运行的程序
或批处理文件。
'spm_id_from' 不是内部或外部命令，也不是可运行的程序
或批处理文件。
'vd_source' 不是内部或外部命令，也不是可运行的程序
或批处理文件。


I have a member account and can help
You can see the audio bit rate of Dolby Atmos！
![2022-06-11 195102](https://user-images.githubusercontent.com/92282389/173186717-1ec3927f-543b-44ff-9c5e-bc0073c25d41.png)


Try passing logged in cookies
> Try passing logged in cookies

**Still not Dolby Vision and Dolby Atmos, potplayer shows HDR video**


D:\高清修复音乐录影带>yt-dlp -vU --cookies=cookies.txt https://www.bilibili.com/video/BV1zv411w7Aj?p=1
[debug] Command-line config: ['-vU', '--cookies=cookies.txt', 'https://www.bilibili.com/video/BV1zv411w7Aj?p=1']
[debug] Encodings: locale cp936, fs utf-8, pref cp936, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.05.18 [b14d523] (win_exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.22000-SP0
[debug] Checking exe version: ffprobe -bsfs
[debug] Checking exe version: ffmpeg -bsfs
[debug] exe versions: ffmpeg 2022-06-06-git-73302aa193-full_build-www.gyan.dev (setts), ffprobe 2022-06-06-git-73302aa193-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.14.1, brotli-1.0.9, certifi-2021.10.08, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.3
[debug] Proxy map: {'http': 'http://127.0.0.1:10809', 'https': 'https://127.0.0.1:10809', 'ftp': 'ftp://127.0.0.1:10809'}
Latest version: 2022.05.18, Current version: 2022.05.18
yt-dlp is up to date (2022.05.18)
[debug] [BiliBili] Extracting URL: https://www.bilibili.com/video/BV1zv411w7Aj?p=1
[BiliBili] 1zv411w7Aj: Grabbing original ID via API
[BiliBili] 250458461: Downloading webpage
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[BiliBili] 250458461: Extracting videos in anthology
[BiliBili] 250458461: Downloading tags
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 250458461_part1: Downloading 1 format(s): 31+2
[debug] Invoking http downloader on "https://upos-sz-mirrorhw.bilivideo.com/upgcxcode/79/81/407508179/407508179_dv1-1-30126.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1654957473&gen=playurlv2&os=hwbv&oi=0&trid=49fac91da29444e0bcdb0d3ed09fd155u&mid=24916087&platform=pc&upsig=c585186b3a6bbda041dd07193eb7d3e0&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&bvc=vod&nettype=0&orderid=0,2&agrr=0&bw=1171982&logo=80000000"
[debug] File locking is not supported on this platform. Proceeding without locking
[download] Destination: 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f31.mp4
[download] 100% of 223.54MiB in 00:20
[debug] Invoking http downloader on "https://upos-sz-mirrorcos.bilivideo.com/upgcxcode/79/81/407508179/407508179-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1654957473&gen=playurlv2&os=cosbv&oi=0&trid=49fac91da29444e0bcdb0d3ed09fd155u&mid=24916087&platform=pc&upsig=08e94983716bd51633ee31b8afb2e167&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&bvc=vod&nettype=0&orderid=0,2&agrr=0&bw=41257&logo=80000000"
[download] Destination: 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f2.m4a
[download] 100% of 7.87MiB in 00:02
[Merger] Merging formats into "【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f31.mp4" -i "file:【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f2.m4a" -c copy -map "0:v:0" -map "1:a:0" -movflags "+faststart" "file:【杜比视界·全景声】00后摄影师带你走近治愈系「秘 境桂林」 [250458461_part1].temp.mp4"
Deleting original file 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f2.m4a (pass -k to keep)
Deleting original file 【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].f31.mp4 (pass -k to keep)



General
Complete name                  : D:\高清修复音乐录影带\【杜比视界·全景声】00后摄影师带你走近治愈系「秘境桂林」 [250458461_part1].mp4
Format                         : MPEG-4
Format profile                 : Base Media
Codec ID                       : isom (isom/dby1/iso2/mp41)
File size                      : 232 MiB
Duration                       : 3 min 20 s
Overall bit rate               : 9 691 kb/s
Writing application            : Lavf59.24.100

Video
ID                             : 1
Format                         : HEVC
Format/Info                    : High Efficiency Video Coding
Format profile                 : Main 10@L5@Main
Codec ID                       : hvc1
Codec ID/Info                  : High Efficiency Video Coding
Duration                       : 3 min 20 s
Bit rate                       : 9 358 kb/s
Width                          : 3 840 pixels
Height                         : 1 920 pixels
Display aspect ratio           : 2.000
Frame rate mode                : Constant
Frame rate                     : 30.000 FPS
Color space                    : YUV
Chroma subsampling             : 4:2:0 (Type 0)
Bit depth                      : 10 bits
Bits/(Pixel*Frame)             : 0.042
Stream size                    : 223 MiB (97%)
Writing library                : x265 0.0:[Linux][GCC 6.3.0][64 bit] 10bit
Encoding settings              : cpuid=1111039 / frame-threads=16 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=3840x1920 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=3 / no-allow-non-conformance / repeat-headers / annexb / aud / hrd / info / hash=1 / no-temporal-layers / no-open-gop / min-keyint=150 / keyint=150 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=20 / lookahead-slices=8 / scenecut=0 / hist-scenecut=0 / radl=0 / splice / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=0 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=3 / limit-refs=1 / no-limit-modes / me=1 / subme=2 / merange=57 / temporal-mvp / no-frame-dup / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / sao / no-sao-non-deblock / rd=3 / selective-sao=4 / early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=0.00 / psy-rdoq=0.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=21.0 / qcomp=0.60 / qpstep=4 / stats-write=1 / stats-read=0 / slow-firstpass / vbv-maxrate=12000 / vbv-bufsize=12000 / vbv-init=0.8 / crf-max=0.0 / crf-min=0.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=9 / transfer=18 / colormatrix=9 / chromaloc=1 / chromaloc-top=0 / chromaloc-bottom=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / hist-threshold=0.01 / no-opt-cu-delta-qp / no-aq-motion / no-hdr10 / no-hdr10-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=0 / analysis-save-reuse-level=0 / analysis-load-reuse-level=0 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00 / no-scenecut-aware-qpconformance-window-offsets / right=0 / bottom=0 / decoder-max-rate=0
Color range                    : Limited
Color primaries                : BT.2020
Transfer characteristics       : HLG
Matrix coefficients            : BT.2020 non-constant
Codec configuration box        : hvcC

Audio
ID                             : 2
Format                         : AAC LC
Format/Info                    : Advanced Audio Codec Low Complexity
Codec ID                       : mp4a-40-2
Duration                       : 3 min 20 s
Bit rate mode                  : Constant
Bit rate                       : 328 kb/s
Channel(s)                     : 2 channels
Channel layout                 : L R
Sampling rate                  : 48.0 kHz
Frame rate                     : 46.875 FPS (1024 SPF)
Compression mode               : Lossy
Stream size                    : 7.83 MiB (3%)
Default                        : Yes
Alternate group                : 1


> Codec ID : isom (isom/dby1/iso2/mp41)

dby1 suggests Dolby Vision. Try using a more up to date version of MediaInfo.

Resolving patch:
diff --git a/yt_dlp/extractor/bilibili.py b/yt_dlp/extractor/bilibili.py
--- a/yt_dlp/extractor/bilibili.py
+++ b/yt_dlp/extractor/bilibili.py
@@ -47,14 +47,14 @@ def extract_formats(self, play_info):
             for r in traverse_obj(play_info, ('support_formats', lambda _, v: v['quality']))
         }
 
-        audios = traverse_obj(play_info, ('dash', 'audio', ...))
+        audios = traverse_obj(play_info, ('dash', (None, 'dolby'), 'audio', ..., {dict}))
         flac_audio = traverse_obj(play_info, ('dash', 'flac', 'audio'))
         if flac_audio:
             audios.append(flac_audio)
         formats = [{
             'url': traverse_obj(audio, 'baseUrl', 'base_url', 'url'),
             'ext': mimetype2ext(traverse_obj(audio, 'mimeType', 'mime_type')),
-            'acodec': audio.get('codecs'),
+            'acodec': traverse_obj(audio, ('codecs', {str.lower})),
             'vcodec': 'none',
             'tbr': float_or_none(audio.get('bandwidth'), scale=1000),
             'filesize': int_or_none(audio.get('size')),
@@ -69,6 +69,7 @@ def extract_formats(self, play_info):
             'height': int_or_none(video.get('height')),
             'vcodec': video.get('codecs'),
             'acodec': 'none' if audios else None,
+            'dynamic_range': {126: 'DV', 125: 'HDR10'}.get(int_or_none(video.get('id'))),
             'tbr': float_or_none(video.get('bandwidth'), scale=1000),
             'filesize': int_or_none(video.get('size')),
             'quality': int_or_none(video.get('id')),


Test patch: