Skip to content

Commit 45c0a21

Browse files
committed
Add new scripts to support build raisr without internet access.
The 01_pull_resources.sh is used to pull all resources used for build raisr and ffmpeg and generate tarball. The 02_install_prerequisites.sh is used to extract resources tarball and install package from it. The 03_build_raisr_ffmpeg.sh is used to build raisr and ffmpeg. Signed-off-by: Xiaoxia Liang <xiaoxia.liang@intel.com>
1 parent 140f955 commit 45c0a21

3 files changed

Lines changed: 191 additions & 0 deletions

File tree

scripts/01_pull_resources.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# This script is used to pull all resources(Cmake 3.14, nasm, x264, x265, IPP, Raisr and ffmpeg) used for build RAISR and ffmpeg. And by default, the script will generate a tarball raisr.tar.gz of these resources and you can use "no_package" option to disable generate the tarball.
4+
5+
package_flag=true
6+
7+
# Usage: 01_pull_resource <no_package>
8+
while [ -n "$*" ]; do
9+
case "$(printf %s "$1" | tr '[:upper:]' '[:lower:]')" in
10+
no_package) package_flag=false && shift ;;
11+
*) break ;;
12+
esac
13+
done
14+
15+
raisr_folder=raisr
16+
mkdir $raisr_folder
17+
cd $raisr_folder
18+
19+
# pull cmake 3.14
20+
wget https://cmake.org/files/v3.14/cmake-3.14.0.tar.gz
21+
if [ ! -f "cmake-3.14.0.tar.gz" ];then
22+
echo "Failed to download Cmake 3.14!"
23+
exit 1
24+
fi
25+
26+
# pull raisr code
27+
git clone https://github.com/OpenVisualCloud/Video-Super-Resolution-Library.git
28+
if [ ! -d "Video-Super-Resolution-Library" ];then
29+
echo "Failed to pull source code of Video-Super-Resolution-Library!"
30+
exit 1
31+
fi
32+
33+
# pull ffmpeg
34+
git clone https://github.com/FFmpeg/FFmpeg ffmpeg
35+
if [ ! -d "ffmpeg" ];then
36+
echo "Failed to pull source code of ffmpeg!"
37+
exit 1
38+
fi
39+
40+
cd ffmpeg
41+
git checkout -b n4.4 n4.4
42+
git am ../Video-Super-Resolution-Library/ffmpeg/0001-ffmpeg-raisr-filter.patch
43+
cd -
44+
45+
# pull nasm used for build x264
46+
wget https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2
47+
if [ ! -f "nasm-2.15.05.tar.bz2" ];then
48+
echo "Failed to download nasm!"
49+
exit 1
50+
fi
51+
52+
# pull x264 and x265
53+
git clone https://github.com/mirror/x264 -b stable --depth 1
54+
if [ ! -d "x264" ];then
55+
echo "Failed to pull source code of x264!"
56+
exit 1
57+
fi
58+
59+
wget https://github.com/videolan/x265/archive/3.4.tar.gz
60+
if [ ! -f "3.4.tar.gz" ];then
61+
echo "Failed to download source code of x265!"
62+
exit 1
63+
fi
64+
65+
# pull IPP
66+
wget https://registrationcenter-download.intel.com/akdlm/irc_nas/19007/l_ipp_oneapi_p_2021.6.2.16995_offline.sh
67+
if [ ! -f "l_ipp_oneapi_p_2021.6.2.16995_offline.sh" ];then
68+
echo "Failed to download IPP package!"
69+
exit 1
70+
fi
71+
72+
echo "Successfully downloaded all these resources!"
73+
74+
if [ "$package_flag" == "true" ]; then
75+
cd ..
76+
tar -zcvf ./$raisr_folder.tar.gz ./$raisr_folder
77+
if [ ! -f "$raisr_folder.tar.gz" ];then
78+
echo "Failed to package these resources to $raisr_folder.tar.gz!"
79+
exit 1
80+
else
81+
echo "Successfully packaged these resources to $raisr_folder.tar.gz!"
82+
rm -rf ./$raisr_folder
83+
fi
84+
fi
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
# This scrpit is used to extract the tarball raisr.tar.gz of resources and build and install the libraries required by building raisr and ffmpeg
4+
# It requires Linux based OS(Tested and validated on Ubuntu 18.04 LTS), gcc/g++ 7.5 or later, make and pkg-config to run this script.
5+
6+
# Usage: 02_install_prerequisites.sh /xxx/raisr.tar.gz
7+
8+
package_path=$1
9+
if [ -z "$package_path" ];then
10+
echo "Usage: 02_install_prerequisites.sh /xxx/raisr.tar.gz"
11+
exit 1
12+
fi
13+
14+
tar -zxf $package_path ./
15+
cd raisr
16+
17+
# install IPP
18+
chmod +x ./l_ipp_oneapi_p_2021.6.2.16995_offline.sh
19+
sudo ./l_ipp_oneapi_p_2021.6.2.16995_offline.sh -a -s --eula accept
20+
echo "source /opt/intel/oneapi/ipp/latest/env/vars.sh" | tee -a ~/.bash_profile
21+
22+
# build and install CMake 3.14
23+
tar zxf ./cmake-3.14.0.tar.gz
24+
cd cmake-3.14.0 && \
25+
./bootstrap --prefix=/usr/local && \
26+
make -j $(nproc) && \
27+
sudo make install
28+
cd -
29+
30+
# build and install nasm
31+
tar xjf ./nasm-2.15.05.tar.bz2 && \
32+
cd nasm-2.15.05 && \
33+
./autogen.sh && \
34+
./configure --prefix=/usr/local --libdir=/usr/local/lib && \
35+
make -j $(nproc) && \
36+
sudo make install
37+
cd -
38+
39+
# build and install x264
40+
cd x264 && \
41+
./configure --prefix=/usr/local --libdir=/usr/local/lib \
42+
--enable-shared && \
43+
make -j $(nproc) && \
44+
sudo make install
45+
cd -
46+
47+
# build and install x265
48+
tar xzf ./3.4.tar.gz
49+
cd x265-3.4/build/linux && \
50+
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DLIB_INSTALL_DIR=/usr/local/lib ../../source && \
51+
make -j $(nproc) && \
52+
sudo make install
53+
cd -
54+
55+
# remove the resources except Raisr and ffmpeg
56+
rm l_ipp_oneapi_p_2021.6.2.16995_offline.sh
57+
rm 3.4.tar.gz
58+
rm cmake-3.14.0.tar.gz
59+
rm nasm-2.15.05.tar.bz2
60+
rm -rf ./x264
61+
rm -rf ./x265-3.4
62+
rm -rf ./cmake-3.14.0
63+
rm -rf ./nasm-2.15.05

scripts/03_build_raisr_ffmpeg.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# This scrpit is used to build raisr and ffmpeg
4+
5+
# Usage: 03_build_raisr_ffmpeg.sh /xxx/raisr/Video-Super-Resolution-Library
6+
7+
raisr_path=$1
8+
9+
if [ -z "$raisr_path" ];then
10+
echo "Usage: 03_build_raisr_ffmpeg.sh /xxx/raisr/Video-Super-Resolution-Library"
11+
exit 1
12+
fi
13+
14+
# set IPP, x264 and x265 env
15+
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
16+
source /opt/intel/oneapi/ipp/latest/env/vars.sh
17+
18+
# build raisr
19+
cd $raisr_path
20+
sudo -E ./build.sh no_docker
21+
22+
# build ffmpeg
23+
cd ../ffmpeg
24+
cp ../Video-Super-Resolution-Library/ffmpeg/vf_raisr.c libavfilter/
25+
26+
./configure \
27+
--enable-libipp \
28+
--extra-cflags="-fopenmp" \
29+
--extra-ldflags=-fopenmp \
30+
--enable-gpl \
31+
--enable-libx264 \
32+
--enable-libx265 \
33+
--extra-libs='-lraisr -lstdc++ -lippcore -lippvm -lipps -lippi' \
34+
--enable-cross-compile
35+
make clean
36+
make -j $(nproc)
37+
38+
cp -r ../Video-Super-Resolution-Library/filters* .
39+
40+
echo -e "To run the library you can do the following: \n
41+
cd raisr/ffmpeg \n
42+
./ffmpeg -y -i /input_files/input.mp4 -vf raisr=threadcount=20 -pix_fmt yuv420p /output_files/out.yuv \n
43+
And you can see more use cases in README file of Video-Super-Resolution-Library."
44+

0 commit comments

Comments
 (0)