Wednesday, 3 February 2021

How to build FFMPEG in Ubuntu18?

 

sudo apt-get update -qq && sudo apt-get -y install \ autoconf \ automake \ build-essential \ cmake \ git-core \ libass-dev \ libfreetype6-dev \ libgnutls28-dev \ libsdl2-dev \ libtool \ libva-dev \ libvdpau-dev \ libvorbis-dev \ libxcb1-dev \ libxcb-shm0-dev \ libxcb-xfixes0-dev \ meson \ ninja-build \ pkg-config \ texinfo \ wget \ yasm \ zlib1g-dev
sudo apt-get install nasm
sudo apt-get install libx264-dev

sudo apt-get install libx265-dev libnuma-dev
sudo apt-get install libvpx-dev
sudo apt-get install libfdk-aac-dev
sudo apt-get install libmp3lame-dev
sudo apt-get install libopus-dev


cd ~/ffmpeg_sources && \
git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom && \
mkdir -p aom_build && \
cd aom_build && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_NASM=on -DBUILD_SHARED_LIBS=on ../aom && \
PATH="$HOME/bin:$PATH" make -j32 && \
make install

cd ~/ffmpeg_sources && \
git -C SVT-AV1 pull 2> /dev/null || git clone https://github.com/AOMediaCodec/SVT-AV1.git && \
mkdir -p SVT-AV1/build && \
cd SVT-AV1/build && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=ON .. && \
PATH="$HOME/bin:$PATH" make && \
make install

cd ~/ffmpeg_sources && \
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar xjvf ffmpeg-snapshot.tar.bz2 && \
cd ffmpeg && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="$HOME/ffmpeg_build" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --extra-libs="-lpthread -lm" \
  --bindir="$HOME/bin" \
  --enable-gpl \
  --enable-gnutls \
  --enable-libaom \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libsvtav1 \
  --enable-libdav1d \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
  --disable-static \
  --enable-shared \
  --enable-nonfree && \
PATH="$HOME/bin:$PATH" make -j32 && \
make install && \
hash -r

 

Reference: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

Friday, 29 January 2021

How to install nvidia driver and cuda together in ubuntu18?

1. boot into ubuntu os

2. login to os and download cuda installer, cuda_10.2.89_440.33.01_linux.run (the best version for 2080ti)

3. press ctrl + alt + f3

4. login with username and password

5. type the following commands in terminal:-

sudo service gdm stop

sudo apt purge nvidia*

sudo apt install gcc

sudo apt install libglvnd-dev

sudo sh  cuda_10.2.89_440.33.01_linux.run (check all boxes and install) 

Once completed, you should able to see driver, toolkit and samples installed successfully. Then,

sudo reboot

nvidia-smi

Tuesday, 26 January 2021

How to add cmake arguments in vscode?

 Ctrl + Shift + P -> Open Workspace Settings (Json)

{
    "cmake.configureArgs": [
        "-DCMAKE_INSTALL_PREFIX=/home/ninja/workspace/opencv/distribute",
        "-DWITH_CUDA=ON",
        "-DWITH_CUBLAS=ON",
        "-Dpkgcfg_lib_FFMPEG_avformat=/usr/local/ffmpeg/lib/libavformat.so",
        "-Dpkgcfg_lib_FFMPEG_avcodec=/usr/local/ffmpeg/lib/libavcodec.so",
        "-Dpkgcfg_lib_FFMPEG_avutil=/usr/local/ffmpeg/lib/libavutil.so",
        "-DOPENCV_EXTRA_MODULES_PATH=/home/ninja/workspace/opencv_contrib-4.2.0/modules",
    ]
}



==========================================

Opencv4.4.0 with CUDA, NVCUVID

==========================================

{
    "cmake.configureArgs": [
        "-DCMAKE_BUILD_TYPE=RELEASE",
        "-DCMAKE_INSTALL_PREFIX=/home/ninja/workspace/opencv-4.4.0/distribute",
        "-DINSTALL_C_EXAMPLES=ON",
        "-DOPENCV_GENERATE_PKGCONFIG=ON",
        "-DINSTALL_PYTHON_EXAMPLES=ON",
        "-DBUILD_SHARED_LIBS=ON",
        "-DWITH_TBB=ON",
        "-DWITH_V4L=ON",
        "-DBUILD_opencv_world=OFF",
        "-DOPENCV_PYTHON3_INSTALL_PATH=/home/ninja/workspace/opencv-4.4.0/distribute/python3",
        "-DWITH_QT=ON",
        "-DWITH_OPENGL=ON",
        "-DWITH_CUDA=ON",
        "-DWITH_CUFFT=ON",
        "-DWITH_CUBLAS=ON",
        "-DWITH_NVCUVID=ON",
        "-DBUILD_CUDA_STUBS=ON",
        "-DBUILD_opencv_cudalegacy=ON",
        "-DBUILD_opencv_cudacodec=ON",
        "-DCUDA_FAST_MATH=ON",
        "-DCUDA_GENERATION=Kepler",
        "-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.2",
        "-DCUDA_nvcuvid_LIBRARIES=/home/ninja/workspace/Video_Codec_SDK_10.0.26/Lib/linux/stubs/x86_64/libnvcuvid.so",
        "-DCUDA_nvcuvenc_LIBRARIES=/home/ninja/workspace/Video_Codec_SDK_10.0.26/Lib/linux/stubs/x86_64/libnvidia-encode.so",
        "-DOPENCV_EXTRA_MODULES_PATH=/home/ninja/workspace/opencv_contrib-4.4.0/modules",
        "-DBUILD_NEW_PYTHON_SUPPORT=ON",
        "-DBUILD_opencv_python3=ON",
        "-DHAVE_opencv_python3=ON",
        "-DPYTHON3_EXECUTABLE=/home/ninja/anaconda3/bin/python",
        "-DPYTHON3_DEFAULT_EXECUTABLE=/home/ninja/anaconda3/bin/python",
        "-DPYTHON3_INCLUDE_PATH=/home/ninja/anaconda3/include/python3.8",
        "-DPYTHON3_NUMPY_INCLUDE_DIRS=/home/ninja/anaconda3/lib/python3.8/site-packages/numpy/core/include",
        "-DPYTHON3_PACKAGES_PATH=/home/ninja/anaconda3/lib/python3.8/site-packages",
        "-DPYTHON3_LIBRARIES=/home/ninja/anaconda3/lib/libpython3.8.so",
        "-DPYTHON3_LIBRARIES_PATH=/home/ninja/anaconda3/lib",
        "-DBUILD_EXAMPLES=ON"
        ]
}


(put include_directories(/home/ninja/workspace/Video_Codec_SDK_10.0.26/Interface) into CMakeLists.txt)

Wednesday, 20 January 2021

How to remove .jpg files in current and subfolders?

current folder and one level sub folder:-

find . -maxdepth 2 -type f -name "*.jpg" -delete 

or

find . -name "*.jpg" -exec rm -rf {} \;



Tuesday, 19 January 2021

How to install labelme in ubuntu using python2.7?

 conda create -n labelme python=2.7

conda activate labelme

conda install pyqt

pip install labelme

How to install different ubuntu desktop?

Kubuntu: apt-get install kubuntu-desktop (KDE)
Xubuntu: apt-get install xubuntu-desktop (XFCE) - like windows
Lubuntu: apt-get install lubuntu-desktop (LXDE)
Ubuntu GNOME: apt-get install ubuntu-gnome-desktop (Gnome)

Sunday, 17 January 2021

How to kill a process based on process name?

 kill -9 $(pidof watch) 

# where 'watch' is the process name