参考链接
- 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;
}
编译
输出