Can someone help me to install the netflix's VMAF library in Ubuntu - ffmpeg

First of all, I have to say that I am not very experienced in ubuntu.
I would like to install this library to use with FFMPEG.
I am following these steps, but I can manage to install it well...
https://github.com/Netflix/vmaf/blob/master/resource/doc/VMAF_Python_library.md
Could someone tell me what are the exact steps (commands) that I have to follow.
On the other hand, someone knows if there are other metrics that can ffmpeg calculates directly (apart from PSNR or SSIM)?
Many thanks

The link you provided is just to install the VMAF python library. To use VMAF with ffmpeg you need to install libvmaf first and then compile ffmpeg with libvmaf filter enabled. However, as one user suggests, you can use already compiled ffmpeg packages https://www.johnvansickle.com/ffmpeg/
Moving to your questions. These are the step by step I followed to install FFmpeg+VMAF over an Ubuntu 20.04:
Installing dependencies:
apt update -qq
apt install pkg-config -y
apt-get install --no-install-recommends\
ninja-build \
python3 \
python3-pip \
python3-setuptools \
python3-wheel \
ninja-build \
wget \
doxygen \
autoconf \
automake \
cmake \
g++ \
gcc \
pkg-config \
make \
nasm \
yasm -y
pip3 install --user meson
Installing libvmaf:
export PATH="$PATH:$HOME/.local/bin"
wget https://github.com/Netflix/vmaf/archive/v1.5.1.tar.gz
tar -xzf v1.5.1.tar.gz
cd vmaf-1.5.1/libvmaf/
meson build --buildtype release
ninja -vC build
ninja -vC build test
ninja -vC build install
Installing ffmpeg:
wget https://ffmpeg.org/releases/ffmpeg-4.2.2.tar.bz2 && tar xjf ffmpeg-4.2.2.tar.bz2
cd ffmpeg-4.2.2
./configure --enable-libvmaf --enable-version3
make
make install
Sometimes, depending on your OS, you also need to setup your $PATH, $LD_LIBRARY_PATH, $PKG_CONFIG_PATH.

Download an already compiled ffmpeg from johnvansickle.com. It supports the libvmaf filter. For instructions on how to install it see the FAQ.

Here is a detailed guide on OTTVerse for compiling and installing FFmpeg with VMAF support on Ubuntu 18.04. It shouldn't take you more than a few minutes.
Be aware, that VMAF's libvmaf library will soon be dropped and replaced with a new library called libvmaf_rc. Hopefully, its compilation with FFmpeg will remain smooth as well.

sudo apt-get install nasm doxygen ninja-build meson
Download VMAF source from here and extract it.
cd into the vmaf source code folder.
cd into the libvmaf folder.
meson build --buildtype release
ninja -vC build
ninja -vC build install
Download ffmpeg source code from here.
Extract the source code and cd into the ffmpeg source code folder.
./configure --enable-gpl --enable-libx264 --enable-libx265 --enable-nonfree --enable-libvmaf --enable-version3
sudo make
sudo make install
Add the following export line to ~/.bashrc or ~/.bash_profile: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/x86_64-linux-gnu/.
Run source ~/.bashrc or source ~/.bash_profile.
Attribution.

Related

centos:centos7 image is missing libgcc_s.so for cross compiling aarch64

I'm trying to setup a docker file that uses the x86_64 centos:centos7 docker image to cross compile to aarch64. The only problem is I'm missing libgcc_s.so for cross compiling, and I'm not sure why. I also noticed that there were no official glibc-aarch64 so I went with Computational's packages. I've provided my docker file, and any help would be appreciated.
FROM centos:centos7
RUN yum -y update \
&& yum -y install epel-release \
&& yum -y install clang gcc gcc-c++ make wget \
&& yum -y install gcc-aarch64-linux-gnu gcc-c++-aarch64-linux-gnu
RUN yum install -y http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/glibc-aarch64-linux-gnu-2.24-2.sdl7.2.noarch.rpm
RUN yum install -y http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/glibc-aarch64-linux-gnu-devel-2.24-2.sdl7.2.noarch.rpm
CMD ["/bin/bash"]
I'm not sure on the exact reason why, but gcc-aarch64-linux-gnu and gcc-c++-arch64-linux-gnu were compiled with --disable-shared. This prevents them from building libgcc_s.so. My best guess on why is because the shared library isn't always used and it's more common to use libgcc.a.
The two solutions that I had were to either build libgcc from source, or to copy the libgcc_s.so from another repo with the same version. I ended up extracting libgcc_s.so from libgcc-4.8.5-44.el7.aarch64.rpm.

Missing OCI support when building GDAL

So I am building a DOTNET application that runs on Debian, and makes use of ogr2ogr to copy data from an oracle database towards an Postgres database.
The problem is that I cannot get GDAL to recognize the OCI driver.
These are the installation commands that I have collected for now:
#Install dependencies used by GDAL and ora2pg
apt-get update && apt-get install -y -q --no-install-recommends \
libc-bin unzip curl ca-certificates rpm libaio1 \
#Package manager for installing Oracle
alien \
# Install postgresql
postgresql-client \
# Used for the POSTGRES_HOME variable
libpq-dev \
#Package manager used for installation of perl database drivers
cpanminus \
# Proj build
sqlite libsqlite3-dev pkg-config g++ make
#Install Oracle
curl -o oracle-instantclient-basic.x86_64.rpm https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-basic-19.9.0.0.0-1.x86_64.rpm
curl -o oracle-instantclient-devel.x86_64.rpm https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-devel-19.9.0.0.0-1.x86_64.rpm
curl -o oracle-instantclient-sqlplus.x86_64.rpm https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-sqlplus-19.9.0.0.0-1.x86_64.rpm
alien -i oracle-instantclient-basic.x86_64.rpm && alien -i oracle-instantclient-devel.x86_64.rpm && alien -i oracle-instantclient-sqlplus.x86_64.rpm
EXPORT ORACLE_HOME=/usr/lib/oracle/19.9/client64
EXPORT TNS_ADMIN=/usr/lib/oracle/19.9/client64/network/admin
EXPORT LD_LIBRARY_PATH=/usr/lib/oracle/19.9/client64/lib
EXPORT PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/oracle/19.9/client64/bin
#Install Postgres en Oracle drivers for perl, ora2pg
cpanm DBD::Oracle
cpanm DBD::Pg
#Setup
wget https://download.osgeo.org/proj/proj-6.3.2.tar.gz
tar -zxf proj-6.3.2.tar.gz -C /opt/
/opt/proj-6.3.2/configure --prefix=/usr --disable-static --enable-lto
make -C /opt/proj-6.3.2/
make install -C /opt/proj-6.3.2/
RUN wget http://download.osgeo.org/gdal/3.2.2/gdal-3.2.2.tar.gz
/opt/gdal-3.2.2/configure
make -C /opt/proj-6.3.2/
make install -C /opt/proj-6.3.2/
Is there anyone who can tell me what I am missing, because I cannot find any answers on the internet...
So after a lot off testing, my colleague found the problem.
Apparently the scripts search for a folder in $ORACLE_HOME/sdk.
Now by installing it, like above, it doesn't install the sdk folder on the correct location.
So we solved it by adding an extra step extracting the SDK zip package on the correct location.
This is the result:
Dockerfile
Above solution did not work for me. I needed a GDAl container with OCI. Based on some other info I found I build an image that works.
https://github.com/botenvouwer/gdal-oci
Currently you have to clone and build the image yourself. You should (but don't have to) pass the version to your docker build as ARG GDAL_VERSION.

unrecognized option --gc-keep-exported on arm ld

Right now, I'm trying to integrate a GitHub Action that checks if some code on a pull request compiles properly (VEX Robotics for anyone interested). However, when it gets to running the make command, I get this error:
Building Project
make: Entering directory '/github/workspace/V5'
Adding timestamp [OK]
Creating cold package with libpros,okapilib [ERRORS]
/usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/bin/ld: unrecognized option '--gc-keep-exported'
/usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
make: *** [bin/cold.package.elf] Error 1
common.mk:200: recipe for target 'bin/cold.package.elf' failed
I'm extremely confused as to why this is occurring? --gc-keep-exported is a real option, and this code compiles perfectly on my local machine. I've tried changing the ubuntu version and updating the VEX SDK to see if it helps, but I keep on getting the same error. What should I do?
Code:
Dockerfile:
FROM ubuntu:18.04
RUN apt-get update
# Install GCC & Clang
RUN apt-get install build-essential -y
RUN apt-get install clang -y
# Install needed ARM deps
RUN apt-get install gcc-arm-none-eabi -y
RUN apt-get install binutils-arm-none-eabi -y
# Install 7z & cURL
RUN apt-get install p7zip-full -y
RUN apt-get install curl -y
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
entrypoint.sh:
echo "Downloading VEX SDK"
# Get VEX SDK and put it in ~/sdk
curl -L https://content.vexrobotics.com/vexcode/v5code/VEXcodeProV5_2_0_1.dmg -o _vexcode_.dmg
7z x _vexcode_.dmg || :
7z x Payload~ ./VEXcode\ Pro\ V5.app/Contents/Resources/sdk -osdk_temp || :
mkdir ~/sdk
mv sdk_temp/VEXcode\ Pro\ V5.app/Contents/Resources/sdk/* ~/sdk
rm -fR _vex*_ _vex*_.dmg sdk_temp/ Payload~
ls ~/sdk # ls just for testing
echo "Building Project"
# Now make the makefile in the set path
make --directory=$1
The reason this was happening was because I used an old version of gcc-arm-none-eabi. The version on apt is super outdated (v6.3.1 vs v10.2.1).
I was able to use the new version by downloading the tarball available on their site and using the direct paths to compile my code.
There is a newer GCC version available for a newer Ubuntu version, you could browse for another one, or be lazy and enjoy some malpractice with me:
FROM ubuntu:latest

compiling ffmpeg with nvidia/cuda failed loading nvcuvid

I am trying to compile an ffmpeg binary with support for using nvidia GPU's, I am running:
os: ubuntu 18.04
nvidia driver: nvidia-driver-390
cat /usr/local/cuda-9.0/version.txt => CUDA Version 9.0.176
gpu: 2x 1080ti
With the instructions shown on https://developer.nvidia.com/ffmpeg, being:
git clone https://git.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
I first found the error ERROR: cuda requested, but not all dependencies are satisfied: ffnvcodec, which was solved with help from https://superuser.com/questions/1299064/error-cuvid-requested-but-not-all-dependencies-are-satisfied-cuda-ffnvcodec. Below is the summary (make and make install just gave a list of commands to run):
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
sed 's###PREFIX###/usr/local#' ffnvcodec.pc.in > ffnvcodec.pc
sudo install -m 0755 -d '/usr/local/include/ffnvcodec'
sudo install -m 0644 include/ffnvcodec/*.h '/usr/local/include/ffnvcodec'
sudo install -m 0755 -d '/usr/local/lib/pkgconfig'
sudo install -m 0644 ffnvcodec.pc '/usr/local/lib/pkgconfig'
With that done, I removed the ffmpeg folder, recloned it and ran within the folder:
./configure --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda-9.0/include --extra-ldflags=-L/usr/local/cuda-9.0/lib64
make -j 10
Note that the path /usr/local/cuda-9.0 does contain both the include and lib64 folders, and that this resulted in no errors, just deprecation warnings.
Now when running this particular ffmpeg binary, with absolute paths, using the flag -hwaccel cuvid results in:
~/Documents/ffmpeg-cuda/ffmpeg/ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -vsync 0 -i ~/test.mp4 -vf "scale_npp=1920:1072" -vcodec h264_nvenc ~/out1.mp4 -vf scale_npp=1280:720 -vcodec h264_nvenc out2.mp4
Which, is exactly what they have on their website to test it, results in:
[h264_cuvid # 0x556348eb94c0] Cannot load cuvidGetDecodeStatus
[h264_cuvid # 0x556348eb94c0] Failed loading nvcuvid.
I have also prepended: PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" before ./configure, but also did not make a difference.
What am I doing wrong? Is there something important I missed?
With the ffmpeg repo https://github.com/FFmpeg/nv-codec-headers, which is "FFmpeg version of headers required to interface with Nvidias codec APIs", I glanced over the fact that Linux needed a "396.24 or newer driver". And only CUDA toolkit 9.2 at least, supports this driver version. So, the order of commands I used I have forgotten, but was roughly like below in order to remove nvidia drivers and cuda software;
sudo apt remove cuda
sudo aot-get autoremove --purge cuda
cd /var
# Here I removed files like cuda-repo-9-0-local-xxx
cd /etc/apt/sources.list.d
# Here I removed files like cuda-9-0-xxx.list/save
Now using the GUI software & Updates, in the additional drivers tab, sometimes wouldnt let me change from 390 to 396, so I'm pretty sure I first changed to Nouveau display driver, restarted the computer, and then chose 396 NVIDIA driver (open source), restarted the computer again and then now using 396, a check with nvidia-smi showed 396.51.
I then went to https://developer.nvidia.com/cuda-downloads and downloaded the 9.2 Linux Ubuntu 17.04 .deb file and then:
wget https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda-repo-ubuntu1710-9-2-local_9.2.148-1_amd64
mv cuda-repo-ubuntu1710-9-2-local_9.2.148-1_amd64 cuda-repo-ubuntu1710-9-2-local_9.2.148-1_amd64.deb
sudo dpkg -i --force-overwrite cuda-repo-ubuntu1710-9-2-local_9.2.148-1_amd64.deb
sudo apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
Now with CudaToolKit 9.2 installed with nvidia-drvier version 396.51, re-doing the steps posted in my question, resulted in no errors when running ffmpeg with -hwaccel cuvid. Which by the way makes a MASSIVE difference!

FFMPEG Install/enable 'libfdk_aac' after installed FFMPEG via PPA

I have linux MINT 17.3 Kernel 4.4.0-81 all update available. (For different reasons I can't move to newer version of ubuntu/mint)
I have installed FFMPEG via PPA (NOT from compiling the source):
sudo add-apt-repository ppa:jonathonf/ffmpeg-3 -y
sudo apt-get update
sudo apt-get install -y ffmpeg
Then I tried to install libfdk-aac with guide:
https://trac.ffmpeg.org/wiki/CompilationGuide/Quick/libfdk-aac
sudo apt-get install pkg-config autoconf automake libtool
git clone https://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
./autogen.sh
./configure --enable-shared --enable-static
make
sudo make install
sudo ldconfig
But I'm still receive from FFMPEG: "unknown encoder 'libfdk_aac'"
How can I check if "libfdk_aac' is correctly installed and HOW CAN I ACTIVATE / ENABLE the 'libfdk_aac' on FFMPEG?
If is not possible in my situation, and if I'm obliged to remove all ffmpeg and follow this:
https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
FFmpeg does not have a "plug-n-play" codec system. If you want to add another external codec you must compile FFmpeg.
Alternatively, you could find a static ffmpeg binary that includes your desired codecs, but this is not a likely option due to the non-free/GPL incompatible situation of the fdk-aac license.
Your best option if you want to use libfdk_aac is to follow the compile guide you linked to. You can even keep the ffmpeg you installed from that PPA because the guide does not interfere with any existing repository ffmpeg.

Resources