|
217
|
1 #ifndef FFMPEG_CLI_H
|
|
|
2 #define FFMPEG_CLI_H
|
|
|
3
|
|
|
4 #include <stdbool.h>
|
|
|
5
|
|
|
6 // Result codes
|
|
|
7 typedef enum {
|
|
|
8 FFMPEG_OK = 0,
|
|
|
9 FFMPEG_ERR_INPUT_NOT_FOUND = 1,
|
|
|
10 FFMPEG_ERR_OUTPUT_FAILED = 2,
|
|
|
11 FFMPEG_ERR_INVALID_ARGS = 3,
|
|
|
12 FFMPEG_ERR_PROCESS_FAILED = 4,
|
|
|
13 } FfmpegResult;
|
|
|
14
|
|
|
15 // Image conversion options
|
|
|
16 typedef struct {
|
|
|
17 int quality; // 0-100, default 80
|
|
|
18 int max_width; // 0 = no resize
|
|
|
19 int max_height; // 0 = no resize
|
|
|
20 bool preserve_aspect;
|
|
|
21 } ImageConvertOpts;
|
|
|
22
|
|
|
23 // Video conversion options for HLS
|
|
|
24 typedef struct {
|
|
|
25 int segment_duration; // seconds, default 6
|
|
|
26 int video_bitrate; // kbps, 0 = auto
|
|
|
27 int audio_bitrate; // kbps, 0 = 128
|
|
|
28 int max_width; // 0 = no resize
|
|
|
29 int max_height; // 0 = no resize
|
|
|
30 bool generate_thumbnail;
|
|
|
31 } HlsConvertOpts;
|
|
|
32
|
|
|
33 // Initialize default options
|
|
|
34 ImageConvertOpts ffmpeg_image_opts_default(void);
|
|
|
35 HlsConvertOpts ffmpeg_hls_opts_default(void);
|
|
|
36
|
|
|
37 // Convert image to WebP format
|
|
|
38 // output_path should end with .webp
|
|
|
39 FfmpegResult ffmpeg_image_to_webp(const char* input_path, const char* output_path, ImageConvertOpts* opts);
|
|
|
40
|
|
|
41 // Convert video to HLS format
|
|
|
42 // output_dir is the directory where .m3u8 and .ts files will be created
|
|
|
43 FfmpegResult ffmpeg_video_to_hls(const char* input_path, const char* output_dir, const char* name, HlsConvertOpts* opts);
|
|
|
44
|
|
|
45 // Generate video thumbnail
|
|
|
46 FfmpegResult ffmpeg_video_thumbnail(const char* input_path, const char* output_path, int timestamp_seconds);
|
|
|
47
|
|
|
48 // Get media duration in seconds (works for both audio and video)
|
|
|
49 FfmpegResult ffmpeg_get_duration(const char* input_path, double* duration_out);
|
|
|
50
|
|
|
51 // Check if ffmpeg is available on the system
|
|
|
52 bool ffmpeg_is_available(void);
|
|
|
53
|
|
|
54 // Get last error message
|
|
|
55 const char* ffmpeg_last_error(void);
|
|
|
56
|
|
|
57 #endif // FFMPEG_CLI_H
|