Files
2gopus/go-version/README.md
2026-03-22 00:54:34 -07:00

201 lines
5.2 KiB
Markdown

# 2gopus - Audio to Opus Converter (Go Version)
A modern, feature-rich audio conversion tool written in Go that converts various audio formats to Opus/OGG format with extensive configuration options.
## Features
- **Multiple Input Formats**: MP3, WAV, FLAC, OGG, M4A, AAC, WMA
- **High-Quality Output**: Opus and OGG formats
- **Concurrent Processing**: Multi-threaded conversion for faster processing
- **Flexible Configuration**: Extensive options for quality, bitrate, sample rate, and more
- **Batch Processing**: Convert entire directories recursively
- **Safety Features**: Dry-run mode, verbose logging, and error handling
- **Cross-Platform**: Works on Linux, macOS, and Windows
## Installation
### Prerequisites
- Go 1.21 or later
- Git (for dependency management)
### Build from Source
```bash
# Clone or download the source
cd 2gopus
# Download dependencies
make deps
# Build the binary
make build
# Install system-wide (optional)
sudo make install
```
## Usage
### Basic Usage
```bash
# Convert all audio files in current directory
./2gopus-go
# Convert files from specific directory
./2gopus-go -input /path/to/music -output /path/to/converted
# High quality conversion
./2gopus-go -quality 8 -bitrate 192
# Preview what would be converted (dry run)
./2gopus-go -dry-run -verbose
```
### Advanced Usage
```bash
# Fast conversion with 8 threads, delete originals
./2gopus-go -threads 8 -delete -verbose
# Convert to OGG format with specific settings
./2gopus-go -format ogg -quality 6 -bitrate 160 -samplerate 48000
# Process only current directory (no recursion)
./2gopus-go -recursive=false -input ./music
```
## Command Line Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `-input` | string | "." | Input directory to scan for audio files |
| `-output` | string | "." | Output directory for converted files |
| `-quality` | int | 5 | Opus quality setting (0-10, higher is better) |
| `-bitrate` | int | 128 | Target bitrate in kbps |
| `-samplerate` | int | 48000 | Sample rate for output |
| `-channels` | int | 2 | Number of channels (1=mono, 2=stereo) |
| `-recursive` | bool | true | Scan subdirectories recursively |
| `-delete` | bool | false | Delete original files after conversion |
| `-threads` | int | 4 | Number of concurrent conversion threads |
| `-verbose` | bool | false | Enable verbose output |
| `-dry-run` | bool | false | Show what would be converted without converting |
| `-format` | string | "opus" | Output format (opus, ogg) |
| `-compression` | int | 5 | Compression level (0-10) |
| `-help`, `-h` | bool | false | Show help message |
## Examples
### Batch Conversion
```bash
# Convert entire music library
./2gopus-go -input /home/user/Music -output /home/user/Music/Opus -quality 7 -threads 8
```
### High Quality Conversion
```bash
# Maximum quality settings
./2gopus-go -quality 10 -bitrate 320 -samplerate 48000 -channels 2
```
### Space-Saving Conversion
```bash
# Lower quality for smaller files
./2gopus-go -quality 3 -bitrate 64 -delete
```
### Preview Mode
```bash
# See what would be converted
./2gopus-go -dry-run -verbose -input /path/to/audio
```
## Supported Formats
### Input Formats
- **MP3** (.mp3) - MPEG Audio Layer III
- **WAV** (.wav) - Waveform Audio File Format
- **FLAC** (.flac) - Free Lossless Audio Codec
- **OGG** (.ogg) - Ogg Vorbis
- **M4A** (.m4a) - MPEG-4 Audio
- **AAC** (.aac) - Advanced Audio Coding
- **WMA** (.wma) - Windows Media Audio
### Output Formats
- **Opus** (.opus) - Modern, efficient audio codec
- **OGG** (.ogg) - Ogg container with Opus codec
## Performance Tips
1. **Use Multiple Threads**: Increase `-threads` for faster conversion on multi-core systems
2. **Quality vs Speed**: Higher quality settings take longer but produce better results
3. **Batch Processing**: Process large directories in batches to manage memory usage
4. **Storage**: Use `-delete` carefully - test with `-dry-run` first
## Troubleshooting
### Common Issues
1. **"No audio files found"**
- Check that your input directory contains supported audio formats
- Verify file extensions are lowercase (.mp3, not .MP3)
2. **"Permission denied"**
- Ensure you have read access to input files
- Ensure you have write access to output directory
3. **"Out of memory"**
- Reduce the number of threads with `-threads`
- Process files in smaller batches
### Debug Mode
Use verbose mode to see detailed conversion information:
```bash
./2gopus-go -verbose -input /path/to/audio
```
## Development
### Building from Source
```bash
# Install dependencies
go mod download
# Run tests
go test -v
# Build for current platform
go build -o 2gopus-go main.go
# Build for multiple platforms
GOOS=linux GOARCH=amd64 go build -o 2gopus-go-linux main.go
GOOS=windows GOARCH=amd64 go build -o 2gopus-go.exe main.go
GOOS=darwin GOARCH=amd64 go build -o 2gopus-go-macos main.go
```
### Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
## License
This project is open source. Please check the license file for details.
## Changelog
### Version 1.0.0
- Initial Go implementation
- Support for MP3 and WAV input formats
- Opus output format
- Multi-threaded processing
- Extensive configuration options
- Cross-platform support