Ubuntu 16.04 上,已通过 源码安装 ffmpeg-4.3.1,在此基础上尝试单独编译 ffplay.c。当前工作目录如下:
.
├── CMakeLists.txt
├── cmdutils.c
├── cmdutils.h
└── ffplay.c
CMakeLists.txt 文件内容如下,其余三个文件均来自源码 ffmpeg-4.3.1/fftools/ 文件夹下。
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(myplay)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
# FFmpeg source
set(MY_LIBRARY ~/ffmpeg-4.3.1)
include_directories(${MY_LIBRARY})
# config.h
set(MY_BUILD_LIBRARY ~/ffmpeg-4.3.1/build)
include_directories(${MY_BUILD_LIBRARY})
# gdb
set(CMAKE_C_FLAGS "-g")
aux_source_directory(. DIR_SRCS)
add_executable(myplay ${DIR_SRCS})
target_link_libraries(myplay
-lavcodec
-lavdevice
-lavfilter
-lavformat
-lavutil
-lswresample
-lswscale
-lm
-lSDL2
)
set_property(TARGET myplay PROPERTY CXX_STANDARD 11)
在当前目录执行
mkdir build && cd build
cmake ..
make
然后会生成可执行文件 myplay,测试
./myplay -version
尝试使用 gdb 调试
gdb ./myplay
(gdb) b upload_texture
(gdb) b 1250
(gdb) run ../videos/fpx.gif
(gdb) s
(gdb) p frame->format
(gdb) p frame->linesize[0]
(gdb) c
(gdb) quit
现在可以修改代码并编译调试了👴