feat: argparse and dry-run.
This commit is contained in:
65
README.md
65
README.md
@@ -1,9 +1,70 @@
|
||||
# bilibili-merge
|
||||
|
||||
Merge bilibili downloaded videos.
|
||||
Merge bilibili downloaded videos with audio files.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
```bash
|
||||
cargo install bilibili-merge
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
bilibili-merge [OPTIONS] [PATH]
|
||||
```
|
||||
|
||||
### Arguments
|
||||
|
||||
- `PATH` - Path to the directory containing video and audio files (default: current directory)
|
||||
|
||||
### Options
|
||||
|
||||
- `-n, --dry-run` - Dry run mode: show what would be done without actually doing it
|
||||
- `-f, --force` - Force overwrite existing files
|
||||
- `-h, --help` - Print help information
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Video File Selection**: The tool automatically finds the **largest file** (by file size) in the specified directory and uses it as the video file. This means:
|
||||
- If there's only one video file, it will be selected
|
||||
- If there are multiple files, the largest one (by size) will be selected
|
||||
- Only files (not directories) are considered
|
||||
- The selection is based on file size, not file name
|
||||
|
||||
2. **Audio File Matching**: The tool looks for an audio file with the same base name as the video file, but with `.m4a` extension. For example:
|
||||
- Video: `video.mp4` → Audio: `video.m4a`
|
||||
- Video: `episode_01.flv` → Audio: `episode_01.m4a`
|
||||
|
||||
3. **Processing Steps**:
|
||||
- Converts the audio file from M4A to AAC format
|
||||
- Renames the original video file to `original.<extension>` as a backup
|
||||
- Merges the video and audio into a single file
|
||||
- The merged file is saved as `<original_name>.mp4` (always MP4 format, regardless of input format)
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
# Merge video and audio in current directory
|
||||
bilibili-merge
|
||||
|
||||
# Merge video and audio in a specific directory
|
||||
bilibili-merge /path/to/video/directory
|
||||
|
||||
# Dry run to see what would be done
|
||||
bilibili-merge -n
|
||||
|
||||
# Force overwrite existing files
|
||||
bilibili-merge -f
|
||||
|
||||
# Combine options
|
||||
bilibili-merge -n -f /path/to/directory
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- The tool requires `ffmpeg` to be installed and available in your PATH
|
||||
- By default, the tool will **not** overwrite existing files (use `-f` to force)
|
||||
- The original video file is automatically backed up as `original.<extension>`
|
||||
- The output file is always in MP4 format, regardless of the input video format
|
||||
- In dry-run mode, you'll get a shell script that you can review or execute manually
|
||||
|
||||
Reference in New Issue
Block a user