@@ -373,7 +373,8 @@ bool export_media(
373373 int threshold = 128,
374374 Audio audio = Audio::off,
375375 int fps = 0,
376- const ExportConfig& config = ExportConfig() // Customize rendering style
376+ const ExportConfig& config = ExportConfig(), // Customize rendering style
377+ bool use_gpu = true // Use GPU/hardware acceleration
377378);
378379```
379380
@@ -391,6 +392,7 @@ bool export_media(
391392| ` audio ` | ` Audio ` | ` Audio::off ` | Whether to include audio in video exports |
392393| ` fps ` | ` int ` | ` 0 ` | Frame rate for video export (0 = original fps) |
393394| ` config ` | ` ExportConfig ` | ` ExportConfig() ` | Rendering customization (dot_size, density, colors) |
395+ | ` use_gpu ` | ` bool ` | ` true ` | Use GPU/hardware acceleration for encoding (see below) |
394396
395397### Format Enum
396398
@@ -573,12 +575,18 @@ int main() {
573575
574576### How Video Export Works
575577
576- 1 . ** Frame extraction ** : FFmpeg extracts frames from the source video
577- 2 . ** ASCII rendering** : Each frame is rendered to ASCII/Braille art using the specified mode
578+ 1 . ** Preprocessing ** : FFmpeg extracts frames from the source video (progress shown with animated bar)
579+ 2 . ** ASCII rendering** : Each frame is rendered to ASCII/Braille art using ** multithreaded processing **
5785803 . ** Image rendering** : The ASCII art is rendered to actual pixels (proper Braille dot rendering)
579- 4 . ** Video encoding** : All frames are combined back into an MP4 video
581+ 4 . ** Video encoding** : All frames are combined back into an MP4 video using hardware or CPU encoder
5805825 . ** Audio muxing** (optional): Audio track is extracted and muxed with the video
581583
584+ ** Multithreading:**
585+
586+ - Frame rendering automatically uses multiple CPU threads (up to 16)
587+ - Thread count is based on ` std::thread::hardware_concurrency() `
588+ - Progress bar shows real-time completion percentage
589+
582590### Output Quality
583591
584592The exported video/image quality depends on:
@@ -599,6 +607,46 @@ sudo apt install ffmpeg
599607brew install ffmpeg
600608```
601609
610+ ### GPU Acceleration
611+
612+ Video export automatically uses hardware acceleration when available. The ` use_gpu ` parameter controls this behavior:
613+
614+ | ` use_gpu ` | Behavior |
615+ | ---------------- | ---------------------------------------------------------------- |
616+ | ` true ` (default) | Automatically detect and use the best available hardware encoder |
617+ | ` false ` | Force CPU-only encoding with ` libx264 ` |
618+
619+ ** Supported Hardware Encoders:**
620+
621+ | GPU Vendor | Encoder | Platform |
622+ | ---------- | ------------------- | ------------------------ |
623+ | NVIDIA | ` h264_nvenc ` | Linux, Windows |
624+ | AMD/Intel | ` h264_vaapi ` | Linux |
625+ | Intel | ` h264_qsv ` | Linux, Windows |
626+ | Apple | ` h264_videotoolbox ` | macOS |
627+ | CPU | ` libx264 ` | All platforms (fallback) |
628+
629+ ** How it works:**
630+
631+ 1 . On startup, the system detects available GPUs (NVIDIA, AMD, Intel, Apple)
632+ 2 . FFmpeg is probed to find which hardware encoders are available
633+ 3 . The best encoder is automatically selected based on your hardware
634+ 4 . If no hardware encoder is available, falls back to CPU encoding
635+
636+ ** Performance:**
637+
638+ - Hardware encoding is typically ** 5-20x faster** than CPU encoding
639+ - CPU encoding uses ** multithreading** (auto-detects cores, up to 16 threads)
640+ - Progress is shown during both preprocessing (frame extraction) and rendering
641+
642+ ** Forcing CPU encoding:**
643+
644+ ``` cpp
645+ // Force CPU encoding (useful for compatibility or debugging)
646+ export_media ("video.mp4", "output", Type::video, Format::video,
647+ Mode::colored, 80, 128, Audio::on, 0, {}, false);
648+ ```
649+
602650Image export requires **ImageMagick** for PNG conversion:
603651
604652```bash
0 commit comments