Mercurial
diff third_party/ffmpeg/ffmpeg_cli.h @ 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/third_party/ffmpeg/ffmpeg_cli.h Sun Jan 25 10:44:04 2026 -0800 @@ -0,0 +1,57 @@ +#ifndef FFMPEG_CLI_H +#define FFMPEG_CLI_H + +#include <stdbool.h> + +// Result codes +typedef enum { + FFMPEG_OK = 0, + FFMPEG_ERR_INPUT_NOT_FOUND = 1, + FFMPEG_ERR_OUTPUT_FAILED = 2, + FFMPEG_ERR_INVALID_ARGS = 3, + FFMPEG_ERR_PROCESS_FAILED = 4, +} FfmpegResult; + +// Image conversion options +typedef struct { + int quality; // 0-100, default 80 + int max_width; // 0 = no resize + int max_height; // 0 = no resize + bool preserve_aspect; +} ImageConvertOpts; + +// Video conversion options for HLS +typedef struct { + int segment_duration; // seconds, default 6 + int video_bitrate; // kbps, 0 = auto + int audio_bitrate; // kbps, 0 = 128 + int max_width; // 0 = no resize + int max_height; // 0 = no resize + bool generate_thumbnail; +} HlsConvertOpts; + +// Initialize default options +ImageConvertOpts ffmpeg_image_opts_default(void); +HlsConvertOpts ffmpeg_hls_opts_default(void); + +// Convert image to WebP format +// output_path should end with .webp +FfmpegResult ffmpeg_image_to_webp(const char* input_path, const char* output_path, ImageConvertOpts* opts); + +// Convert video to HLS format +// output_dir is the directory where .m3u8 and .ts files will be created +FfmpegResult ffmpeg_video_to_hls(const char* input_path, const char* output_dir, const char* name, HlsConvertOpts* opts); + +// Generate video thumbnail +FfmpegResult ffmpeg_video_thumbnail(const char* input_path, const char* output_path, int timestamp_seconds); + +// Get media duration in seconds (works for both audio and video) +FfmpegResult ffmpeg_get_duration(const char* input_path, double* duration_out); + +// Check if ffmpeg is available on the system +bool ffmpeg_is_available(void); + +// Get last error message +const char* ffmpeg_last_error(void); + +#endif // FFMPEG_CLI_H