diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b8ddf1c..62db7ef5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,8 @@ jobs: - name: build id: build run: | + sed -i 's/option(BMF_ENABLE_PYTHON "Enable build with python support" OFF)/option(BMF_ENABLE_PYTHON "Enable build with python support" ON)/' CMakeLists.txt + sed -i 's/option(BMF_ENABLE_TEST "Compile examples and tests" OFF)/option(BMF_ENABLE_TEST "Compile examples and tests" ON)/' CMakeLists.txt ./build.sh debug - name: set envs @@ -78,6 +80,10 @@ jobs: # test hmp (cd bmf/hml/tests/data && ./gen.sh $(pwd)/../../../../output/files) (cd bmf/hml/tests && pytest) + + - name: Setup tmate session + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 build_and_test_win: name: build and test win diff --git a/.gitignore b/.gitignore index ec59f314..23358c51 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,14 @@ *.so *.sym /build*/ +CMakeFiles +_deps +bmf/files* +bmf/demo/transcode/*.mp4 +bmf/test/distributed_node/build/* +bmf/demo/transcode/*.json +bmf/demo/transcode/test_cb +bmf/demo/transcode/test_cb.d* !build.gradle bmf/c_module_sdk/build bmf/c_module_sdk/cmake-build-debug diff --git a/CMakeLists.txt b/CMakeLists.txt index 76f61372..7f1d2a7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,14 +16,14 @@ set(BMF_BUILD_COMMIT "" CACHE STRING "BMF commit") option(BMF_LOCAL_DEPENDENCIES "Build dependencies locally" ON) option(BMF_ENABLE_BREAKPAD "Enable build with breakpad support" OFF) -option(BMF_ENABLE_CUDA "Enable CUDA support" ON) +option(BMF_ENABLE_CUDA "Enable CUDA support" OFF) option(BMF_ENABLE_TORCH "Enable CUDA support" OFF) -option(BMF_ENABLE_PYTHON "Enable build with python support" ON) +option(BMF_ENABLE_PYTHON "Enable build with python support" OFF) option(BMF_ENABLE_GLOG "Enable build with glog support" OFF) option(BMF_ENABLE_JNI "Enable build with JNI support" OFF) option(BMF_ENABLE_FFMPEG "Enable build with ffmpeg support" ON) option(BMF_ENABLE_MOBILE "Enable build for mobile platform" OFF) -option(BMF_ENABLE_TEST "Compile examples and tests" ON) +option(BMF_ENABLE_TEST "Compile examples and tests" OFF) option(BMF_ENABLE_FUZZTEST "Enable fuzz tests" OFF) option(FUZZTEST_ENABLE_FUZZING_MODE "Enable fuzz tests in fuzzing mode" OFF) option(CMAKE_EXPORT_COMPILE_COMMANDS "Export compiler commands" OFF) diff --git a/activate_env.sh b/activate_env.sh new file mode 100644 index 00000000..73d98a68 --- /dev/null +++ b/activate_env.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# set the environment variables for bmf +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 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$(pwd)/output/bmf/lib + +# only set if you want to use BMF in python +export PYTHONPATH=$(pwd)/output/bmf/lib:$(pwd)/output +export DYLD_LIBRARY_PATH=~/Documents/Programs/Git/Github/bmf/output/bmf/lib diff --git a/bmf/builder/bmf_graph.py b/bmf/builder/bmf_graph.py index 749b2985..b6c71d68 100644 --- a/bmf/builder/bmf_graph.py +++ b/bmf/builder/bmf_graph.py @@ -511,6 +511,7 @@ def generate_meta_info_config(pre_module, callback_dict): # set callback function for key, callback in callback_dict.items(): callback_binding = "{}:{}".format(key, callback[0]) + print(callback_binding) meta_info_config.add_callback_binding(callback_binding) return meta_info_config diff --git a/bmf/c_modules/include/ffmpeg_decoder.h b/bmf/c_modules/include/ffmpeg_decoder.h index f0e17ae6..21191ff5 100644 --- a/bmf/c_modules/include/ffmpeg_decoder.h +++ b/bmf/c_modules/include/ffmpeg_decoder.h @@ -173,6 +173,8 @@ class CFFDecoder : public Module { int orig_pts_time_ = 0; + std::function callback_endpoint_; + int process_raw_stream_packet(Task &task, BMFAVPacket &bmf_pkt, bool eof); int process_input_bmf_av_packet(Task &task); @@ -234,6 +236,9 @@ class CFFDecoder : public Module { int read_packet(uint8_t *buf, int buf_size); int pkt_ts(AVPacket *pkt, int index); + + void set_callback( + std::function callback_endpoint) override; }; /** @page ModuleDecoder Build-in Decode Module * @ingroup DecM diff --git a/bmf/c_modules/include/ffmpeg_encoder.h b/bmf/c_modules/include/ffmpeg_encoder.h index 603c26c5..a3ed6116 100644 --- a/bmf/c_modules/include/ffmpeg_encoder.h +++ b/bmf/c_modules/include/ffmpeg_encoder.h @@ -138,6 +138,8 @@ class CFFEncoder : public Module { CurrentImage2Buffer current_image_buffer_ = {0}; bool copy_ts_ = false; bool has_complex_filtergraph_ = false; + // use for callback to get the frame number + int frame_number = 0; public: CFFEncoder(int node_id, JsonParam option); diff --git a/bmf/c_modules/src/ffmpeg_decoder.cpp b/bmf/c_modules/src/ffmpeg_decoder.cpp index fe2de016..32774e7e 100644 --- a/bmf/c_modules/src/ffmpeg_decoder.cpp +++ b/bmf/c_modules/src/ffmpeg_decoder.cpp @@ -2468,6 +2468,12 @@ int CFFDecoder::process(Task &task) { init_input(dec_opts_); } + if (callback_endpoint_ != nullptr) { + std::string info = "total frame number: " + std::to_string(video_stream_->nb_frames); + auto para = CBytes::make((uint8_t *)info.c_str(), info.size()); + callback_endpoint_(0, para); + } + if (!input_fmt_ctx_) { BMFLOG_NODE(BMF_WARNING, node_id_) << "decoder input_fmt_ctx_ is not ready or might be free"; @@ -2524,6 +2530,11 @@ int CFFDecoder::process(Task &task) { return PROCESS_OK; } +void CFFDecoder::set_callback( + std::function callback_endpoint) { + callback_endpoint_ = callback_endpoint; +} + REGISTER_MODULE_CLASS(CFFDecoder) REGISTER_MODULE_INFO(CFFDecoder, info) { info.module_description = "Builtin FFmpeg-based decoding module."; diff --git a/bmf/c_modules/src/ffmpeg_encoder.cpp b/bmf/c_modules/src/ffmpeg_encoder.cpp index f1cfb314..39a896eb 100644 --- a/bmf/c_modules/src/ffmpeg_encoder.cpp +++ b/bmf/c_modules/src/ffmpeg_encoder.cpp @@ -411,14 +411,16 @@ int CFFEncoder::handle_output(AVPacket *hpkt, int idx) { AVPacket *pkt = hpkt; if (idx == 0) { - if (callback_endpoint_ != NULL) { - float curr_time = - (in_stream_tbs_[0].den > 0 && in_stream_tbs_[0].num > 0) - ? float(pkt->pts * in_stream_tbs_[0].num / - in_stream_tbs_[0].den) - : 0; - - std::string info = "pts: " + std::to_string(curr_time); + if (callback_endpoint_ != nullptr) { + // float curr_time = + // (in_stream_tbs_[0].den > 0 && in_stream_tbs_[0].num > 0) + // ? float(pkt->pts * in_stream_tbs_[0].num / + // in_stream_tbs_[0].den) + // : 0; + + // std::string info = "pts: " + std::to_string(curr_time); + std::string info = "pts: " + std::to_string(pkt->pts) + " dts: " + std::to_string(pkt->dts) + +" frame number: "+ std::to_string(++frame_number); auto para = CBytes::make((uint8_t *)info.c_str(), info.size()); callback_endpoint_(0, para); } diff --git a/bmf/demo/transcode/build.sh b/bmf/demo/transcode/build.sh new file mode 100644 index 00000000..bc4d571e --- /dev/null +++ b/bmf/demo/transcode/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +g++ -std=c++17 -g -o test_cb test_cb.cpp -L/Users/jacklau/Documents/Programs/Git/Github/bmf/output/bmf/lib -lengine -lbmf_module_sdk -lhmp diff --git a/bmf/demo/transcode/test_cb.cpp b/bmf/demo/transcode/test_cb.cpp new file mode 100644 index 00000000..debbe318 --- /dev/null +++ b/bmf/demo/transcode/test_cb.cpp @@ -0,0 +1,146 @@ +#include "builder.hpp" +#include "nlohmann/json.hpp" +#include "connector.hpp" + +#include + +// Global variable or pass-by-reference as needed +int frame_number_total = 0; +int frame_number_global = 0; + +int process_number = 0; +double rest_time = 0; + +std::chrono::system_clock::time_point last_encoder_call; // Track last call time +bool first_encoder_call = true; // Flag for first call + +std::vector duration_history; // Store recent durations for averaging +constexpr size_t max_history_size = 20; // Limit for the number of durations tracked +constexpr double min_duration_threshold = 10.0; // Ignore durations < 10 ms + +double compute_smooth_duration(double new_duration) { + if (new_duration >= min_duration_threshold) { + duration_history.push_back(new_duration); + if (duration_history.size() > max_history_size) { + duration_history.erase(duration_history.begin()); + } + } + return duration_history.empty() ? 0.0 : + std::accumulate(duration_history.begin(), duration_history.end(), 0.0) / duration_history.size(); +} + +// std::string format_time(const std::tm& tm) { +// char buffer[20]; // Buffer to hold formatted time string +// std::snprintf(buffer, sizeof(buffer), "%04d-%02d-%02d %02d:%02d:%02d", +// tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, +// tm.tm_hour, tm.tm_min, tm.tm_sec); +// return std::string(buffer); +// } + +bmf_sdk::CBytes decoder_callback(bmf_sdk::CBytes input) { + std::string strInfo; + strInfo.assign(reinterpret_cast(input.buffer), input.size); + // BMFLOG(BMF_INFO) << "====Callback==== " << strInfo; + + + std::regex frame_regex(R"(\btotal frame number:\s*(\d+))"); + std::smatch match; + + if (std::regex_search(strInfo, match, frame_regex) && match.size() > 1) { + std::istringstream(match[1]) >> frame_number_total; // Convert to int + BMFLOG(BMF_DEBUG) << "Extracted Frame Number: " << frame_number_total; + } else { + BMFLOG(BMF_WARNING) << "Failed to extract frame number"; + } + + uint8_t bytes[] = {97, 98, 99, 100, 101, 0}; + return bmf_sdk::CBytes{bytes, 6}; +} + +bmf_sdk::CBytes encoder_callback(bmf_sdk::CBytes input) { + std::string strInfo; + strInfo.assign(reinterpret_cast(input.buffer), input.size); + // BMFLOG(BMF_INFO) << "====Callback==== " << strInfo; + + std::regex frame_regex(R"(\bframe number:\s*(\d+))"); + std::smatch match; + + if (std::regex_search(strInfo, match, frame_regex) && match.size() > 1) { + std::istringstream(match[1]) >> frame_number_global; // Convert to int + BMFLOG(BMF_DEBUG) << "Extracted Total Frame Number: " << frame_number_global; + process_number = frame_number_global * 100 / frame_number_total; + + static auto last_encoder_call_time = std::chrono::system_clock::now(); + auto now = std::chrono::system_clock::now(); + + auto duration = std::chrono::duration_cast(now - last_encoder_call_time).count(); + last_encoder_call_time = now; + + double smooth_duration = compute_smooth_duration(duration); + if (frame_number_global > 0 && frame_number_total > 0) { + // double progress = static_cast(frame_number_global) / frame_number_total; + rest_time = smooth_duration * (frame_number_total-frame_number_global) / 1000; + } + + BMFLOG(BMF_INFO) << "Process Number (percentage): " << process_number << "%\t" + << "Current duration (milliseconds): " << duration << "\t" + << "Smoothed Duration: " << smooth_duration << " ms\t" + << "Estimated Rest Time (seconds): " << rest_time; + + + + if (frame_number_global == frame_number_total) { + BMFLOG(BMF_INFO) << "====Callback==== Finish"; + } + + } else { + BMFLOG(BMF_WARNING) << "Failed to extract frame number"; + } + + uint8_t bytes[] = {97, 98, 99, 100, 101, 0}; + return bmf_sdk::CBytes{bytes, 6}; +} + +int main() { + std::string output_file = "./cb.mp4"; + + std::function de_callback = decoder_callback; + std::function en_callback = encoder_callback; + + nlohmann::json graph_para = { + {"dump_graph", 0} + }; + auto graph = bmf::builder::Graph(bmf::builder::NormalMode, + bmf_sdk::JsonParam(graph_para)); + + nlohmann::json decode_para = { + {"input_path", "../../files/big_bunny_10s_30fps.mp4"}, + }; + auto video = graph.Decode(bmf_sdk::JsonParam(decode_para)); + video.AddCallback(0, std::function(decoder_callback)); + + nlohmann::json encode_para = { + {"output_path", output_file}, + {"video_params", { + {"codec", "h264"}, + {"crf", 23}, + {"preset", "veryslow"} + }}, + {"audio_params", { + {"codec", "aac"}, + {"bit_rate", 128000}, + {"sample_rate", 44100}, + {"channels", 2} + }} + }; + + + + auto node = graph.Encode(video["video"], video["audio"], + bmf_sdk::JsonParam(encode_para)); + + node.AddCallback(0, en_callback); + + graph.Run(); + +} \ No newline at end of file diff --git a/bmf/demo/transcode/transcode.py b/bmf/demo/transcode/transcode.py index d6b94c45..c2fe6ced 100644 --- a/bmf/demo/transcode/transcode.py +++ b/bmf/demo/transcode/transcode.py @@ -148,7 +148,7 @@ def test_video(): def test_cb(): - input_video_path = "../../files/img.mp4" + input_video_path = "../../files/big_bunny_10s_30fps.mp4" output_path = "./cb.mp4" expect_result = '../transcode/cb.mp4|240|320|7.615000|MOV,MP4,M4A,3GP,3G2,MJ2|366635|348991|h264|' \ '{"fps": "30.0662251656"}' @@ -156,14 +156,15 @@ def test_cb(): graph = bmf.graph() def cb(para): - print(para) - - graph.add_user_callback(bmf.BmfCallBackType.LATEST_TIMESTAMP, cb) + print("====CallBack====", para.decode('UTF-8')) + return bytes("OK", "ASCII") # decode video = graph.decode({"input_path": input_video_path}) - (bmf.encode( + video.node_.add_user_callback(bmf.BmfCallBackType.LATEST_TIMESTAMP, cb) + + bmf.encode( video['video'], video['audio'], { "output_path": output_path, "video_params": { @@ -173,7 +174,10 @@ def cb(para): "crf": "23", "preset": "veryfast" } - }).run()) + }).node_.add_user_callback(bmf.BmfCallBackType.LATEST_TIMESTAMP, cb) + + graph.option_["dump_graph"] = 1 + graph.run() def compareProfile(graph_file): @@ -235,5 +239,5 @@ def compare(): # test_simple() # test_audio() # test_video() - # test_cb() - compare() + test_cb() + # compare() diff --git a/bmf/engine/connector/include/builder.hpp b/bmf/engine/connector/include/builder.hpp index a141a026..0eb06a62 100644 --- a/bmf/engine/connector/include/builder.hpp +++ b/bmf/engine/connector/include/builder.hpp @@ -141,6 +141,9 @@ class RealNode : public std::enable_shared_from_this { void AddCallback(long long key, bmf::BMFCallback callbackInstance); + void AddCallback(long long key, + std::function callback); + nlohmann::json Dump(); std::shared_ptr @@ -451,6 +454,9 @@ class BMF_ENGINE_API Node { void AddCallback(long long key, const bmf::BMFCallback &callbackInstance); + void AddCallback(long long key, + std::function callback); + void Start(); Node Module( diff --git a/bmf/engine/connector/src/builder.cpp b/bmf/engine/connector/src/builder.cpp index 06f0ae82..35e48950 100644 --- a/bmf/engine/connector/src/builder.cpp +++ b/bmf/engine/connector/src/builder.cpp @@ -133,9 +133,12 @@ nlohmann::json RealNode::NodeMetaInfo::Dump() { nlohmann::json info; info["premodule_id"] = preModuleUID_; - info["callback_bindings"] = nlohmann::json::object(); + info["callback_binding"] = + nlohmann::json(std::vector()); for (auto &kv : callbackBinding_) { - info["callback_bindings"][kv.first] = kv.second; + info["callback_binding"].push_back( + std::to_string(kv.first) + ":" + std::to_string(kv.second) + ); } return info; @@ -228,6 +231,12 @@ void RealNode::AddCallback(long long key, bmf::BMFCallback callbackInstance) { std::make_shared(callbackInstance); metaInfo_.callbackBinding_[key] = callbackInstance.uid(); } +void RealNode::AddCallback(long long key, std::function callback) { + auto cb = bmf::BMFCallback(callback); + metaInfo_.callbackInstances_[key] = + std::make_shared(cb); + metaInfo_.callbackBinding_[key] = cb.uid(); +} std::shared_ptr RealNode::AddModule(std::string const &alias, const bmf_sdk::JsonParam &option, @@ -666,6 +675,12 @@ void Node::AddCallback(long long key, baseP_->AddCallback(key, callbackInstance); } +void Node::AddCallback(long long key, + std::function callback) { + std::cout << "===CallBack==== Node::AddCallback" << &callback << std::endl; + baseP_->AddCallback(key, callback); +} + void Node::Start() { Stream(0).Start(); } Node Node::Module(const std::vector &inStreams, diff --git a/bmf/test/distributed_node/CMakeLists.txt b/bmf/test/distributed_node/CMakeLists.txt index 21de6d95..0111cf2e 100644 --- a/bmf/test/distributed_node/CMakeLists.txt +++ b/bmf/test/distributed_node/CMakeLists.txt @@ -5,15 +5,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) # Set compiler flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fPIC") -# Include directories -include_directories( - /root/workspace/bmf_OSPP/output/bmf/include - . -) - -# Link directories -link_directories(/root/workspace/bmf_OSPP/output/bmf/lib) - # Source files # set(LIB_SRCS_SPLIT split_module.cpp) set(LIB_SRCS_COPY copy_module.cpp) @@ -27,12 +18,12 @@ add_library(copy_module SHARED ${LIB_SRCS_COPY}) # Link the external libraries to the modules # target_link_libraries(split_module engine bmf_module_sdk) -target_link_libraries(copy_module engine bmf_module_sdk) +target_link_libraries(copy_module engine bmf_module_sdk hmp) # target_link_libraries(assemble_module engine bmf_module_sdk) # Create the executable and link the shared libraries add_executable(cpp_demo ${MAIN_SRCS}) -target_link_libraries(cpp_demo copy_module engine bmf_module_sdk) +target_link_libraries(cpp_demo copy_module engine bmf_module_sdk hmp) # Clean up build files set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "cpp_demo") diff --git a/build_osx.sh b/build_osx.sh index 589e9be7..94db2028 100755 --- a/build_osx.sh +++ b/build_osx.sh @@ -17,6 +17,8 @@ then if [ "$1" = "clean" ] then rm -rf build_osx + rm -rf output + rm -rf CMakeFiles exit fi diff --git a/scripts/build_ffmpeg.sh b/scripts/build_ffmpeg.sh index 9f79fc3c..c269d196 100755 --- a/scripts/build_ffmpeg.sh +++ b/scripts/build_ffmpeg.sh @@ -10,6 +10,7 @@ then ARCH=$(uname -m) fi +INSTALL_DIR=${INSTALL_DIR:-/usr/local} while [[ $# -gt 0 ]] do @@ -21,6 +22,9 @@ do --arch=*) ARCH=${arg#--arch=} ;; + --install-dir=*) + INSTALL_DIR=${arg#--install-dir=} + ;; *) break ;; @@ -50,7 +54,7 @@ function build_nasm_unix() { tar xjvf nasm-2.15.05.tar.bz2 cd nasm-2.15.05 ./autogen.sh - ./configure --enable-shared + ./configure --enable-shared --prefix=$INSTALL_DIR make -j $2 make install } @@ -60,7 +64,7 @@ function build_yasm_unix() { curl -O -L https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz tar xzvf yasm-1.3.0.tar.gz cd yasm-1.3.0 - ./configure + ./configure --prefix=$INSTALL_DIR make -j $2 make install } @@ -69,7 +73,7 @@ function build_x264_unix() { cd $1 git clone --branch stable --depth 1 https://code.videolan.org/videolan/x264.git cd x264 - ./configure --enable-shared + ./configure --enable-shared --prefix=$INSTALL_DIR make -j $2 make install } @@ -78,7 +82,7 @@ function build_x265_unix() { cd $1 git clone --branch stable --depth 7 https://bitbucket.org/multicoreware/x265_git cd $1/x265_git/build/linux - cmake -G "Unix Makefiles" -DENABLE_SHARED:bool=off ../../source + cmake -G "Unix Makefiles" -DENABLE_SHARED:bool=off -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ../../source make -j $2 make install } @@ -88,7 +92,7 @@ function build_fdk-aac_unix() { git clone --depth 1 https://github.com/mstorsjo/fdk-aac cd fdk-aac autoreconf -fiv - ./configure --enable-shared + ./configure --enable-shared --prefix=$INSTALL_DIR make -j $2 make install } @@ -98,7 +102,7 @@ function build_mp3lame_unix() { curl -O -L https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz tar xzvf lame-3.100.tar.gz cd lame-3.100 - ./configure --enable-shared --enable-nasm + ./configure --enable-shared --enable-nasm --prefix=$INSTALL_DIR make -j $2 make install } @@ -108,7 +112,7 @@ function build_opus_unix() { curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz tar xzvf opus-1.3.1.tar.gz cd opus-1.3.1 - ./configure --enable-shared + ./configure --enable-shared --prefix=$INSTALL_DIR make -j $2 make install } @@ -117,23 +121,36 @@ function build_vpx_unix() { cd $1 git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git cd libvpx - ./configure --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm + ./configure --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --prefix=$INSTALL_DIR make -j $2 make install } function build_ffmpeg_unix() { cd $1 - if [ ! -e ffmpeg-4.4.tar.gz2 ] - then - curl -O -L https://ffmpeg.org/releases/ffmpeg-4.4.tar.bz2 + + version=${version:-5} + + if [ "$version" == "5" ]; then + ffmpeg_version="ffmpeg-5.1.6" + ffmpeg_tar="ffmpeg-5.1.6.tar.bz2" + ffmpeg_url="https://ffmpeg.org/releases/$ffmpeg_tar" + else + ffmpeg_version="ffmpeg-4.4" + ffmpeg_tar="ffmpeg-4.4.tar.bz2" + ffmpeg_url="https://ffmpeg.org/releases/$ffmpeg_tar" fi - if [ -d ffmpeg-4.4 ] - then - rm -rf ffmpeg-4.4 + + if [ ! -e $ffmpeg_tar ]; then + curl -O -L $ffmpeg_url fi - tar xjvf ffmpeg-4.4.tar.bz2 - cd ffmpeg-4.4 + + if [ -d $ffmpeg_version ]; then + rm -rf $ffmpeg_version + fi + + tar xjvf $ffmpeg_tar + cd $ffmpeg_version if [ ${OS} == "Linux" ] && [[ ${DEVICE} =~ "gpu" ]] && [ $(uname -m) == "x86_64" ] then @@ -145,6 +162,7 @@ function build_ffmpeg_unix() { case $3 in x86_64) ./configure \ + --prefix=$INSTALL_DIR \ --pkg-config-flags="--static" \ --enable-shared \ --disable-static \ @@ -155,6 +173,7 @@ function build_ffmpeg_unix() { ;; arm64) ./configure \ + --prefix=$INSTALL_DIR \ --pkg-config-flags="--static" \ --enable-shared \ --disable-static \ @@ -165,6 +184,7 @@ function build_ffmpeg_unix() { ;; *) ./configure \ + --prefix=$INSTALL_DIR \ --pkg-config-flags="--static" \ --enable-shared \ --disable-static \ @@ -384,19 +404,22 @@ then for arg in $@ do - (build_${arg}_unix $(pwd)/ffmpeg_source ${cores}) - if [ ${arg} == "nasm" ] || [ ${arg} == "yasm" ] + if [[ ${arg} != "--install-dir"* ]] # Exclude --install-dir from build arguments then - disable_asm="" - fi + (build_${arg}_unix $(pwd)/ffmpeg_source ${cores}) + if [ ${arg} == "nasm" ] || [ ${arg} == "yasm" ] + then + disable_asm="" + fi - set +e - (check_lib $(pwd)/ffmpeg_source ${arg}) - if [ $? -eq 0 ] - then - ffmpeg_opts="${ffmpeg_opts} --enable-lib${arg}" + set +e + (check_lib $(pwd)/ffmpeg_source ${arg}) + if [ $? -eq 0 ] + then + ffmpeg_opts="${ffmpeg_opts} --enable-lib${arg}" + fi + set -e fi - set -e done ffmpeg_opts="${ffmpeg_opts} ${disable_asm}" diff --git a/version.sh b/version.sh index 462ab6a0..32057e05 100644 --- a/version.sh +++ b/version.sh @@ -1,4 +1,5 @@ #!/bin/bash +#!test if [[ $OS == *Windows* ]]; then BMF_BUILD_VERSION=$(python setup.py --version)