mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-06 16:10:42 +08:00
添加视频压缩代码
This commit is contained in:
65
others/C/video_compression/include/config.h
Normal file
65
others/C/video_compression/include/config.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* 加载配置文件
|
||||
* @param config_file 配置文件路径
|
||||
* @return true表示成功,false表示失败
|
||||
*/
|
||||
bool config_load(const char* config_file);
|
||||
|
||||
/**
|
||||
* 保存配置文件
|
||||
* @param config_file 配置文件路径
|
||||
* @return true表示成功,false表示失败
|
||||
*/
|
||||
bool config_save(const char* config_file);
|
||||
|
||||
/**
|
||||
* 获取字符串配置值
|
||||
* @param key 配置键
|
||||
* @param default_value 默认值
|
||||
* @return 配置值
|
||||
*/
|
||||
const char* config_get_string(const char* key, const char* default_value);
|
||||
|
||||
/**
|
||||
* 获取整数配置值
|
||||
* @param key 配置键
|
||||
* @param default_value 默认值
|
||||
* @return 配置值
|
||||
*/
|
||||
int config_get_int(const char* key, int default_value);
|
||||
|
||||
/**
|
||||
* 获取布尔配置值
|
||||
* @param key 配置键
|
||||
* @param default_value 默认值
|
||||
* @return 配置值
|
||||
*/
|
||||
bool config_get_bool(const char* key, bool default_value);
|
||||
|
||||
/**
|
||||
* 设置字符串配置值
|
||||
* @param key 配置键
|
||||
* @param value 配置值
|
||||
*/
|
||||
void config_set_string(const char* key, const char* value);
|
||||
|
||||
/**
|
||||
* 设置整数配置值
|
||||
* @param key 配置键
|
||||
* @param value 配置值
|
||||
*/
|
||||
void config_set_int(const char* key, int value);
|
||||
|
||||
/**
|
||||
* 设置布尔配置值
|
||||
* @param key 配置键
|
||||
* @param value 配置值
|
||||
*/
|
||||
void config_set_bool(const char* key, bool value);
|
||||
|
||||
#endif // CONFIG_H
|
||||
37
others/C/video_compression/include/error.h
Normal file
37
others/C/video_compression/include/error.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef ERROR_H
|
||||
#define ERROR_H
|
||||
|
||||
typedef enum {
|
||||
ERR_NONE = 0,
|
||||
ERR_FILE_NOT_FOUND,
|
||||
ERR_INVALID_ARGUMENT,
|
||||
ERR_MEMORY_ALLOC,
|
||||
ERR_FFMPEG,
|
||||
ERR_UNKNOWN
|
||||
} ErrorCode;
|
||||
|
||||
/**
|
||||
* 设置当前错误代码
|
||||
* @param code 错误代码
|
||||
* @param message 错误信息(可选)
|
||||
*/
|
||||
void error_set(ErrorCode code, const char* message);
|
||||
|
||||
/**
|
||||
* 获取当前错误代码
|
||||
* @return 错误代码
|
||||
*/
|
||||
ErrorCode error_get_code();
|
||||
|
||||
/**
|
||||
* 获取当前错误信息
|
||||
* @return 错误信息字符串
|
||||
*/
|
||||
const char* error_get_message();
|
||||
|
||||
/**
|
||||
* 清除错误状态
|
||||
*/
|
||||
void error_clear();
|
||||
|
||||
#endif // ERROR_H
|
||||
27
others/C/video_compression/include/file_utils.h
Normal file
27
others/C/video_compression/include/file_utils.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef FILE_UTILS_H
|
||||
#define FILE_UTILS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* 检查文件是否存在
|
||||
* @param path 文件路径
|
||||
* @return true表示存在,false表示不存在
|
||||
*/
|
||||
bool file_exists(const char* path);
|
||||
|
||||
/**
|
||||
* 获取文件大小
|
||||
* @param path 文件路径
|
||||
* @return 文件大小(字节),-1表示错误
|
||||
*/
|
||||
long file_size(const char* path);
|
||||
|
||||
/**
|
||||
* 获取文件扩展名
|
||||
* @param path 文件路径
|
||||
* @return 扩展名字符串(包含.),NULL表示没有扩展名
|
||||
*/
|
||||
const char* file_extension(const char* path);
|
||||
|
||||
#endif // FILE_UTILS_H
|
||||
16
others/C/video_compression/include/gui.h
Normal file
16
others/C/video_compression/include/gui.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef GUI_H
|
||||
#define GUI_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// 初始化GUI界面
|
||||
BOOL init_gui(HINSTANCE hInstance);
|
||||
|
||||
// 主窗口过程函数
|
||||
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
|
||||
// 创建压缩参数设置控件
|
||||
void create_compression_controls(HWND hwnd);
|
||||
|
||||
#endif // GUI_H
|
||||
38
others/C/video_compression/include/logger.h
Normal file
38
others/C/video_compression/include/logger.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum {
|
||||
LOG_DEBUG,
|
||||
LOG_INFO,
|
||||
LOG_WARNING,
|
||||
LOG_ERROR
|
||||
} LogLevel;
|
||||
|
||||
/**
|
||||
* 初始化日志系统
|
||||
* @param log_file 日志文件路径,NULL表示输出到stdout
|
||||
*/
|
||||
void logger_init(const char* log_file);
|
||||
|
||||
/**
|
||||
* 设置日志级别
|
||||
* @param level 日志级别
|
||||
*/
|
||||
void logger_set_level(LogLevel level);
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
* @param level 日志级别
|
||||
* @param format 格式化字符串
|
||||
* @param ... 可变参数
|
||||
*/
|
||||
void logger_log(LogLevel level, const char* format, ...);
|
||||
|
||||
/**
|
||||
* 关闭日志系统
|
||||
*/
|
||||
void logger_close();
|
||||
|
||||
#endif // LOGGER_H
|
||||
21
others/C/video_compression/include/progress.h
Normal file
21
others/C/video_compression/include/progress.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef PROGRESS_H
|
||||
#define PROGRESS_H
|
||||
|
||||
/**
|
||||
* 初始化进度显示
|
||||
* @param total 总工作量
|
||||
*/
|
||||
void progress_init(long total);
|
||||
|
||||
/**
|
||||
* 更新进度
|
||||
* @param current 当前进度
|
||||
*/
|
||||
void progress_update(long current);
|
||||
|
||||
/**
|
||||
* 完成进度显示
|
||||
*/
|
||||
void progress_finish();
|
||||
|
||||
#endif // PROGRESS_H
|
||||
61
others/C/video_compression/include/string_utils.h
Normal file
61
others/C/video_compression/include/string_utils.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef STRING_UTILS_H
|
||||
#define STRING_UTILS_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* 安全的字符串拷贝
|
||||
* @param dest 目标缓冲区
|
||||
* @param src 源字符串
|
||||
* @param dest_size 目标缓冲区大小
|
||||
* @return 目标字符串
|
||||
*/
|
||||
char* str_copy(char* dest, const char* src, size_t dest_size);
|
||||
|
||||
/**
|
||||
* 安全的字符串连接
|
||||
* @param dest 目标缓冲区
|
||||
* @param src 要连接的字符串
|
||||
* @param dest_size 目标缓冲区大小
|
||||
* @return 目标字符串
|
||||
*/
|
||||
char* str_concat(char* dest, const char* src, size_t dest_size);
|
||||
|
||||
/**
|
||||
* 去除字符串两端的空白字符
|
||||
* @param str 要处理的字符串
|
||||
* @return 处理后的字符串
|
||||
*/
|
||||
char* str_trim(char* str);
|
||||
|
||||
/**
|
||||
* 检查字符串是否以指定前缀开头
|
||||
* @param str 要检查的字符串
|
||||
* @param prefix 前缀
|
||||
* @return 1表示是,0表示否
|
||||
*/
|
||||
int str_starts_with(const char* str, const char* prefix);
|
||||
|
||||
/**
|
||||
* 检查字符串是否以指定后缀结尾
|
||||
* @param str 要检查的字符串
|
||||
* @param suffix 后缀
|
||||
* @return 1表示是,0表示否
|
||||
*/
|
||||
int str_ends_with(const char* str, const char* suffix);
|
||||
|
||||
/**
|
||||
* 将字符串转换为小写
|
||||
* @param str 要转换的字符串
|
||||
* @return 转换后的字符串
|
||||
*/
|
||||
char* str_to_lower(char* str);
|
||||
|
||||
/**
|
||||
* 将字符串转换为大写
|
||||
* @param str 要转换的字符串
|
||||
* @return 转换后的字符串
|
||||
*/
|
||||
char* str_to_upper(char* str);
|
||||
|
||||
#endif // STRING_UTILS_H
|
||||
26
others/C/video_compression/include/utils.h
Normal file
26
others/C/video_compression/include/utils.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* 获取当前时间戳(毫秒)
|
||||
* @return 时间戳
|
||||
*/
|
||||
long long get_timestamp();
|
||||
|
||||
/**
|
||||
* 生成随机字符串
|
||||
* @param buffer 输出缓冲区
|
||||
* @param length 字符串长度
|
||||
*/
|
||||
void generate_random_string(char* buffer, int length);
|
||||
|
||||
/**
|
||||
* 检查指针是否有效
|
||||
* @param ptr 要检查的指针
|
||||
* @return true表示有效,false表示无效
|
||||
*/
|
||||
bool is_pointer_valid(const void* ptr);
|
||||
|
||||
#endif // UTILS_H
|
||||
24
others/C/video_compression/include/video_compressor.h
Normal file
24
others/C/video_compression/include/video_compressor.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef VIDEO_COMPRESSOR_H
|
||||
#define VIDEO_COMPRESSOR_H
|
||||
|
||||
/**
|
||||
* 压缩视频文件
|
||||
* @param input_file 输入文件路径
|
||||
* @param output_file 输出文件路径
|
||||
* @param quality 压缩质量(1-10000)
|
||||
* @return 0表示成功,非0表示失败
|
||||
*/
|
||||
int compress_video(const char* input_file, const char* output_file, int quality);
|
||||
|
||||
/**
|
||||
* 初始化视频压缩模块
|
||||
* @return 0表示成功,非0表示失败
|
||||
*/
|
||||
int init_video_compressor();
|
||||
|
||||
/**
|
||||
* 清理视频压缩模块资源
|
||||
*/
|
||||
void cleanup_video_compressor();
|
||||
|
||||
#endif // VIDEO_COMPRESSOR_H
|
||||
Reference in New Issue
Block a user