以下是一段使用 ffmpeg 库解析 RTSP 流并转码为 H264 的 C 代码示例:
``` #include <libavformat/avformat.h> #include <libavcodec/avcodec.h> #include <libavutil/avutil.h>
int main(int argc, char *argv[]) { // 初始化 libav av_register_all(); avformat_network_init();
// 创建输入上下文
AVFormatContext *input_ctx = NULL;
avformat_open_input(&input_ctx, "rtsp://...", NULL, NULL);
avformat_find_stream_info(input_ctx, NULL);
// 创建输出上下文
AVFormatContext *output_ctx = NULL;
avformat_alloc_output_context2(&