Linux主板上如何编译rkmedia
介绍
rkmedia是Rockchip Linux平台的多媒体库,封装了底层媒体模块接口,提供常用多媒体解决方案。rkmedia支持视频输入、视频输出、视频编解码、音频输入输出、音频编解码、图像处理等功能。
为了在Rockchip Linux主板上编译rkmedia,你需要先下载rkmedia的源代码,并配置好交叉编译器和相关依赖。具体步骤如下:
编译
拷贝源码
cp -rf SDK/external/rkmedia /home/neardi/
安装编译环境
sudo apt install libv4l-dev libasound2-dev build-essential cmake
编译easymedia
由于easymedia被rkmedia所依赖,所以需要编译rkmedia,先编译easymedia.
cd /home/neardi/rkmedia
cmake ./
neardi@LPA3399PRO:~/rkmedia$ cmake ./
-- cmake version 3.16.3
CMake Deprecation Warning at CMakeLists.txt:11 (cmake_policy):
The OLD behavior for policy CMP0025 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
CMake Deprecation Warning at CMakeLists.txt:12 (cmake_policy):
The OLD behavior for policy CMP0042 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/neardi/rkmedia
安装easymedia
sudo make install
neardi@LPA3399PRO:~/rkmedia$ sudo make install
[sudo] password for neardi:
[100%] Built target easymedia
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/local/lib/libeasymedia.so.1.0.1
-- Up-to-date: /usr/local/lib/libeasymedia.so.1
-- Up-to-date: /usr/local/lib/libeasymedia.so
-- Up-to-date: /usr/local/include/easymedia/buffer.h
-- Up-to-date: /usr/local/include/easymedia/codec.h
-- Up-to-date: /usr/local/include/easymedia/control.h
-- Up-to-date: /usr/local/include/easymedia/decoder.h
-- Up-to-date: /usr/local/include/easymedia/demuxer.h
-- Up-to-date: /usr/local/include/easymedia/encoder.h
-- Up-to-date: /usr/local/include/easymedia/filter.h
-- Up-to-date: /usr/local/include/easymedia/flow.h
-- Up-to-date: /usr/local/include/easymedia/image.h
-- Up-to-date: /usr/local/include/easymedia/key_string.h
-- Up-to-date: /usr/local/include/easymedia/link_config.h
-- Up-to-date: /usr/local/include/easymedia/lock.h
-- Up-to-date: /usr/local/include/easymedia/media_config.h
-- Up-to-date: /usr/local/include/easymedia/media_reflector.h
-- Up-to-date: /usr/local/include/easymedia/media_type.h
-- Up-to-date: /usr/local/include/easymedia/message.h
-- Up-to-date: /usr/local/include/easymedia/message_type.h
-- Up-to-date: /usr/local/include/easymedia/muxer.h
-- Up-to-date: /usr/local/include/easymedia/reflector.h
-- Up-to-date: /usr/local/include/easymedia/rga_filter.h
-- Up-to-date: /usr/local/include/easymedia/rknn_user.h
-- Up-to-date: /usr/local/include/easymedia/rknn_utils.h
-- Up-to-date: /usr/local/include/easymedia/sound.h
-- Up-to-date: /usr/local/include/easymedia/stream.h
-- Up-to-date: /usr/local/include/easymedia/utils.h
-- Up-to-date: /usr/local/lib/pkgconfig/libeasymedia.pc
修改引入文件
neardi@LPA3399PRO:~/rkmedia/examples$ git diff .
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f133c01..d9a442d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -489,6 +489,8 @@ endif() #if(DRM_DISPLAY)
# rkmedia_muxer_test
#--------------------------
add_executable(rkmedia_muxer_test rkmedia_muxer_test.c ${COMMON_SRC})
+include_directories(../include/easymedia)
+include_directories(../include/rkmedia)
add_dependencies(rkmedia_muxer_test easymedia)
target_link_libraries(rkmedia_muxer_test easymedia)
target_include_directories(rkmedia_muxer_test PRIVATE ${CMAKE_SOURCE_DIR}/include)
编译rkmedia
make -j16
neardi@LPA3399PRO:~/rkmedia/examples$ make -j16
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.16)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
CMake Warning (dev) at CMakeLists.txt:494 (add_dependencies):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
The dependency target "easymedia" of target "rkmedia_muxer_test" does not
exist.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: /home/neardi/rkmedia/examples
Scanning dependencies of target rkmedia_muxer_test
[ 50%] Building C object CMakeFiles/rkmedia_muxer_test.dir/common/sample_common_isp.o
[ 50%] Building C object CMakeFiles/rkmedia_muxer_test.dir/common/sample_fake_isp.o
[ 75%] Building C object CMakeFiles/rkmedia_muxer_test.dir/rkmedia_muxer_test.o
[100%] Linking C executable rkmedia_muxer_test
[100%] Built target rkmedia_muxer_test