Mercurial
diff media_processor/README.md @ 217:7ef4c9d2a72d hg-web
[DO NOT PUSH] Random values.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Sun, 25 Jan 2026 10:44:04 -0800 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/media_processor/README.md Sun Jan 25 10:44:04 2026 -0800 @@ -0,0 +1,85 @@ +# media_processor + +Reusable media processing library for images and videos. + +## Features + +- **Image Processing**: Convert images to WebP format with quality/size options +- **Video Processing**: Convert videos to HLS format for streaming +- **Auto-detection**: Automatically detects media type from file extension +- **Thumbnail Generation**: Creates thumbnails for videos +- **Original Preservation**: Keeps original files alongside processed versions + +## Usage + +```c +#include "media_processor/media_processor.h" + +// Process any media file (auto-detects type) +MediaProcessorOpts opts = media_processor_opts_default("./output"); +opts.image_quality = 85; +opts.video_max_width = 1920; + +char* id = media_generate_id(); +MediaResult* result = media_process_file("upload.mp4", id, &opts); + +if (result->status == MEDIA_STATUS_COMPLETED) { + printf("HLS playlist: %s\n", result->hls_playlist); + printf("Thumbnail: %s\n", result->thumbnail_path); +} + +media_result_free(result); +free(id); +``` + +## Output Structure + +For images: +``` +output/ +└── {id}/ + ├── original.jpg # Original file + └── image.webp # Converted WebP +``` + +For videos: +``` +output/ +└── {id}/ + ├── original.mp4 # Original file + ├── video.m3u8 # HLS playlist + ├── video_000.ts # HLS segments + ├── video_001.ts + └── video_thumb.jpg # Thumbnail +``` + +## Options + +### Image Options + +| Option | Default | Description | +|--------|---------|-------------| +| `image_quality` | 80 | WebP quality (0-100) | +| `image_max_width` | 0 | Max width (0 = no limit) | +| `image_max_height` | 0 | Max height (0 = no limit) | + +### Video Options + +| Option | Default | Description | +|--------|---------|-------------| +| `video_segment_duration` | 6 | HLS segment length in seconds | +| `video_bitrate` | 0 | Video bitrate in kbps (0 = auto) | +| `video_max_width` | 0 | Max width (0 = no limit) | +| `video_max_height` | 0 | Max height (0 = no limit) | +| `generate_thumbnail` | true | Generate video thumbnail | + +## Building + +```bash +bazel build //media_processor:media_processor +``` + +## Dependencies + +- `//third_party/ffmpeg:ffmpeg_cli` - FFmpeg CLI wrapper +- `//dowa:dowa` - Memory and string utilities