Skip to content

Commit

Permalink
test win ci
Browse files Browse the repository at this point in the history
  • Loading branch information
taoboyang committed Apr 1, 2024
1 parent 64f5257 commit 125d82a
Show file tree
Hide file tree
Showing 10 changed files with 456 additions and 19 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,85 @@ jobs:
# test hmp
(cd bmf/hml/tests/data && ./gen.sh $(pwd)/../../../../output/files)
(cd bmf/hml/tests && pytest)
build_and_test_win:
name: build and test win
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: build_test
shell: pwsh
run: |
$bashPath = "C:\msys64\usr\bin\bash.exe"
$bashCommand = @'
export PATH=/usr/bin:/usr/lib:/usr/local/bin:/usr/local/lib:$PATH
python
exit()
python3
exit()
echo $PATH
echo "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" | sed 's/[^0-9A-Za-z]/^&/g'
eval "$(./win_env/vcvarsall.sh x64)"
export INCLUDE="${INCLUDE};C:\\msys64\\usr\\local\\include"
wget https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-03-20-13-14/ffmpeg-n4.4.4-92-g01fc3034ee-win64-gpl-shared-4.4.zip
pacman -S unzip --noconfirm
unzip ffmpeg-n4.4.4-92-g01fc3034ee-win64-gpl-shared-4.4.zip
mkdir -p /usr/local
cp -r ffmpeg-n4.4.4-92-g01fc3034ee-win64-gpl-shared-4.4/* /usr/local/
ls /usr/lib
ls /usr/include
ls /usr/bin
cmake -version
./build_win_lite.sh --msvc=2022 --preset=x64-Release bmf_ffmpeg
cmake --build build_win_lite/x64-Release --config Release --target ALL_BUILD
cmake --build build_win_lite/x64-Release --config Release --target ALL_BUILD
cmake --build build_win_lite/x64-Release --config Release --target ALL_BUILD
cp -r build_win_lite/x64-Release/output .
python -m pip install timeout_decorator numpy onnxruntime pytest opencv-python
export PYTHONHOME="$(dirname "$(which python)")"
export C_INCLUDE_PATH=${C_INCLUDE_PATH}:$(pwd)/output/bmf/include
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:$(pwd)/output/bmf/include
export LIBRARY_PATH=${LIBRARY_PATH}:$(pwd)/output/bmf/lib
export PYTHONPATH=$(pwd)/output/bmf/lib:$(pwd)/output
export PATH=$(pwd)/3rd_party/win_rootfs/x64/usr/bin:$(pwd)/3rd_party/win_rootfs/x64/usr/lib:$(pwd)/output/bmf/bin:$(pwd)/output/bmf/lib:${PATH}
echo $PATH
echo $(pwd)
export HMP_TEST_DATA_ROOT=$(pwd)/bmf/hml/tests/data
run_bmf_graph
ffmpeg
module_manager
./output/bmf/bin/module_manager install python_copy_module python my_module:my_module $(pwd)/output/test/customize_module v0.0.1
./output/bmf/bin/module_manager install cpp_copy_module c++ copy_module:CopyModule $(pwd)/output/test/c_module/lib v0.0.1
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/files.tar.gz && tar xvf files.tar.gz && rm -rf files.tar.gz)
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/models.tar.gz && tar xvf models.tar.gz && rm -rf models.tar.gz)
cd output/bmf/bin
./test_bmf_module_sdk.exe
./test_bmf_engine.exe --gtest_filter=-go_module.module_loader
./test_cpp_builder.exe
cd -
export
ls output/bmf/lib
ls output/bmf/bin
which python
which python3
(cd output/demo/transcode && python test_transcode.py)
(cd output/demo/edit && python test_edit.py)
(cd output/demo/predict && python predict_sample.py)
(cd output/test/audio_copy && python test_simple.py)
(cd output/test/pre_module && python test_pre_module.py)
(cd output/test/sync_mode && python test_sync_mode.py)
(cd output/test/generator && python test_generator.py)
(cd output/test/run_by_config && python test_run_by_config.py)
(cd output/test/server && python test_server.py)
(cd output/test/c_module && python test_video_c_module.py)
(cd output/test/dynamical_graph && python dynamical_graph.py)
(cd output/test/av_log_buffer && python test_av_log_buffer.py)
(cd output/test/push_data_into_graph && python test_push_data.py)
(cd output/test/complex_edit_case && python test_complex_case.py)
(cd output/test/complex_edit_case && python test_compare_with_edit.py)
(cd bmf/hml/tests/data && ./gen.sh $(pwd)/../../../../output/files)
(cd bmf/hml/tests && python -m pytest)
'@
echo $bashCommand | & $bashPath
2 changes: 1 addition & 1 deletion bmf/sdk/cpp_sdk/include/bmf/sdk/audio_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace bmf_sdk {

struct AudioChannelLayout {
// ref: ffmpeg/channel_layout.h
enum Layout {
enum Layout : uint64_t {
kFRONT_LEFT = 0x00000001,
kFRONT_RIGHT = 0x00000002,
kFRONT_CENTER = 0x00000004,
Expand Down
2 changes: 1 addition & 1 deletion bmf/sdk/cpp_sdk/src/audio_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static int popcount_c(uint32_t x) {
}

static inline int popcount64_c(uint64_t x) {
return popcount_c(uint32_t(x)) + popcount_c((uint32_t(x >> 32)));
return popcount_c((uint32_t)(x)) + popcount_c((uint32_t)(x >> 32));
}

struct AudioFrame::Private {
Expand Down
42 changes: 35 additions & 7 deletions bmf/sdk/cpp_sdk/test/test_module_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ TEST(module_manager, test_compat_path) {
auto p1 = p0 / std::string("a.out");
p0 /= std::string("a.out");
EXPECT_EQ(p0.string(), p0.string());
EXPECT_EQ(p0.string(), "/home/foo/a.out");
std::string p0_result;
std::string val;
#ifdef _WIN32
p0_result = "/home/foo\\a.out";
val = "test_bmf_module_sdk.exe";
#else
p0_result = "/home/foo/a.out";
val = "test_bmf_module_sdk";
#endif
EXPECT_EQ(p0.string(), p0_result);

auto p2 = fs::path("./foo/b.txt");
EXPECT_EQ(p2.extension(), std::string(".txt"));
Expand All @@ -56,8 +65,8 @@ TEST(module_manager, test_compat_path) {
EXPECT_EQ(p4.parent_path().filename().string(), "foo");
EXPECT_EQ(fs::path("foo").filename().string(), "foo");

EXPECT_TRUE(fs::exists("test_bmf_module_sdk"));
EXPECT_FALSE(fs::is_directory("test_bmf_module_sdk"));
EXPECT_TRUE(fs::exists(val));
EXPECT_FALSE(fs::is_directory(val));
EXPECT_FALSE(fs::exists("not_exists"));
}

Expand All @@ -72,7 +81,13 @@ TEST(module_manager, resolve_module_info) {
ASSERT_TRUE(info != nullptr);
EXPECT_EQ(info->module_name, "c_ffmpeg_decoder");
EXPECT_TRUE(fs::exists(info->module_path));
EXPECT_EQ(info->module_entry, "libbuiltin_modules.CFFDecoder");
std::string module_entry;
#ifdef _WIN32
module_entry = "builtin_modules.CFFDecoder";
#else
module_entry = "libbuiltin_modules.CFFDecoder";
#endif
EXPECT_EQ(info->module_entry, module_entry);
EXPECT_EQ(info->module_type, "c++");
}

Expand All @@ -82,7 +97,13 @@ TEST(module_manager, resolve_module_info) {
ASSERT_TRUE(info != nullptr);
EXPECT_EQ(info->module_name, "pass_through");
EXPECT_TRUE(fs::exists(info->module_path));
EXPECT_EQ(info->module_entry, "libpass_through.PassThroughModule");
std::string module_entry;
#ifdef _WIN32
module_entry = "pass_through.PassThroughModule";
#else
module_entry = "libpass_through.PassThroughModule";
#endif
EXPECT_EQ(info->module_entry, module_entry);
EXPECT_EQ(info->module_type, "c++");
}

Expand All @@ -104,7 +125,13 @@ TEST(module_manager, resolve_module_info) {
EXPECT_EQ(info->module_type, "c++");
EXPECT_EQ(info->module_name, "cpp_copy_module");
EXPECT_TRUE(fs::exists(info->module_path));
EXPECT_EQ(info->module_entry, "libcopy_module.CopyModule");
std::string module_entry;
#ifdef _WIN32
module_entry = "copy_module.CopyModule";
#else
module_entry = "libcopy_module.CopyModule";
#endif
EXPECT_EQ(info->module_entry, module_entry);
}

// resolve module info from sys repo(python)
Expand Down Expand Up @@ -170,14 +197,15 @@ TEST(module_manager, load_module) {
auto module = facotry->make(1);
EXPECT_TRUE(module != nullptr);
}

#ifndef _WIN32
// load sys repo module(go)
{
auto facotry = M.load_module("go_copy_module");
ASSERT_TRUE(facotry != nullptr);
auto module = facotry->make(1);
EXPECT_TRUE(module != nullptr);
}
#endif
}

#endif // BMF_ENABLE_MOBILE
Expand Down
12 changes: 6 additions & 6 deletions bmf/test/complex_edit_case/test_compare_with_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def jobv(index):
input = "../../files/edit" + str(index) + ".mp4"
output = "../../files/vv_" + str(index) + ".mp4"
cmd = "ffmpeg -y -i " + input + " -t 10.0 -filter_complex " \
"'[0:v]scale=-2:720,setsar=r=1/1[s],[s]pad=w=1280:h=720:x=(ow-iw)/2:y=(oh-ih)/2:color=black,setsar=r=1/1' " \
"\"[0:v]scale=-2:720,setsar=r=1/1[s],[s]pad=w=1280:h=720:x=(ow-iw)/2:y=(oh-ih)/2:color=black,setsar=r=1/1\" " \
"-c:v libx264 -crf 23 -preset veryfast -r 20.0 -an -y " + output
os.system(cmd)

Expand All @@ -35,7 +35,7 @@ def longvideo_jobv(index):
input = "../../files/edit2.mp4"
output = "../../files/vv_" + str(index) + ".mp4"
cmd = "ffmpeg -y -i " + input + " -t 60.0 -filter_complex " \
"'[0:v]scale=-2:720,setsar=r=1/1[s],[s]pad=w=1280:h=720:x=(ow-iw)/2:y=(oh-ih)/2:color=black,setsar=r=1/1' " \
"\"[0:v]scale=-2:720,setsar=r=1/1[s],[s]pad=w=1280:h=720:x=(ow-iw)/2:y=(oh-ih)/2:color=black,setsar=r=1/1\" " \
"-c:v libx264 -crf 23 -preset veryfast -r 20.0 -an -y " + output
os.system(cmd)

Expand Down Expand Up @@ -156,12 +156,12 @@ def test_edit_concat_ffmpeg(self):
i.join()

cmd4 = "ffmpeg -y -i ../../files/vv_1.mp4 -i ../../files/vv_2.mp4 -i ../../files/vv_3.mp4 -filter_complex " \
"'[0:v]scale=1280:720[v1];[v1]split[sp1][sp2];[sp1]trim=start=0:duration=10[v2];[v2]setpts=PTS-STARTPTS[v3];[sp2]trim=start=9:duration=1[v4];" \
"\"[0:v]scale=1280:720[v1];[v1]split[sp1][sp2];[sp1]trim=start=0:duration=10[v2];[v2]setpts=PTS-STARTPTS[v3];[sp2]trim=start=9:duration=1[v4];" \
"[v4]setpts=PTS-STARTPTS[v5];[v5]scale=200:200[v6];[1:v]scale=1280:720[v7];[v7]split[sp3][sp4];[sp3]trim=start=0:duration=10[v8];" \
"[v8]setpts=PTS-STARTPTS[v9];[v9][v6]overlay=repeatlast=0[v10];[sp4]trim=start=9:duration=1[v11];" \
"[v11]setpts=PTS-STARTPTS[v12];[v12]scale=200:200[v13];[2:v]scale=1280:720[v14];[v14]trim=start=0:duration=10[v15];" \
"[v15]setpts=PTS-STARTPTS[v16];[v16][v13]overlay=repeatlast=0[v17];[v3][v10][v17]concat=n=3:v=1:a=0[v18]" \
"' -map '[v18]' -c:v libx264 -crf 23 -r 20 -s 1280x720 -preset veryfast %s" % (output_path)
"\" -map \"[v18]\" -c:v libx264 -crf 23 -r 20 -s 1280x720 -preset veryfast %s" % (output_path)

os.system(cmd4)

Expand Down Expand Up @@ -281,12 +281,12 @@ def test_longvideo_edit_concat_ffmpeg(self):
i.join()

cmd4 = "ffmpeg -y -i ../../files/vv_1.mp4 -i ../../files/vv_2.mp4 -i ../../files/vv_3.mp4 -filter_complex " \
"'[0:v]scale=1280:720[v1];[v1]split[sp1][sp2];[sp1]trim=start=0:duration=60[v2];[v2]setpts=PTS-STARTPTS[v3];[sp2]trim=start=55:duration=5[v4];" \
"\"[0:v]scale=1280:720[v1];[v1]split[sp1][sp2];[sp1]trim=start=0:duration=60[v2];[v2]setpts=PTS-STARTPTS[v3];[sp2]trim=start=55:duration=5[v4];" \
"[v4]setpts=PTS-STARTPTS[v5];[v5]scale=200:200[v6];[1:v]scale=1280:720[v7];[v7]split[sp3][sp4];[sp3]trim=start=0:duration=60[v8];" \
"[v8]setpts=PTS-STARTPTS[v9];[v9][v6]overlay=repeatlast=0[v10];[sp4]trim=start=55:duration=5[v11];" \
"[v11]setpts=PTS-STARTPTS[v12];[v12]scale=200:200[v13];[2:v]scale=1280:720[v14];[v14]trim=start=0:duration=60[v15];" \
"[v15]setpts=PTS-STARTPTS[v16];[v16][v13]overlay=repeatlast=0[v17];[v3][v10][v17]concat=n=3:v=1:a=0[v18]" \
"' -map '[v18]' -c:v libx264 -crf 23 -r 20 -s 1280x720 -preset veryfast %s" % (output_path)
"\" -map \"[v18]\" -c:v libx264 -crf 23 -r 20 -s 1280x720 -preset veryfast %s" % (output_path)

os.system(cmd4)

Expand Down
9 changes: 7 additions & 2 deletions bmf/test/cpp_builder/cpp_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ TEST(cpp_modules, module_cpp) {
nlohmann::json decode_para = {
{"input_path", "../../files/big_bunny_10s_30fps.mp4"}};
auto video = graph.Decode(bmf_sdk::JsonParam(decode_para));

std::string module_name;
#ifdef _WIN32
module_name = "../lib/copy_module.dll";
#else
module_name = "../lib/libcopy_module.so";
#endif
auto video_2 =
graph.Module({video["video"]}, "copy_module", bmf::builder::CPP,
bmf_sdk::JsonParam(), "CopyModule",
"../lib/libcopy_module.so", "copy_module:CopyModule");
module_name, "copy_module:CopyModule");

nlohmann::json encode_para = {
{"output_path", output_file},
Expand Down
2 changes: 2 additions & 0 deletions build_win_lite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ BUILD_DIR=build_win_lite
OUTPUT_DIR=output
COMPILE_ARCH=""
preset=""
PYTHON_VERSION=3.9
export SCRIPT_EXEC_MODE=win

export WIN_XCOMPILE_ROOT=$(pwd)/3rd_party/win_rootfs
Expand Down Expand Up @@ -117,6 +118,7 @@ if [[ ${HOST} =~ msys_nt || ${HOST} =~ mingw ]]; then
-DRUN_HAVE_POSIX_REGEX=0 \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DBMF_BUILD_VERSION=${BMF_BUILD_VERSION} \
-DBMF_PYENV=${PYTHON_VERSION} \
-DBMF_BUILD_COMMIT=${BMF_BUILD_COMMIT} ../..

)
Expand Down
3 changes: 1 addition & 2 deletions cmake/ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function(find_ffmpeg_version FFMPEG_VERSION_INCLUDE_DIR VERSION_VAR)
endif()
endfunction()


if(DEFINED ENV{FFMPEG_ROOT_PATH})
set(FFMPEG_LIBRARY_DIR $ENV{FFMPEG_ROOT_PATH}/lib)
set(FFMPEG_INCLUDE_DIR $ENV{FFMPEG_ROOT_PATH}/include)
Expand All @@ -52,7 +51,7 @@ else()
find_library(FFMPEG_LIBRARY_DIR avcodec
HINTS /usr/)
endif()

message(STATUS "FFMPEG_INCLUDE_DIR:" ${FFMPEG_INCLUDE_DIR} ", FFMPEG_LIBRARY_DIR:" ${FFMPEG_LIBRARY_DIR})
if(FFMPEG_LIBRARY_DIR AND FFMPEG_INCLUDE_DIR)
message(STATUS "find FFmpeg, FFMPEG_INCLUDE_DIR:" ${FFMPEG_INCLUDE_DIR} ", FFMPEG_LIBRARY_DIR:" ${FFMPEG_LIBRARY_DIR})
function(define_ffmpeg_target)
Expand Down
Loading

0 comments on commit 125d82a

Please sign in to comment.