一、準(zhǔn)備工作
在視頻處理和多媒體應(yīng)用程序開發(fā)中,F(xiàn)Fmpeg 是一個強(qiáng)大的開源工具,它提供了處理音頻和視頻的豐富功能。CLion 是一款受歡迎的跨平臺集成開發(fā)環(huán)境(IDE),它提供了強(qiáng)大的代碼編輯和調(diào)試工具。
本文章介紹在CLion下配置FFmpeg開發(fā)環(huán)境的方法。
1. 準(zhǔn)備環(huán)境
- windows10
- 已安裝Clion
2. 下載FFmpeg
官網(wǎng)入口:
找 Windows builds by BtbN,跳轉(zhuǎn)到:
https://github.com/BtbN/FFmpeg-Builds/releases
選擇合適的版本下載 。 我這里下載的是 ffmpeg-n4.4.4-6-gd5fa6e3a91-win64-gpl-shared-4.4 。
二、操作步驟
1. Clion 新建一個C項目
2. 修改 CMakeLists.txt
cmake_minimum_required(VERSION 3.24)
project(ffmpeg_learn1 C)
set(CMAKE_C_STANDARD 11)
include_directories(E:/Downloads/ffmpeg-master-latest-win64-gpl-shared/include)
link_directories(E:/Downloads/ffmpeg-master-latest-win64-gpl-shared/lib)
add_executable(ffmpeg_learn1 main.c)
target_link_libraries(
ffmpeg_learn1
avcodec
avdevice
avfilter
avformat
avutil
postproc
swresample
swscale
)
3. 修改配置
點擊 Edit Configurations:
設(shè)置環(huán)境變量:
path=E:/Downloads/ffmpeg-master-latest-win64-gpl-shared/bin
4. 運行測試
main.c輸入內(nèi)容 :
#include "libavformat/avformat.h"
int main() {
av_log_set_level(AV_LOG_INFO);
av_log(NULL, AV_LOG_INFO, "avformat_configurations: \n %s", avformat_configuration());
return 0;
}
點擊運行:
5. 打印rtsp 流信息的 demo
#include <stdio.h>
#include <libavformat/avformat.h>
int main(int argc, char *argv[]) {
// 初始化 FFmpeg
av_register_all();
// 打開 RTSP 流
AVFormatContext *formatContext = NULL;
if (avformat_open_input(&formatContext, "rtsp://地址信息", NULL, NULL) != 0) {
fprintf(stderr, "無法打開 RTSP 流\n");
return 1;
}
// 獲取流信息
if (avformat_find_stream_info(formatContext, NULL) < 0) {
fprintf(stderr, "無法獲取流信息\n");
return 1;
}
// 打印流信息
av_dump_format(formatContext, 0, "rtsp://地址信息", 0);
// 關(guān)閉 RTSP 流
avformat_close_input(&formatContext);
return 0;
}
文章來源:http://www.zghlxwxcb.cn/news/detail-695797.html
通過官方文檔 : https://www.ffmpeg.org/documentation.html 可以查看更多FFmpeg的操作方法。文章來源地址http://www.zghlxwxcb.cn/news/detail-695797.html
到了這里,關(guān)于Clion 使用ffmpeg 學(xué)習(xí)1 開發(fā)環(huán)境配置的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!