feat: add devcontainer/nix support and refactor into modules

- Add .devcontainer/devcontainer.json for Podman development
- Add shell.nix for Nix users
- Refactor monolithic main.cpp into modular components:
  - parser: argument parsing
  - validator: configuration validation
  - converter: ffmpeg command building/execution
- Update Makefile with proper dependencies and test target
- Simplify build.sh to use make
- Update README with development environment docs
This commit is contained in:
tkmxqrdxddd
2026-03-16 17:35:35 +01:00
parent 64cde37777
commit 75285276e4
13 changed files with 418 additions and 299 deletions

190
README.md
View File

@@ -1,105 +1,137 @@
# Davinci Video Converter
# DaVinci Video Converter
This is a simple tool that converts your `.mp4` videos into a format that DaVinci Resolve uses on Linux. The application utilizes `ffmpeg` for video conversion.
A command-line video conversion tool optimized for DaVinci Resolve workflows.
## Features
- Convert `.mp4` videos to DNxHD format.
- Simple command-line interface for user input.
- Convert videos using various codecs (H.264, H.265, ProRes)
- Quality presets for different use cases
- CRF-based quality control
- Verbose output for debugging
## Prerequisites
## Development Environment
Before building and running the application, ensure you have the following installed:
### DevContainer (Podman)
- `g++` (GNU C++ Compiler)
- `make` (Build automation tool)
- `ffmpeg` (Multimedia framework for handling video, audio, and other multimedia files)
This project includes a DevContainer configuration for use with Podman. To use it:
## Installation
1. Install the Dev Containers extension in VS Code
2. Configure VS Code to use Podman:
- Set `remote.containers.defaultDockerCommand` to `podman` in VS Code settings
3. Reopen the project in the container (Ctrl+Shift+P → "Dev Containers: Reopen in Container")
### Using the Build Script
The container includes all necessary dependencies (g++, make, ffmpeg).
1. Clone the repository:
```bash
git clone (https://github.com/tkmxqrdxddd/davinci-video-converter)
cd davinci-video-converter
```
### Nix Shell
2. Run the build script to install dependencies and build the project:
```bash
./build.sh
```
This script will automatically install the required dependencies based on your Linux distribution and build the project. It will also install the application to `/usr/bin`, making it accessible from anywhere.
### Manual Installation
If you prefer to install manually, follow these steps:
1. Install the required dependencies (if not already installed):
- For Debian-based systems:
```bash
sudo apt-get install -y build-essential ffmpeg
```
- For Red Hat-based systems:
```bash
sudo dnf install -y gcc-c++ ffmpeg make
```
- For Arch Linux:
```bash
sudo pacman -Syu --noconfirm base-devel ffmpeg
```
- For openSUSE:
```bash
sudo zypper install -y gcc-c++ ffmpeg make
```
- For Alpine Linux:
```bash
sudo apk add --no-cache g++ ffmpeg make
```
2. Build the project using `make`:
```bash
make
```
This will create an executable named `davinci-convert` in the `output` directory.
3. Install the application:
```bash
make install
```
## Running the Program
To run the program, use the following command:
For Nix users, enter the development shell:
```bash
davinci-convert
nix-shell
```
### Usage
This provides a development environment with g++, make, and ffmpeg.
1. When prompted, enter the input file path of the `.mp4` video you want to convert.
2. Enter the desired output file path (including the filename and extension) for the converted video.
3. The program will start the conversion process. You will see messages indicating the progress.
4. Once the conversion is complete, you will receive a success message.
## Building
### Cleaning Up
### Using Make
```bash
make
```
### Using build.sh
```bash
./build.sh
```
### Clean Build
To clean up the generated files (object files and the executable), run:
```bash
make clean
```
## Contributing
## Usage
If you would like to contribute to this project, please fork the repository and submit a pull request. Any contributions, bug reports, or feature requests are welcome!
```bash
./davinci-video-converter [options] <input> <output>
```
### Options
| Option | Description | Default |
|--------|-------------|---------|
| `-c, --codec <codec>` | Video codec (h264, h265, prores) | h264 |
| `-q, --quality <qual>` | Quality preset (fast, medium, slow) | medium |
| `-r, --crf <value>` | CRF value 0-51 | 23 |
| `-v, --verbose` | Enable verbose output | false |
| `-h, --help` | Show help message | - |
### Examples
Convert with default settings:
```bash
./davinci-video-converter input.mp4 output.mp4
```
Convert with H.265 codec and slow preset:
```bash
./davinci-video-converter -c h265 -q slow input.mp4 output.mp4
```
Convert with custom CRF value:
```bash
./davinci-video-converter -r 18 input.mp4 output.mp4
```
Verbose conversion:
```bash
./davinci-video-converter -v input.mp4 output.mp4
```
## Testing
Run the built-in tests:
```bash
make test
```
## Installation
```bash
sudo make install
```
## Uninstallation
```bash
sudo make uninstall
```
## Project Structure
```
davinci-video-converter/
├── .devcontainer/
│ └── devcontainer.json # DevContainer configuration for Podman
├── src/
│ ├── include/
│ │ ├── config.hpp # Configuration struct definition
│ │ ├── converter.hpp # Converter module interface
│ │ ├── parser.hpp # Argument parser interface
│ │ └── validator.hpp # Validator module interface
│ ├── main.cpp # Main entry point
│ ├── parser.cpp # Argument parsing implementation
│ ├── validator.cpp # Configuration validation
│ └── converter.cpp # FFmpeg command building and execution
├── shell.nix # Nix development environment
├── Makefile # Build configuration
├── build.sh # Build script
└── README.md
```
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Acknowledgments
- This project uses `ffmpeg` for video conversion. For more information, visit the [FFmpeg website](https://ffmpeg.org/).
MIT