Skip to content

Commit 91b7d50

Browse files
authored
docs: document (#7)
1 parent 361dc09 commit 91b7d50

File tree

6 files changed

+215
-4
lines changed

6 files changed

+215
-4
lines changed

README.md

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,85 @@
11
# bili-pc-mp4
2-
MP4 convertor for videos downloaded by the Bilibili pc application.
2+
3+
[![npm](https://img.shields.io/npm/v/bili-pc-mp4.svg?style=flat-square)](https://www.npmjs.com/package/bili-pc-mp4)
4+
![license](https://img.shields.io/npm/l/bili-pc-mp4.svg?style=flat-square)
5+
![size](https://img.shields.io/github/repo-size/yinyanfr/bili-pc-mp4?style=flat-square)
6+
[![GitHub release](https://img.shields.io/github/release/yinyanfr/bili-pc-mp4.svg?style=flat-square)](https://github.com/yinyanfr/bili-pc-mp4/releases/latest)
7+
8+
```bash
9+
npx bili-pc-mp4 ~/Movies/bilibili
10+
```
11+
12+
中文文档 | [English Document](./docs/README.en.md)
13+
14+
`bili-pc-mp4` 是用于将「Bilibili 桌面客户端」(Windows(非 UMP), Mac 版)下载的视频转换为 MP4 格式的工具。
15+
16+
**请注意 `bili-pc-mp4` 并非下载器**,您需要先通过「Bilibili 桌面客户端」对视频进行「离线缓存」。
17+
18+
`bili-pc-mp4` 仅支持由「Bilibili 桌面客户端」下载的视频,不支持其它平台客户端。
19+
20+
您需要先[安装 ffmpeg](./docs/ffmpeg.md).
21+
22+
## :star2: 特性
23+
24+
- 解密并合并视频,不损失音画质
25+
- 支持批量转换多个视频
26+
- 支持查看视频信息
27+
- 简单易用的命令行工具
28+
- 低内存占用
29+
30+
## :wrench: 命令行工具
31+
32+
### 转换视频
33+
34+
您可以使用页首的简单命令,或使用完整命令:
35+
36+
```bash
37+
npx bili-pc-mp4 convert -i ~/Movies/bilibili -o ~/Movies/converted
38+
```
39+
40+
命令行支持如下选项:
41+
42+
| 名称 | 类型 | 简介 |
43+
| ------------------- | ---- | ------------------------------------------------------------------------------ |
44+
| `--input, -i` | 路径 | 指定要转换的视频位置,可以是单个视频的文件夹,也可以是包含多个视频的文件夹。 |
45+
| `--output, -o` | 路径 | 指定输出视频的位置,默认为当前位置。 |
46+
| `--page-number, -p` | | 是否在输出的视频文件名前加入分p 序号。 |
47+
| `--silience, -s` | | 是否取消终端输出。 |
48+
| `--buffer-size, -b` | 数字 | 指定读取文件流的分块大小(KB),默认为64 MB,为使解密有效,该值应不少于 16 KB. |
49+
50+
你可以输入以下命令查看完整帮助信息和使用示例:
51+
52+
```bash
53+
npx bili-pc-mp4 help
54+
```
55+
56+
### 查看视频信息
57+
58+
```bash
59+
npx bili-pc-mp4 list ~/Movies/bilibili
60+
```
61+
62+
## :book: 作为库使用
63+
64+
您也可以讲 `bili-pc-mp4` 作为库使用,`bili-pc-mp4` 使用 CommonJS.
65+
66+
`bili-pc-mp4` 完整使用 JSDoc,各功能及选项与命令行一致。
67+
68+
```bash
69+
npm i bili-pc-mp4
70+
```
71+
72+
```typescript
73+
import { listVideos, processFolder } from 'bili-pc-mp4';
74+
75+
// 查看视频信息
76+
await listVideos('./bilibili');
77+
78+
// 转换视频
79+
await processFolder('./bilibili', {
80+
output: './converted',
81+
pageNumber: true,
82+
silence: true,
83+
bufferSize: 64 * 1024,
84+
});
85+
```

docs/README.en.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# bili-pc-mp4
2+
3+
[![npm](https://img.shields.io/npm/v/bili-pc-mp4.svg?style=flat-square)](https://www.npmjs.com/package/bili-pc-mp4)
4+
![license](https://img.shields.io/npm/l/bili-pc-mp4.svg?style=flat-square)
5+
![size](https://img.shields.io/github/repo-size/yinyanfr/bili-pc-mp4?style=flat-square)
6+
[![GitHub release](https://img.shields.io/github/release/yinyanfr/bili-pc-mp4.svg?style=flat-square)](https://github.com/yinyanfr/bili-pc-mp4/releases/latest)
7+
8+
[中文文档](../README.md) | English Document
9+
10+
`bili-pc-mp4` is a tool for converting videos downloaded from the "Bilibili Desktop Client" (Windows (non-UMP), Mac version) into MP4 format.
11+
12+
Please note that `bili-pc-mp4` is not a downloader, and you need to first use the "Bilibili Desktop Client" to perform "offline caching" of the videos.
13+
14+
`bili-pc-mp4 only` supports videos downloaded using the "Bilibili Desktop Client" and does not support other platform clients.
15+
16+
You need to first [install ffmpeg](./ffmpeg.en.md).
17+
18+
## :star2: Features
19+
20+
- Decrypts and merges videos without loss of audio and video quality.
21+
- Supports batch conversion of multiple videos.
22+
- Supports viewing video information.
23+
- Simple and easy-to-use command-line tool.
24+
- Low memory usage.
25+
26+
## :wrench: Command-Line Tool
27+
28+
### Convert Videos
29+
30+
You can use the simple command at the top of the page or use the complete command:
31+
32+
```bash
33+
npx bili-pc-mp4 convert -i ~/Movies/bilibili -o ~/Movies/converted
34+
```
35+
36+
| Name | Type | Description |
37+
| ------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
38+
| `--input, -i` | Path | Specifies the location of the videos to be converted. It can be a folder containing a single video or multiple videos. |
39+
| `--output, -o` | Path | Specifies the output location for the videos. Defaults to the current location. |
40+
| `--page-number, -p` | | Whether to include the page number (分p) before the output video filename. |
41+
| `--silence, -s` | | Whether to suppress terminal output. |
42+
| `--buffer-size, -b` | Number | Specifies the block size (in KB) for reading file streams. Defaults to 64 MB. For effective decryption, this value should not be less than 16 KB. |
43+
44+
You can input the following command to see complete help information and usage examples:
45+
46+
```bash
47+
npx bili-pc-mp4 help
48+
```
49+
50+
### View Video Information
51+
52+
```bash
53+
npx bili-pc-mp4 list ~/Movies/bilibili
54+
```
55+
56+
## :book: Using as a Library
57+
58+
You can also use `bili-pc-mp4` as a library; bili-pc-mp4 uses CommonJS.
59+
60+
`bili-pc-mp4` has complete JSDoc, and its features and options are consistent with the command-line.
61+
62+
```bash
63+
npm i bili-pc-mp4
64+
```
65+
66+
```typescript
67+
import { listVideos, processFolder } from 'bili-pc-mp4';
68+
69+
// View video information
70+
await listVideos('./bilibili');
71+
72+
// Convert videos
73+
await processFolder('./bilibili', {
74+
output: './converted',
75+
pageNumber: true,
76+
silence: true,
77+
bufferSize: 64 * 1024,
78+
});
79+
```

docs/ffmpeg.en.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Installing ffmpeg
2+
3+
[中文文档](./ffmpeg.md) | English Document
4+
5+
You can directly obtain it from the [ffmpeg project website](https://ffmpeg.org/download.html).
6+
7+
Alternatively, you can use a package manager for your operating system.
8+
9+
## Windows
10+
11+
You can use [Chocolatey](https://chocolatey.org/install), and install ffmpeg with the following command.
12+
13+
```bash
14+
choco install ffmpeg
15+
```
16+
17+
## Mac OS
18+
19+
You can use [Homebrew](https://brew.sh/), and install ffmpeg with the following command.
20+
21+
```bash
22+
brew install ffmpeg
23+
```

docs/ffmpeg.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 安装 ffmpeg
2+
3+
中文文档 | [English Document](./ffmpeg.en.md)
4+
5+
您可以直接从 [ffmpeg 项目网站](https://ffmpeg.org/download.html)获取。
6+
7+
或使用适用于您操作系统的管理器。
8+
9+
## Windows
10+
11+
您可以使用 [Chocolatey](https://chocolatey.org/install),并通过如下命令安装 ffmpeg.
12+
13+
```bash
14+
choco install ffmpeg
15+
```
16+
17+
## Mac OS
18+
19+
您可以使用 [Homebrew](https://brew.sh/),并通过如下命令安装 ffmpeg.
20+
21+
```bash
22+
brew install ffmpeg
23+
```

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bili-pc-mp4",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "MP4 convertor for videos downloaded by the Bilibili pc application.",
55
"main": "dist/index.js",
66
"bin": "dist/cli/index.js",
@@ -12,7 +12,10 @@
1212
"lint-staged": "lint-staged",
1313
"prepare": "husky install"
1414
},
15-
"keywords": [],
15+
"keywords": [
16+
"bilibili",
17+
"bilibili-download"
18+
],
1619
"author": "",
1720
"repository": {
1821
"type": "git",

src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function analyseFolder(dirPath: string): Promise<Task[]> {
8282
* @param {number} [bufferSize=65536] - The size of the buffer for reading the file.
8383
* @returns {ReadStream} A readable stream containing the decrypted file content.
8484
*/
85-
function decryptedBuffer(filePath: string, bufferSize = 1024 * 64) {
85+
function decryptedBuffer(filePath: string, bufferSize = 64 * 1024) {
8686
const readStream = createReadStream(filePath, { highWaterMark: bufferSize });
8787
let isFirstChunk = true;
8888

0 commit comments

Comments
 (0)