# Bilibili Extract Audio

> Extracts audio (including music and other permitted audio) from a Bilibili video the user has the right to access and save, given a BV ID or bilibili.com/b23.tv URL. Use when the user asks to save, convert, or extract Bilibili audio as MP3, M4A, OPUS, WAV, or the original stream, including content that may need a logged-in browser session.

- Skill: `caimao123/bilibili-extract-audio` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add caimao123/bilibili-extract-audio`
- Raw SKILL.md: https://api.skillmd.com/api/skills/caimao123/bilibili-extract-audio/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: caimao123 (https://skillmd.com/u/caimao123)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/caimao123/bilibili-extract-audio

---


# Extract Bilibili Audio

Use the bundled CLI. Extract audio from Bilibili videos the user has the right to access and save (permitted audio, music, and similar). Do not bypass access controls.

## Run

```bash
python scripts/extract_audio.py <BV-or-URL>
```

Resolve `scripts/extract_audio.py` relative to this skill directory. Output defaults to `~/Music/Bilibili` (override with `--output-dir`, or `BILIBILI_AUDIO_OUTPUT_DIR`). Default to the best original audio stream without transcoding. For an M4A source, rewrite only the container as a standard fast-start M4A; preserve the encoded audio bit-for-bit.

Useful options:

- `--format mp3|m4a|opus|wav|original` only when the user requests a specific format
- `--keep-container` to retain Bilibili's original DASH container
- `--bitrate 192` for converted formats
- `--cookies-from-browser chrome|edge|firefox` only when the user explicitly asks to use an existing logged-in session
- `--all-parts` to process every part of a multipart video

If dependencies are missing:

```bash
python -m pip install --user -U yt-dlp imageio-ffmpeg
```

## Report

Return the generated filename(s). Preserve errors from Bilibili or `yt-dlp`. Explain authentication, region, membership, or removed-video errors without attempting to circumvent them.

