Add fdk-aac

This commit is contained in:
Fancy code 2024-06-24 21:27:54 +08:00
commit 3644358597
22 changed files with 99 additions and 29 deletions

View File

@ -164,6 +164,9 @@ set(MAIN_SRC_FILE "" CACHE STRING INTERNAL)
unset(MAIN_LINK_LIB CACHE)
set(MAIN_LINK_LIB "" CACHE STRING INTERNAL)
unset(EXTERNAL_LIBS_PATH CACHE)
set(EXTERNAL_LIBS_PATH "" CACHE STRING INTERNAL)
# Config message for test code.
unset(TEST_LINK_LIB CACHE)
set(TEST_LINK_LIB "" CACHE STRING INTERNAL)

View File

@ -10,8 +10,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig/lib
${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg/lib
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES)

3
external/.gitignore vendored
View File

@ -1,3 +1,4 @@
goahead-5.2.0/GoAhead
ffmpeg/ffmpeg-6.1.1
ffmpeg/ffmpeg-6.1.1
fdk-aac/fdk-aac-2.0.3

View File

@ -22,5 +22,8 @@ add_subdirectory(goahead-5.2.0)
add_subdirectory(cJSON-1.7.17)
add_subdirectory(libhv/libhv-1.3.2)
# ================= ffmpeg related ================= #
add_subdirectory(ffmpeg)
add_subdirectory(fdk-aac)
# ================= ffmpeg related end ================= #
add_subdirectory(libconfig)

26
external/fdk-aac/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,26 @@
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
set(FDK_AAC_INSTALL_PATH "${EXTERNAL_LIBS_OUTPUT_PATH}/fdk-aac")
set(EXTERNAL_LIBS_PATH "${EXTERNAL_LIBS_PATH};${FDK_AAC_INSTALL_PATH}/lib" CACHE STRING INTERNAL FORCE)
message("Compile fdk-aac cmake config files : ${PLATFORM_PATH}/build/cmake/toolchain/linux.toolchain.cmake")
add_custom_target(
fdk_aac
COMMAND echo "Now compile fdk-aac, please wait..."
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/fdk-aac/fdk-aac-2.0.3/CMakeLists.txt || tar -xf fdk-aac-2.0.3.tar.gz
COMMAND chmod 777 -R fdk-aac-2.0.3
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/fdk-aac/fdk-aac-2.0.3/build/Makefile || mkdir fdk-aac-2.0.3/build
COMMAND cd fdk-aac-2.0.3/build && cmake ../ -DCMAKE_TOOLCHAIN_FILE=${PLATFORM_PATH}/build/cmake/toolchain/linux.toolchain.cmake
-DCMAKE_INSTALL_PREFIX=${FDK_AAC_INSTALL_PATH} -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
COMMAND cd fdk-aac-2.0.3/build && make
COMMAND cd fdk-aac-2.0.3/build && make install
COMMAND cd fdk-aac-2.0.3/build && make clean
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/fdk-aac/
)
add_custom_target(
remove_fdk-aac_source_files
COMMAND rm -rf fdk-aac-2.0.3
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/fdk-aac/
)
# cleanclean_script
add_dependencies(sdk_clean remove_fdk-aac_source_files)

BIN
external/fdk-aac/fdk-aac-2.0.3.tar.gz vendored Executable file

Binary file not shown.

View File

@ -1,22 +1,31 @@
set(FFMPEG_INSTALL_PATH "${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg")
set(EXTERNAL_LIBS_PATH "${EXTERNAL_LIBS_PATH};${FFMPEG_INSTALL_PATH}/lib" CACHE STRING INTERNAL FORCE)
find_program(NASM nasm)
if(NOT NASM)
message("nasm not found. Now install.")
execute_process(COMMAND sudo apt install nasm WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/)
endif()
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
set(CONFIGURE_COMMAND "--enable-cross-compile --target-os=linux --arch=linux \
set(CONFIGURE_COMMAND "--enable-cross-compile --target-os=linux --arch=x86_64 \
--cc=${CMAKE_C_COMPILER} \
--cxx=${CMAKE_CXX_COMPILER} \
--prefix=${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg \
--enable-parsers --enable-decoder=h264 \
--prefix=${FFMPEG_INSTALL_PATH} \
--enable-parsers --enable-decoder=h264 --enable-libfdk-aac \
--enable-ffmpeg --enable-static \
--enable-gpl --enable-nonfree --enable-version3 --enable-small \
--enable-muxer=mov --enable-muxer=mp4 \
--enable-decoder=aac --enable-decoder=pcm_alaw --enable-encoder=pcm_alaw \
--enable-demuxer=mov \
--enable-protocol=file --enable-bsf=aac_adtstoasc --enable-bsf=h264_mp4toannexb --enable-bsf=hevc_mp4toannexb")
--enable-protocol=file --enable-bsf=aac_adtstoasc --enable-bsf=h264_mp4toannexb --enable-bsf=hevc_mp4toannexb \
--extra-libs=-lm \
--extra-cflags=\"-I${EXTERNAL_LIBS_OUTPUT_PATH}/fdk-aac/include\" \
--extra-ldflags=\"-L${EXTERNAL_LIBS_OUTPUT_PATH}/fdk-aac/lib\"")
else()
set(CONFIGURE_COMMAND "--enable-cross-compile --target-os=linux --arch=arm64 \
--cc=${CMAKE_C_COMPILER} \
--cxx=${CMAKE_CXX_COMPILER} \
--prefix=${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg \
--disable-asm --enable-parsers --disable-decoders --enable-decoder=h264 \
--prefix=${FFMPEG_INSTALL_PATH} \
--disable-asm --enable-parsers --disable-decoders --enable-decoder=h264 --enable-libfdk-aac \
--disable-debug --enable-ffmpeg --enable-shared --enable-static --disable-stripping --disable-doc \
--enable-gpl --enable-nonfree --enable-version3 --enable-small \
--disable-mipsdsp --disable-mipsdspr2 \
@ -29,13 +38,17 @@ else()
--disable-protocols --enable-protocol=file \
--disable-bsfs --enable-bsf=aac_adtstoasc --enable-bsf=h264_mp4toannexb --enable-bsf=hevc_mp4toannexb \
--disable-indevs \
--disable-outdevs --disable-ffprobe --disable-ffmpeg --disable-ffplay --disable-debug")
--disable-outdevs --disable-ffprobe --disable-ffmpeg --disable-ffplay --disable-debug \
--extra-libs=-lm \
--extra-cflags=\"-I${EXTERNAL_LIBS_OUTPUT_PATH}/fdk-aac/include\" \
--extra-ldflags=\"-L${EXTERNAL_LIBS_OUTPUT_PATH}/fdk-aac/lib\"")
endif()
message("Compile ffmpeg comand : ${CONFIGURE_COMMAND}")
add_custom_target(
ffmpeg
DEPENDS fdk_aac
COMMAND echo "Now compile ffmpeg, please wait..."
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/ffmpeg/Makefile || tar -xf ffmpeg_6.1.1.orig.tar.xz
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/ffmpeg/ffmpeg-6.1.1/Makefile || tar -xf ffmpeg_6.1.1.orig.tar.xz
COMMAND chmod 777 -R ffmpeg-6.1.1
COMMAND cd ffmpeg-6.1.1 && bash -c "./configure ${CONFIGURE_COMMAND}"
COMMAND cd ffmpeg-6.1.1 && make

View File

@ -15,6 +15,20 @@ ffmpeg -i input.g711a -acodec alaw output.wav
$ ffplay video.h264
```
* g711a音频文件转wav音频文件
```code
$ fmpeg -f mulaw -ar 8000 -i audio.g711a audio.wav
```
* 将h264和wav文件合成mp4文件
**注意未发现可以将h264和g711a文件合成mp4文件**
```code
$ ffmpeg -i video.h264 -i audio.wav -c:v copy -c:a aac -b:a 96k test.mp4
```
## 1.2. 问题记录
### 1.2.1. avformat_open_input 执行失败

View File

@ -5,6 +5,7 @@ else()
set(CONFIGURE_COMMAND "--host=${COMPILE_HOST} --disable-cxx --enable-static=yes --prefix=${LIBCONFIG_INSTALL_PATH}")
endif()
message("Compile libconfig comand : ${CONFIGURE_COMMAND}")
set(EXTERNAL_LIBS_PATH "${EXTERNAL_LIBS_PATH};${LIBCONFIG_INSTALL_PATH}/lib" CACHE STRING INTERNAL FORCE)
add_custom_target(
libconfig
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/libconfig-1.7.3/Makefile || tar zxvf libconfig-1.7.3.tar.gz

View File

@ -34,6 +34,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_LINUX_MOCK}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TEST_LINUX_MOCK}")
add_definitions(-DTEST_SOURCE_PATH="${TEST_SOURCE_PATH}")
set(EXTERNAL_LIBS_PATH "${EXTERNAL_LIBS_PATH};${TEST_TOOLS_OUTPUT_PATH}" CACHE STRING INTERNAL FORCE)
add_subdirectory(all)
add_subdirectory(application)
add_subdirectory(middleware)

View File

@ -16,7 +16,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig/lib
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES)

View File

@ -33,9 +33,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig/lib
${TEST_TOOLS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg/lib
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES_MAIN)

View File

@ -52,4 +52,18 @@ TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_EXAMPLE_MediaTask)
HalTestTool::MockKeyClick("reset", 200); // Simulate pressing a button.
MainThread::GetInstance()->Runing();
}
// ../output_files/test/bin/HuntingCameraTest
// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_EXAMPLE_MediaTask_No_sdcard
TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_EXAMPLE_MediaTask_No_sdcard)
{
McuManagerTestTool::MockOtherSideIpcMissionReply(IpcMission::TEST);
SetAllCamerasResult(mAllCamerasMock);
MockSdCardRemove(mLinuxTest);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
MainThread::GetInstance()->Init();
TestManager::ResetTimeOut(1000 * 15);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
HalTestTool::MockKeyClick("reset", 200); // Simulate pressing a button.
MainThread::GetInstance()->Runing();
}
} // namespace MediaManager_Mock_Test

View File

@ -12,8 +12,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${TEST_TOOLS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg/lib
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES)

View File

@ -25,8 +25,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${TEST_TOOLS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg/lib
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES_MAIN)

View File

@ -23,8 +23,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${TEST_TOOLS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg/lib
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES_MAIN)

View File

@ -23,8 +23,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig/lib
${TEST_TOOLS_OUTPUT_PATH}
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES_MAIN)

View File

@ -24,8 +24,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${TEST_TOOLS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg/lib
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES_MAIN)

View File

@ -15,7 +15,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig/lib
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES)

View File

@ -15,7 +15,7 @@ include_directories(
link_directories(
${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg/lib
${EXTERNAL_LIBS_PATH}
)
aux_source_directory(. SRC_FILES)

View File

@ -1,4 +1,5 @@
all:
@sudo add-apt-repository --remove ppa:george-edison55/cmake-3.x
@sudo apt-get update
@sudo apt-get install openssl
@sudo apt-get install libssl-dev

View File

@ -21,9 +21,9 @@ set(TARGET_NAME MediaBase)
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
target_link_libraries(${TARGET_NAME} avformat avcodec avutil swresample avdevice avfilter swscale postproc z StatusCode Log)
target_link_libraries(${TARGET_NAME} avformat avcodec avutil swresample avdevice avfilter swscale postproc fdk-aac z StatusCode Log)
else()
target_link_libraries(${TARGET_NAME} avformat avcodec avutil swresample avdevice avfilter swscale postproc StatusCode Log)
target_link_libraries(${TARGET_NAME} avformat avcodec avutil swresample avdevice avfilter swscale postproc fdk-aac StatusCode Log)
endif()
add_custom_target(