參考鏈接
- Ubuntu 20.04 搭建 CLion FFmpeg 開發環境_TYYJ-洪偉的博客-CSDN博客
安裝CLion
- 首先到 jetbrains 官網 https://www.jetbrains.com/clion/ 下載 CLion 安裝包 CLion-2021.1.tar.gz
- 使用finalshell和ubuntu之間配置ssh鏈接
- 將Clion-2022.1.tar.gz 使用move移動到 /home/chy-cpabe路徑下
- 使用命令 tar -xvzf?Clion-2022.1.tar.gz 進行解壓
- cd clion-2022.1
- cd bin
- sudo ./clion.sh 啟動clion
- 激活
- 創建項目 選擇/home/chy-cpabe/CLionProjects/learn_ffmpeg這個路徑,即項目的名字叫做learn_ffmpeg
二、運行使用 FFmpeg lib 的 Demo
- 音視頻處理 ffmpeg下載、編譯和安裝_MY CUP OF TEA的博客-CSDN博客
- 參考上面鏈接 創建環境?ffmpeg_build?ffmpeg_source 等
- 編譯好的 FFmpeg 庫位于 ffmpeg_build 目錄下
cmake
- 與參考鏈接相比
- 刪除了 uuid 和?vdpau
- 配置文件中的引入庫順序也至關重要,如果庫引入順序顛倒,可能導致編譯無法通過。要注意編譯依賴先后順序
cmake_minimum_required(VERSION 3.22)
set(PROJECT_NAME learn_ffmpeg)
project(${PROJECT_NAME})set(CMAKE_CXX_STANDARD 11)include_directories(/home/chy-cpabe/ffmpeg_build/include)
link_directories(/home/chy-cpabe/ffmpeg_build/lib)add_executable(${PROJECT_NAME} main.cpp)#libavcodec
target_link_libraries(${PROJECT_NAME} vpx m pthread vpx m dav1d dl z fdk-aac mp3lame opus vorbis ogg vorbisenc vorbisx264 x265 stdc++ gcc_s gcc rt numa va)
#libavdevice
target_link_libraries(${PROJECT_NAME} m xcb Xau Xdmcp xcb-shm xcb-shape xcb-xfixes xcb-render asound dl pthread rt SDL2pulse-simple pulse X11 Xext Xcursor Xinerama Xi Xrandr Xss Xxf86vm wayland-egl wayland-client wayland-cursorxkbcommon sndio Xv)
#libavfilter
target_link_libraries(${PROJECT_NAME} pthread m ass harfbuzz glib-2.0 pcre graphite2 fontconfig expat fribidifreetype png16 z va)
#libavformat
target_link_libraries(${PROJECT_NAME} m z gnutls pthread gmp unistring idn2 atomic hogweed nettle tasn1 p11-kit)
#libavutil
target_link_libraries(${PROJECT_NAME} pthread va-drm va va-x11 X11 m Xv X11 Xext)
#libdav1d
target_link_libraries(${PROJECT_NAME} pthread dl)
#libpostproc
target_link_libraries(${PROJECT_NAME} m)
#libSvtAv1Enc
target_link_libraries(${PROJECT_NAME} pthread m)
#libswresample
target_link_libraries(${PROJECT_NAME} m)
#libswscale
target_link_libraries(${PROJECT_NAME} m)target_link_libraries(${PROJECT_NAME}avcodecavdeviceavfilteravformatavutildav1dpostprocSvtAv1Encswresampleswscale
)
源代碼
#include <iostream>extern "C" {
#include<libavutil/avutil.h>
#include<libavcodec/avcodec.h>
#include<libavformat/avformat.h>
#include<libavdevice/avdevice.h>
#include<libavfilter/avfilter.h>
#include<libswscale/swscale.h>
#include<libswresample/swresample.h>
#include<libpostproc/postprocess.h>
}void getVersion(unsigned version, char *lib_name) {unsigned major = AV_VERSION_MAJOR(version);unsigned minor = AV_VERSION_MINOR(version);unsigned micro = AV_VERSION_MICRO(version);printf("%s %d.%d.%d\n", lib_name, major, minor, micro);
}int main() {std::cout << "config: " << avutil_configuration() << std::endl;char avutil[] = "avutil";getVersion(avutil_version(), avutil);char avcodec[] = "avcodec";getVersion(avcodec_version(), avcodec);char avformat[] = "avformat";getVersion(avformat_version(), avformat);char avdevice[] = "avdevice";getVersion(avdevice_version(), avdevice);char avfilter[] = "avfilter";getVersion(avfilter_version(), avfilter);char swscale[] = "swscale";getVersion(swscale_version(), swscale);char swresample[] = "swresample";getVersion(swresample_version(), swresample);char postproc[] = "postproc";getVersion(postproc_version(), postproc);return 0;
}
編譯

輸出?
