diff --git a/README.md b/README.md index 2229ff2fb..b8d221149 100755 --- a/README.md +++ b/README.md @@ -1,9 +1,13 @@ +

+ Header Image +

# ApraPipes -A pipeline framework for developing video and image processing applications. Supports multiple GPUs and Machine Learning toolkits. More details can be found here https://apra-labs.github.io/ApraPipes. +A pipeline framework for developing video and image processing applications. Supports multiple GPUs and Machine Learning toolkits. +Learn more about ApraPipes here https://apra-labs.github.io/ApraPipes. ## Build status -Automatically built and tested on Ubuntu 18.04, Jetson Boards and Windows 11 x64 Visual Studio 2017 Community (without CUDA) +Aprapipes is automatically built and tested on Ubuntu (18.04 and 20.04), Jetson Boards (Jetpack 4.4) and Windows (11) x64 Visual Studio 2017 Community (without CUDA) |OS|Version|With Cuda|Tests|Status| |--|-------|---------|------|------| |Windows|2019|No|[![Test Results](https://gist.githubusercontent.com/kumaakh/f80af234a4aabedc69af3ee197f66944/raw/badge_Windows.svg)](https://gist.githubusercontent.com/kumaakh/f80af234a4aabedc69af3ee197f66944/raw/badge_Windows.svg)|[![CI-Win-NoCUDA](https://github.com/Apra-Labs/ApraPipes/actions/workflows/CI-Win-NoCUDA.yml/badge.svg)](https://github.com/Apra-Labs/ApraPipes/actions/workflows/CI-Win-NoCUDA.yml)| @@ -14,19 +18,37 @@ Automatically built and tested on Ubuntu 18.04, Jetson Boards and Windows 11 x64 |Ubuntu x64_86-WSL|20.04|Yes|[![Test Results](https://gist.githubusercontent.com/kumaakh/f80af234a4aabedc69af3ee197f66944/raw/badge_WSL.svg)](https://gist.githubusercontent.com/kumaakh/f80af234a4aabedc69af3ee197f66944/raw/badge_WSL.svg)|[![CI-Linux-CUDA-wsl](https://github.com/Apra-Labs/ApraPipes/actions/workflows/CI-Linux-CUDA-wsl.yml/badge.svg)](https://github.com/Apra-Labs/ApraPipes/actions/workflows/CI-Linux-CUDA-wsl.yml)| |Ubuntu x64_86-docker|18.04|Yes|No|[![CI-Linux-CUDA-Docker](https://github.com/Apra-Labs/ApraPipes/actions/workflows/CI-Linux-CUDA-Docker.yml/badge.svg)](https://github.com/Apra-Labs/ApraPipes/actions/workflows/CI-Linux-CUDA-Docker.yml)| +## Getting Started with ApraPipes +
+ Please select your Operating System + +
-## Setup + * Note : Make sure to clone using recursive flag + ``` + git clone --recursive https://github.com/Apra-Labs/ApraPipes.git + ``` -### Prerequisites for CUDA -* Make account on developer.nvidia.com, else the next steps will show HTTP 404/403 errors -* Download and install CUDA tool kit based on your OS: __Note: we test both with CUDA v10.2 and v11.7 so either is fine__ - * Ubuntu 18.04 : [CUDA Toolkit 10.2](https://developer.nvidia.com/cuda-10.2-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=debnetwork) or [CUDA Toolkit 11.7](https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=18.04&target_type=deb_network) - * Windows 10/11 : [Cuda Toolkit 10.2](https://developer.nvidia.com/cuda-10.2-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal) or [CUDA Toolkit 11.7](https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64) -* Download [Cudnn](https://developer.nvidia.com/rdp/cudnn-archive#a-collapse765-102) and extract where cuda is installed. Note: this is a painful process. Here are the steps: +

Windows (Version ≥ 10)

+Windows Logo +
+ Requirements + + ### Cuda + * Create an account on developer.nvidia.com if you're not already a member. Note : Otherwise the next step will show HTTP 404/403 error. + * Windows 10/11 : [Cuda Toolkit 10.2](https://developer.nvidia.com/cuda-10.2-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal) or [CUDA Toolkit 11.7](https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64). + + ### Cudnn + * Download [Cudnn](https://developer.nvidia.com/rdp/cudnn-archive#a-collapse765-102) and extract files where cuda is installed. Note: Please be aware that this process requires some effort. Here are the necessary steps: * Download the correct tar/zip file matching your cuda version. _Do not download the exe/installer/deb package._ * Windows: - * download [this file](https://developer.nvidia.com/compute/cudnn/secure/8.3.2/local_installers/10.2/cudnn-windows-x86_64-8.3.2.44_cuda10.2-archive.zip). + * Download [this file](https://developer.nvidia.com/compute/cudnn/secure/8.3.2/local_installers/10.2/cudnn-windows-x86_64-8.3.2.44_cuda10.2-archive.zip). * Extract the downloaded file and copy files to ```C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2``` using an __administrative command prompt__ as follows ``` cd .\extracted_folder @@ -37,8 +59,87 @@ Automatically built and tested on Ubuntu 18.04, Jetson Boards and Windows 11 x64 cd ..\bin copy *.dll "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\" ``` - * Linux: - * download [this file](https://developer.nvidia.com/compute/cudnn/secure/8.3.2/local_installers/10.2/cudnn-linux-x86_64-8.3.2.44_cuda10.2-archive.tar.xz) + ### Prerequisites + * Install Visual Studio 2019 Community + * Install Desktop development C++ + * .NET Desktop development + * Universal Windows Development Platform + * Install choco: + Open Windows PowerShell as Administrator and run: + ``` + Set-ExecutionPolicy AllSigned + Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) + ``` + * Install build dependencies using choco: + ``` + choco feature enable -n allowEmptyChecksums && choco install 7zip git python3 cmake pkgconfiglite -y && pip3 install ninja && pip3 install meson + ``` + * Clone with submodules and LFS. + ``` + git clone --recursive https://github.com/Apra-Labs/ApraPipes.git + ``` + +
+ +
+ Build + + ### Build Without Cuda + If your windows system does not have an NVIDIA GPU use this script + ``` + build_windows_no_cuda.bat + ``` + ### Build With Cuda + ``` + build_windows_cuda.bat + ``` + +
+ +
+ Test + + ### Run Tests + * list all tests + ``` + _build/BUILD_TYPE/aprapipesut.exe --list_content + ``` + * run all tests + ``` + _build/BUILD_TYPE/aprapipesut.exe + ``` + * run all tests disabling memory leak dumps and better progress logging + ``` + _build/BUILD_TYPE/aprapipesut.exe -p -l all --detect_memory_leaks=0 + ``` + * run one test + ``` + _build/BUILD_TYPE/aprapipesut.exe --run_test=filenamestrategy_tests/boostdirectorystrategy + ``` + * run one test with arguments + ``` + _build/BUILD_TYPE/aprapipesut.exe --run_test=unit_tests/params_test -- -ip 10.102.10.121 -data ArgusCamera + ``` + * Look at the unit_tests/params_test to check for sample usage of parameters in test code. + + +
+ +

Linux (Ubuntu ≥ 18.04)

+Linux Logo +
+ Requirements + + ### Cuda + * Create an account on developer.nvidia.com if you're not already a member. Note : Otherwise the next step will show HTTP 404/403 error. + * Ubuntu 18.04/20.04: + 18.04 - [CUDA Toolkit 10.2](https://developer.nvidia.com/cuda-10.2-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=debnetwork) + 20.04 - [CUDA Toolkit 11.7](https://developer.nvidia.com/cuda-11-7-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04) + + ### Cudnn + * Download [Cudnn](https://developer.nvidia.com/rdp/cudnn-archive#a-collapse765-102) and extract files where cuda is installed. Note: Please be aware that this process requires some effort. Here are the necessary steps: + * Linux: + * Download [this file](https://developer.nvidia.com/compute/cudnn/secure/8.3.2/local_installers/10.2/cudnn-linux-x86_64-8.3.2.44_cuda10.2-archive.tar.xz) * extract the files ``` xz -d cudnn-linux-x86_64-8.3.2.44_cuda10.2-archive.tar.xz @@ -50,104 +151,155 @@ Automatically built and tested on Ubuntu 18.04, Jetson Boards and Windows 11 x64 sudo cp -P include/* /usr/local/cuda/include/ sudo cp -P lib/* /usr/local/cuda/lib64/ ``` -## Windows -### Prerequisites -* Install Visual Studio 2019 Community - * Install Desktop development C++ - * .NET Desktop development - * Universal Windows Development Platform -* Install choco: - Open Windows PowerShell as Administrator and run: - ``` - Set-ExecutionPolicy AllSigned - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) - ``` -* Install build dependencies using choco: - ``` - choco feature enable -n allowEmptyChecksums && choco install 7zip git python3 cmake pkgconfiglite -y && pip3 install ninja && pip3 install meson - ``` -* Clone with submodules and LFS. - ``` - git clone --recursive https://github.com/Apra-Labs/ApraPipes.git - ``` - -### Build for windows +
-#### Build Without Cuda -If your windows machies does not have an NVIDIA GPU use this script -``` -build_windows_no_cuda.bat -``` -#### Build With Cuda -``` -build_windows_cuda.bat -``` -### Run Tests -* list all tests - ``` - _build/BUILD_TYPE/aprapipesut.exe --list_content - ``` -* run all tests - ``` - _build/BUILD_TYPE/aprapipesut.exe - ``` -* run all tests disabling memory leak dumps and better progress logging +
+ Build + + * Run this command to make the script file executable. ``` - _build/BUILD_TYPE/aprapipesut.exe -p -l all --detect_memory_leaks=0 + chmod +x build_linux_*.sh ``` -* run one test + ### Build Without Cuda + If your windows system does not have an NVIDIA GPU use this script ``` - _build/BUILD_TYPE/aprapipesut.exe --run_test=filenamestrategy_tests/boostdirectorystrategy + ./build_linux_no_cuda.sh ``` -* run one test with arguments + ### Build With Cuda ``` - _build/BUILD_TYPE/aprapipesut.exe --run_test=unit_tests/params_test -- -ip 10.102.10.121 -data ArgusCamera + ./build_linux_cuda.sh ``` - * Look at the unit_tests/params_test to check for sample usage of parameters in test code - -## Ubuntu 18.04 and 20.04 x64 -### Prerequisites -* Run the following to get latest build tools - ``` - sudo apt-get update && sudo apt-get -y install autoconf automake autopoint build-essential git-core git-lfs libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libsoup-gnome2.4-dev libncurses5-dev libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev ninja-build pkg-config texinfo wget yasm zlib1g-dev nasm gperf bison curl zip unzip tar python3-pip flex && pip3 install meson - ``` -* Note: start a new terminal as pip3 settings do not get effective on the same shell -* CMake minimum version 3.24 - Follow [this article](https://anglehit.com/how-to-install-the-latest-version-of-cmake-via-command-line/) to update cmake -* Clone with submodules and LFS. - ``` - git clone --recursive https://github.com/Apra-Labs/ApraPipes.git - ``` - - -### Build for linux + Build can take ~2 hours depending on the machine configuration. +
-* ```chmod +x build_linux_*.sh``` -* ```./build_linux_x64.sh``` or ```./build_linux_no_cuda.sh``` depending on previous step. No Cuda as the name suggests will not build the Nvidia Cuda GPU Modules. Use this if there is no nvidia GPU present on your host +
+ Test -Build can take ~2 hours depending on the machine configuration. + ### Run Tests + * list all tests + ``` + ./_build/aprapipesut --list_content + ``` + * run all tests + ``` + ./_build/aprapipesut + ``` + * run all tests disabling memory leak dumps and better progress logging + ``` + ./_build/aprapipesut -p -l all --detect_memory_leaks=0 + ``` + * run one test + ``` + ./_build/aprapipesut --run_test=filenamestrategy_tests/boostdirectorystrategy + ``` + * run one test with arguments + ``` + ./_buildaprapipesut --run_test=unit_tests/params_test -- -ip 10.102.10.121 -data ArgusCamera + ``` + * Look at the unit_tests/params_test to check for sample usage of parameters in test code. +
-### Build and test using docker +

Jetson Boards - Nano, TX2, NX, AGX (Jetpack ≥ 4.4)

+Nvidia Logo +
+ Requirements + + ### Prerequisites + * Setup the board with [Jetpack 4.4](https://docs.nvidia.com/sdk-manager/install-with-sdkm-jetson/index.html) or higher as supported. + * Run the following commands to build required libraries. + ``` + sudo apt-get update && sudo apt-get -y install git-lfs libncurses5-dev ninja-build nasm curl libudev-dev libssl-dev && sudo snap install cmake --classic + ``` + * Append following lines to ~/.bashrc. + ``` + export VCPKG_FORCE_SYSTEM_BINARIES=1 + export PATH=/usr/local/cuda/bin${PATH:+:${PATH}} + export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + ``` + * Reload ~/.bashrc: + ``` + source ~/.bashrc: + ``` + * Clone with submodules and LFS. + ``` + git clone --recursive https://github.com/Apra-Labs/ApraPipes.git + ``` + * Run `./bootstrap-vcpkg.sh` in vcpkg/ directory + * Run `./vcpkg integrate install` +
-### Prerequisites -* Ensure virtualization is enabled in both the BIOS settings of your computer and the Windows virtualization feature -Refer [this article](https://support.microsoft.com/en-us/windows/enable-virtualization-on-windows-11-pcs-c5578302-6e43-4b4b-a449-8ced115f58e1#:~:text=Virtualization%20lets%20your%20PC%20emulate,will%20help%20you%20enable%20virtualization) to enable them -* Install WSL 2 on your system: +
+ Build + +### Build for Jetson (Only Cuda Build) + * Run this command to make the script file executable. ``` - wsl --install + chmod +x build_jetson.sh ``` -* Set WSL 2 as the default version using the command line: + * ApraPipes builds CUDA version on Jerson Boads. ``` - wsl --set-default-version 2 + ./build_jetson.sh ``` -* Install Ubuntu-18.04 from [Microsoft store](https://apps.microsoft.com/store/detail/ubuntu-1804-on-windows/9N9TNGVNDL3Q?hl=en-in&gl=in&rtc=1) , Refer [this article](https://learn.microsoft.com/en-us/windows/wsl/install-manual) for any issues regarding installation -* Install Docker Desktop on Windows -from [here](https://docs.docker.com/desktop/install/windows-install/) -* Enable Docker integration with WSL 2 (in Docker Desktop settings -> Resources -> WSL integration -> Enable Ubuntu-18.04 -> Apply&restart) -* Install nvida-container-toolkit using (WSL Ubuntu-18.04) for docker to access Host-system GPU -Follow [this document](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) to install nvidia-container-toolkit -* Note:"Follow the exact instructions outlined in the document to ensure the correct and successful installation of the NVIDIA Container Toolkit" -### Build for Docker + Build can take ~12 hours on Jetson Nano. + Note: Jetson build can also be done using Ubuntu 18.04 x86_64 Laptop via cross compilation. +
+ +
+ Cross Compilation using qemu + +### Cross compilation using qemu + Conceptual steps adapted from [here](https://github.com/zhj-buffer/Cross-Compile-Jetson): -* Use this [docker image](https://github.com/users/kumaakh/packages/container/package/aprapipes-build-x86-ubutu18.04-cuda) with all the software setup. + * On any Intel Ubuntu 18.04 computer (physical or virtual including wsl ) mount a Jetson SD Card Image as described above + * Copy relevant files from mounted image to created a rootfs + * Install qemu on ubuntu host + * chroot into emulated aarm64 environment using script provided in the github link above + * install extra tools and build aprapipes and aprapipesut + * the built aprapipesut can be copied to a Jetson board and run. + + This approach can use all 12-16 cores of a laptop and hence builds faster. +
+ +
+ Test + +### Run Tests + * list all tests `./_build/aprapipesut --list_content` + * run all tests `./_build/aprapipesut` + * run one test `./_build/aprapipesut --run_test=filenamestrategy_tests/boostdirectorystrategy` + * run one test with arguments `./_build/aprapipesut --run_test=unit_tests/params_test -- -ip 10.102.10.121 -data ArgusCamera` + * Look at the unit_tests/params_test to check for sample usage of parameters in test code +
+ +

Docker

+Nvidia Logo +
+ Requirements + +### Prerequisites + * Ensure virtualization is enabled in both the BIOS settings of your computer and the Windows virtualization feature -Refer [this article](https://support.microsoft.com/en-us/windows/enable-virtualization-on-windows-11-pcs-c5578302-6e43-4b4b-a449-8ced115f58e1#:~:text=Virtualization%20lets%20your%20PC%20emulate,will%20help%20you%20enable%20virtualization) to enable them + * Install WSL 2 on your system: + ``` + wsl --install + ``` + * Set WSL 2 as the default version using the command line: + ``` + wsl --set-default-version 2 + ``` + * Install Ubuntu-18.04 from [Microsoft store](https://apps.microsoft.com/store/detail/ubuntu-1804-on-windows/9N9TNGVNDL3Q?hl=en-in&gl=in&rtc=1) , Refer [this article](https://learn.microsoft.com/en-us/windows/wsl/install-manual) for any issues regarding installation + * Install Docker Desktop on Windows -from [here](https://docs.docker.com/desktop/install/windows-install/) + * Enable Docker integration with WSL 2 (in Docker Desktop settings -> Resources -> WSL integration -> Enable Ubuntu-18.04 -> Apply&restart) + * Install nvida-container-toolkit using (WSL Ubuntu-18.04) for docker to access Host-system GPU -Follow [this document](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) to install nvidia-container-toolkit + * Note:"Follow the exact instructions outlined in the document to ensure the correct and successful installation of the NVIDIA Container Toolkit" +
+ +
+ Build + +### Build for Docker + * Use this [docker image](https://github.com/users/kumaakh/packages/container/package/aprapipes-build-x86-ubutu18.04-cuda) with all the software setup. ``` docker pull ghcr.io/kumaakh/aprapipes-build-x86-ubutu18.04-cuda:last-good ``` @@ -168,68 +320,14 @@ Build can take ~2 hours depending on the machine configuration. * build using build_linux_\*.sh scripts as described [above](#build-for-linux) This build will be fairly fast (~10 mins) as entire vcpkg cache comes down with the docker image - -## Jetson boards - Nano, TX2, NX, AGX - -### Prerequisites -* Setup the board with [Jetpack 4.4](https://docs.nvidia.com/sdk-manager/install-with-sdkm-jetson/index.html) -* run the following - ``` - sudo apt-get update && sudo apt-get -y install git-lfs libncurses5-dev ninja-build nasm curl libudev-dev libssl-dev && sudo snap install cmake --classic - ``` -* append following lines to ~/.bashrc - ``` - export VCPKG_FORCE_SYSTEM_BINARIES=1 - export PATH=/usr/local/cuda/bin${PATH:+:${PATH}} - export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} - ``` -* reload ~/.bashrc: - ``` - source ~/.bashrc: - ``` -* Clone with submodules and LFS. - ``` - git clone --recursive https://github.com/Apra-Labs/ApraPipes.git - ``` -* Run `./bootstrap-vcpkg.sh` in vcpkg/ directory -* Run `./vcpkg integrate install` - -### Build for jetsons -* `chmod +x build_jetson.sh` -* `./build_jetson.sh` - -Build can take ~12 hours on Jetson Nano. -Note: Jetson build can also be done using Ubuntu 18.04 x86_64 Laptop via cross compilation. - -### Cross compilation using qemu -Conceptual steps adapted from [here](https://github.com/zhj-buffer/Cross-Compile-Jetson): - -* On any Intel Ubuntu 18.04 computer (physical or virtual including wsl ) mount a Jetson SD Card Image as described above -* Copy relevant files from mounted image to created a rootfs -* Install qemu on ubuntu host -* chroot into emulated aarm64 environment using script provided in the github link above -* install extra tools and build aprapipes and aprapipesut -* the built aprapipesut can be copied to a Jetson board and run. - -This approach can use all 12-16 cores of a laptop and hence builds faster. - - -### Run Tests -* list all tests `_build/aprapipesut --list_content` -* run all tests `_build/aprapipesut` -* run one test `_build/aprapipesut --run_test=filenamestrategy_tests/boostdirectorystrategy` -* run one test with arguments `_build/aprapipesut --run_test=unit_tests/params_test -- -ip 10.102.10.121 -data ArgusCamera` - * Look at the unit_tests/params_test to check for sample usage of parameters in test code - -This project uses boost tests for unit tests. +
## Update Submodules ``` git submodule update --init --recursive ``` - ## Update Documentation -If any changes are made in the documentation i.e. in /docs/source folder, the docs must be regenerated again follwing the steps given below. New contents from the /docs/build directory should be committed. + After making changes to the documentation located in the /docs/source folder, it's essential to regenerate the documentation by following the provided steps. Once regenerated, commit the new content to ensure the latest documentation is up-to-date. ### To regenerate documentation ``` @@ -238,4 +336,4 @@ apt-install get python-sphinx pip install sphinx-rtd-theme cd docs make html -``` +``` \ No newline at end of file diff --git a/base/include/Mp4ReaderSource.h b/base/include/Mp4ReaderSource.h index 675d53689..854b41809 100644 --- a/base/include/Mp4ReaderSource.h +++ b/base/include/Mp4ReaderSource.h @@ -40,7 +40,6 @@ class Mp4ReaderSourceProps : public ModuleProps auto canonicalVideoPath = boost::filesystem::canonical(_videoPath); videoPath = canonicalVideoPath.string(); parseFS = _parseFS; - skipDir = boost::filesystem::path(canonicalVideoPath).parent_path().parent_path().parent_path().string(); bFramesEnabled = _bFramesEnabled; direction = _direction; giveLiveTS = _giveLiveTS; @@ -51,11 +50,16 @@ class Mp4ReaderSourceProps : public ModuleProps parseFSTimeoutDuration = _parseFSTimeoutDuration; readLoop = _readLoop; reInitInterval = _reInitInterval; - if (parseFS) + + //If the input file path is the full video path then its root dir will be skipDir else if the input path is only root dir path then it is directly assigned to skipDir. + if (parseFS && boost::filesystem::path(videoPath).extension() == ".mp4") { skipDir = boost::filesystem::path(videoPath).parent_path().parent_path().parent_path().string(); } - + else + { + skipDir = boost::filesystem::path(canonicalVideoPath).string(); + } } void setMaxFrameSizes(size_t _maxImgFrameSize, size_t _maxMetadataFrameSize) diff --git a/base/src/Mp4ReaderSource.cpp b/base/src/Mp4ReaderSource.cpp index f5471f058..b267b7fb3 100644 --- a/base/src/Mp4ReaderSource.cpp +++ b/base/src/Mp4ReaderSource.cpp @@ -46,7 +46,17 @@ class Mp4ReaderDetailAbs bool Init() { sentEOSSignal = false; - + auto filePath = boost::filesystem::path(mState.mVideoPath); + if (filePath.extension() != ".mp4") + { + if (!cof->probe(filePath, mState.mVideoPath)) + { + LOG_DEBUG << "Mp4 file is not present" << ">"; + isVideoFileFound = false; + return true; + } + isVideoFileFound = true; + } if (mProps.parseFS) { auto boostVideoTS = boost::filesystem::path(mState.mVideoPath).stem().string(); @@ -104,7 +114,15 @@ class Mp4ReaderDetailAbs return; } - auto tempSkipDir = boost::filesystem::path(tempVideoPath).parent_path().parent_path().parent_path().string(); + std::string tempSkipDir; + if (boost::filesystem::path(tempVideoPath).extension() == ".mp4") + { + tempSkipDir = boost::filesystem::path(tempVideoPath).parent_path().parent_path().parent_path().string(); + } + else + { + tempSkipDir = boost::filesystem::path(tempVideoPath).string(); + } if (props.parseFS && mProps.skipDir == tempSkipDir && mState.mVideoPath != "") { if (mProps.videoPath == props.videoPath) @@ -117,6 +135,18 @@ class Mp4ReaderDetailAbs { sentEOSSignal = false; + if (boost::filesystem::path(tempVideoPath).extension() != ".mp4") + { + if (!cof->probe(tempVideoPath, mState.mVideoPath)) + { + LOG_DEBUG << "Mp4 file is not present" << ">"; + isVideoFileFound = false; + return; + } + isVideoFileFound = true; + tempVideoPath = mState.mVideoPath; + } + auto boostVideoTS = boost::filesystem::path(tempVideoPath).stem().string(); uint64_t start_parsing_ts = 0; try diff --git a/base/test/mp4readersource_tests.cpp b/base/test/mp4readersource_tests.cpp index 7aa1d9347..53c97198c 100644 --- a/base/test/mp4readersource_tests.cpp +++ b/base/test/mp4readersource_tests.cpp @@ -202,7 +202,6 @@ BOOST_AUTO_TEST_CASE(read_timeStamp_from_custom_fileName) { /* file structure parsing test */ std::string videoPath = "./data/Mp4_videos/h264_video/apraH264.mp4"; - std::string outPath = "data/testOutput/outFrames"; auto frameType = FrameMetadata::FrameType::H264_DATA; auto h264ImageMetadata = framemetadata_sp(new H264Metadata(0, 0)); bool parseFS = false; @@ -217,7 +216,6 @@ BOOST_AUTO_TEST_CASE(read_timeStamp_from_custom_fileName) BOOST_AUTO_TEST_CASE(getSetProps_change_root_folder) { std::string videoPath = "./data/Mp4_videos/h264_video_metadata/20230514/0011/1686723796848.mp4"; - std::string outPath = "./data/testOutput/outFrames/"; bool parseFS = true; auto frameType = FrameMetadata::FrameType::H264_DATA; auto h264ImageMetadata = framemetadata_sp(new H264Metadata(0, 0)); @@ -248,10 +246,9 @@ BOOST_AUTO_TEST_CASE(getSetProps_change_root_folder) BOOST_TEST(frame->timestamp == 1673420640350); } -BOOST_AUTO_TEST_CASE(getSetProps_change_root_folder_with_custom_file_name) +BOOST_AUTO_TEST_CASE(getSetProps_change_root_folder_to_custom_file_name) { std::string videoPath = "./data/Mp4_videos/h264_video_metadata/20230514/0011/1686723796848.mp4"; - std::string outPath = "./data/testOutput/outFrames/"; bool parseFS = true; auto frameType = FrameMetadata::FrameType::H264_DATA; auto h264ImageMetadata = framemetadata_sp(new H264Metadata(0, 0)); @@ -283,10 +280,9 @@ BOOST_AUTO_TEST_CASE(getSetProps_change_root_folder_with_custom_file_name) BOOST_TEST(frame->timestamp == 1673420640350); } -BOOST_AUTO_TEST_CASE(NotParseFs_to_parseFS) +BOOST_AUTO_TEST_CASE(getSetProps_NotParseFs_to_parseFS) { std::string videoPath = "./data/Mp4_videos/mp4_seeks_tests_h264/apraH264.mp4"; - std::string outPath = "./data/testOutput/outFrames/"; bool parseFS = false; auto frameType = FrameMetadata::FrameType::H264_DATA; auto h264ImageMetadata = framemetadata_sp(new H264Metadata(0, 0)); @@ -318,10 +314,129 @@ BOOST_AUTO_TEST_CASE(NotParseFs_to_parseFS) BOOST_TEST(frame->timestamp == 1685604318680); } -BOOST_AUTO_TEST_CASE(getSetProps_change_root_folder_fail) +BOOST_AUTO_TEST_CASE(getSetProps_custom_file_name_to_root_dir) +{ + std::string videoPath = "./data/Mp4_videos/mp4_seeks_tests_h264/apraH264.mp4"; + bool parseFS = false; + auto frameType = FrameMetadata::FrameType::H264_DATA; + auto h264ImageMetadata = framemetadata_sp(new H264Metadata(0, 0)); + + SetupMp4ReaderTest s(videoPath, h264ImageMetadata, frameType, parseFS, false); + frame_container frames; + + s.mp4Reader->step(); + frames = s.sink->pop(); + auto frame = frames.begin()->second; + BOOST_TEST(frame->timestamp == 1673420640350); + + for (int i = 0; i < 50; i++) + { + s.mp4Reader->step(); + frames = s.sink->pop(); + } + + //change the video file path , Now read first frame new video of changed root dir instead of last frame of open video + auto propsChange = s.mp4Reader->getProps(); + // To read custom file name parseFS needs to be disabled + propsChange.parseFS = true; + propsChange.videoPath = "./data/Mp4_videos/mp4_seeks_tests_h264/"; + s.mp4Reader->setProps(propsChange); + s.mp4Reader->step(); + frames = s.sink->pop(); + frame = frames.begin()->second; + BOOST_TEST(frame->timestamp == 1673420640350); +} + +BOOST_AUTO_TEST_CASE(getSetProps_root_dir_to_custom_file_name) +{ + std::string videoPath = "./data/Mp4_videos/mp4_seeks_tests_h264/"; + bool parseFS = true; + auto frameType = FrameMetadata::FrameType::H264_DATA; + auto h264ImageMetadata = framemetadata_sp(new H264Metadata(0, 0)); + + SetupMp4ReaderTest s(videoPath, h264ImageMetadata, frameType, parseFS, false); + frame_container frames; + + s.mp4Reader->step(); + frames = s.sink->pop(); + auto frame = frames.begin()->second; + BOOST_TEST(frame->timestamp == 1673420640350); + + for (int i = 0; i < 50; i++) + { + s.mp4Reader->step(); + frames = s.sink->pop(); + } + + //change the video file path , Now read first frame new video of changed root dir instead of last frame of open video + auto propsChange = s.mp4Reader->getProps(); + // To read custom file name parseFS needs to be disabled + propsChange.parseFS = false; + propsChange.videoPath = "./data/Mp4_videos/mp4_seeks_tests_h264/apraH264.mp4"; + s.mp4Reader->setProps(propsChange); + s.mp4Reader->step(); + frames = s.sink->pop(); + frame = frames.begin()->second; + BOOST_TEST(frame->timestamp == 1673420640350); +} + +BOOST_AUTO_TEST_CASE(getSetProps_filename_to_root_dir) { std::string videoPath = "./data/Mp4_videos/h264_video_metadata/20230514/0011/1686723796848.mp4"; - std::string outPath = "./data/testOutput/outFrames/"; + bool parseFS = true; + auto frameType = FrameMetadata::FrameType::H264_DATA; + auto h264ImageMetadata = framemetadata_sp(new H264Metadata(0, 0)); + + SetupMp4ReaderTest s(videoPath, h264ImageMetadata, frameType, parseFS, false); + frame_container frames; + + s.mp4Reader->step(); + frames = s.sink->pop(); + auto frame = frames.begin()->second; + BOOST_TEST(frame->timestamp == 1686723796848); + + //change the video file path , Now read first frame new video of changed root dir instead of last frame of open video + auto propsChange = s.mp4Reader->getProps(); + // To read custom file name parseFS needs to be disabled + propsChange.parseFS = true; + propsChange.videoPath = "./data/Mp4_videos/mp4_seeks_tests_h264/"; + s.mp4Reader->setProps(propsChange); + s.mp4Reader->step(); + frames = s.sink->pop(); + frame = frames.begin()->second; + BOOST_TEST(frame->timestamp == 1673420640350); +} + +BOOST_AUTO_TEST_CASE(getSetProps_root_dir_to_filename) +{ + std::string videoPath = "./data/Mp4_videos/mp4_seeks_tests_h264/"; + bool parseFS = true; + auto frameType = FrameMetadata::FrameType::H264_DATA; + auto h264ImageMetadata = framemetadata_sp(new H264Metadata(0, 0)); + + SetupMp4ReaderTest s(videoPath, h264ImageMetadata, frameType, parseFS, false); + frame_container frames; + + s.mp4Reader->step(); + frames = s.sink->pop(); + auto frame = frames.begin()->second; + BOOST_TEST(frame->timestamp == 1673420640350); + + //change the video file path , Now read first frame new video of changed root dir instead of last frame of open video + auto propsChange = s.mp4Reader->getProps(); + // To read custom file name parseFS needs to be disabled + propsChange.parseFS = true; + propsChange.videoPath = "./data/Mp4_videos/h264_video_metadata/20230514/0011/1686723796848.mp4"; + s.mp4Reader->setProps(propsChange); + s.mp4Reader->step(); + frames = s.sink->pop(); + frame = frames.begin()->second; + BOOST_TEST(frame->timestamp == 1686723796848); +} + +BOOST_AUTO_TEST_CASE(getSetProps_change_root_folder_fail) +{ + std::string videoPath = "./data/Mp4_videos/h264_video_metadata/20230514/0011/1686723796848.mp4"; bool parseFS = true; auto frameType = FrameMetadata::FrameType::H264_DATA; auto h264ImageMetadata = framemetadata_sp(new H264Metadata(0, 0)); diff --git a/data/ReadMe Images/ApraPipes.png b/data/ReadMe Images/ApraPipes.png new file mode 100644 index 000000000..25ad6b40e Binary files /dev/null and b/data/ReadMe Images/ApraPipes.png differ diff --git a/data/ReadMe Images/Docker.png b/data/ReadMe Images/Docker.png new file mode 100644 index 000000000..103f2ff36 Binary files /dev/null and b/data/ReadMe Images/Docker.png differ diff --git a/data/ReadMe Images/Linux.png b/data/ReadMe Images/Linux.png new file mode 100644 index 000000000..97472b4fe Binary files /dev/null and b/data/ReadMe Images/Linux.png differ diff --git a/data/ReadMe Images/nvidia.png b/data/ReadMe Images/nvidia.png new file mode 100644 index 000000000..bab3d8cbf Binary files /dev/null and b/data/ReadMe Images/nvidia.png differ diff --git a/data/ReadMe Images/windows.png b/data/ReadMe Images/windows.png new file mode 100644 index 000000000..ef7e3d809 Binary files /dev/null and b/data/ReadMe Images/windows.png differ