A Python tool for organizing and compressing GoPro videos using FFmpeg. It automatically sorts multi-part GoPro video sequences into folders and concatenates/compresses them with hardware or software encoding.
- Automatic Organization: Sorts GoPro video files into sequence-based folders
- Video Concatenation: Merges multi-part GoPro recordings into single files
- Hardware Acceleration: Supports Intel Quick Sync Video (QSV) for faster encoding
- Codec Options: H.265 (HEVC) and H.264 encoding support
- Metadata Preservation: Retains original timestamps and GoPro telemetry data
- Configurable Bitrate: Automatic bitrate calculation based on resolution with customizable limits
- Python 3.10+ (uses match-case syntax)
- FFmpeg with QSV support (for hardware acceleration)
- Linux/Unix environment (uses bash commands)
pip install ffprobe-pythonpip install -r requirements-dev.txt- ffmpeg: Video processing
- exiftool: Metadata handling
- udtacopy (optional): GoPro telemetry data copying
-
Clone the repository:
git clone https://github.com/Re4zOon/video-conversion.git cd video-conversion -
Install Python dependencies:
pip install -r requirements.txt
-
Ensure FFmpeg and exiftool are installed:
# Debian/Ubuntu sudo apt install ffmpeg exiftool # Fedora sudo dnf install ffmpeg perl-Image-ExifTool
python video.py -v /path/to/videos [options]| Argument | Short | Default | Description |
|---|---|---|---|
--videos |
-v |
required | Path to the videos folder |
--codec |
-c |
h265 |
Video codec (h265 or h264) |
--accelerator |
-a |
qsv |
Encoding method (qsv for Intel QuickSync, cpu for software) |
--convert |
-C |
enabled | Disable to skip video conversion (concatenate only) |
--mbits_max |
-mx |
25 |
Maximum bitrate in Mbps |
--ratio_max |
-rx |
0.70 |
Maximum ratio of original bitrate |
--bitratemodifier |
-bm |
0.12 |
Bitrate calculation modifier |
--resume |
-R |
disabled | Skip sequences that already have output files |
Compress videos with H.265 using Intel QSV:
python video.py -v /path/to/gopro/videosUse software encoding with H.264:
python video.py -v /path/to/videos -c h264 -a cpuConcatenate only (no re-encoding):
python video.py -v /path/to/videos -CSet maximum bitrate to 15 Mbps:
python video.py -v /path/to/videos -mx 15- Press
Ctrl+Cor sendSIGTERMto stop conversion. Temporary concat files and partial outputs are cleaned up on interruption. - Use
--resumeto skip sequences that already have converted output files from a previous run. FFmpeg does not support mid-file resume, so interrupted conversions restart from the beginning. - If an output file already exists, the tool prompts to overwrite, rename, or cancel (unless
--resumeis used).
GoPro cameras create file sequences with naming conventions like:
GH010001.MP4,GH020001.MP4, ... (Hero cameras)GX010001.MP4,GX020001.MP4, ... (Hero cameras with GPS)
The tool extracts the sequence identifier (e.g., 0001) and groups related files into folders.
For each sequence folder:
- Files are concatenated using FFmpeg's concat demuxer
- Video is re-encoded (if conversion enabled) with calculated bitrate
- Metadata (timestamps) are preserved using exiftool
- GoPro telemetry data (bin_data stream) is optionally preserved
The target bitrate is calculated based on:
- Video resolution (preset values for 1080p, 1520p, 4K)
- Frame rate and pixel count for non-standard resolutions
- Limited by
ratio_max(percentage of original bitrate) - Capped at
mbits_maxmegabits per second
videos_folder/
├── GH010001.MP4 # Before: loose video files
├── GH020001.MP4
├── GX010002.MP4
└── GX020002.MP4
videos_folder/ # After: organized and converted
├── 0001/
│ ├── GH010001.MP4
│ └── GH020001.MP4
├── 0002/
│ ├── GX010002.MP4
│ └── GX020002.MP4
├── GH010001.MP4 # Converted output files
└── GX010002.MP4
Ensure Intel Media Driver is installed:
# Check for VA-API support
vainfo
# Install Intel media driver (Ubuntu)
sudo apt install intel-media-va-driver-non-freeThis error occurs when a video has additional streams that aren't recognized as GoPro telemetry. The tool expects stream index 3 to be bin_data for GoPro files with telemetry.
If file metadata (timestamps/permissions) cannot be copied after conversion, the tool logs a warning but keeps the converted output file.
This project is open source. Feel free to modify and distribute.
Contributions are welcome! Please feel free to submit issues or pull requests.