Recompile FFMPEG with cuvid & nvcc issue
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Recompile FFMPEG with cuvid & nvcc issue
Hi folks,
Apologies, i'm able to get opencv compiled successfully (using dlandon's docker) - nvidia-smi shows up the right driver (440.59) for the build. CUDA 10.2 seems to install ok (although
```nvcc --version``` shows as command not found? Does that mean it failed? Cant find any errors in the logs?
What i really need is some guidance how to remove FFMPEG and recompile it with cuvid / cuda support (as cant find a good guide)
If anyone can share or point me in the right direction that would be great its a tad beyond my skillset.
Appreciate the help
Thanks
Jamie
Apologies, i'm able to get opencv compiled successfully (using dlandon's docker) - nvidia-smi shows up the right driver (440.59) for the build. CUDA 10.2 seems to install ok (although
```nvcc --version``` shows as command not found? Does that mean it failed? Cant find any errors in the logs?
What i really need is some guidance how to remove FFMPEG and recompile it with cuvid / cuda support (as cant find a good guide)
If anyone can share or point me in the right direction that would be great its a tad beyond my skillset.
Appreciate the help
Thanks
Jamie
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Re: Recompile FFMPEG with cuvid & nvcc issue
ok so
does produce the result:
I did find this guide, so will try this (my concern is matching the variables with what Zoneminder uses)
Code: Select all
/usr/local/cuda-10.2/bin/nvcc -V
Code: Select all
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
Recompile ffmpeg
To enable ffmpeg to use the GPU codec provided by CUDA, ffmpeg must be recompiled to enable it to invoke CUDA through dynamic links
First compile and install the nv-codec-headers Library
Enter the / home/local/ffmepg_sources/ffmpeg-3.3.8/directory to re-execute ffmpeg compilation and installationCode: Select all
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git make PREFIX="/home/local/ffmpeg_build" BINDDIR="/home/local/bin" make install PREFIX="/home/local/ffmpeg_build" BINDDIR="/home/local/bin"
Note the difference between the configure command parameter and the previous configure command parameter
Verify InstallationCode: Select all
PATH="/home/local/ffmpeg_sources/bin:$PATH" PKG_CONFIG_PATH="/home/local/ffmpeg_sources/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/home/local/ffmpeg_sources/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I /home/local/ffmpeg_sources/ffmpeg_build/include -I/usr/local/cuda/include" --extra-ldflags="-L /home/local/ffmpeg_sources/ffmpeg_build/lib -L/usr/local/cuda/lib64" --extra-libs=-lpthread --extra-libs=-lm --bindir="$HOME/bin" --enable-gpl --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libfreetype --enable-cuda --enable-cuvid --enable-nvenc --enable-libnpp
After reinstalling ffmpeg, use the ffmpeg-hwaccels command to see the supported hardware acceleration options
Hardware acceleration methods:
cuvid
Re: Recompile FFMPEG with cuvid & nvcc issue
Before you do it, run ffmpeg (your native version) and note all the build options.
-
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Re: Recompile FFMPEG with cuvid & nvcc issue
ah - good call! thanks
cant believe there isnt a script or guide for this? In the Zoneminder docs it just says 'only if you have GPU and FFMPEG is compiled to support'.
my current ffmpeg for posterity:
cant believe there isnt a script or guide for this? In the Zoneminder docs it just says 'only if you have GPU and FFMPEG is compiled to support'.
my current ffmpeg for posterity:
Code: Select all
fmpeg version 4.3.1-0york0~18.04 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Hardware acceleration methods:
vdpau
vaapi
drm
opencl
[code]
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Re: Recompile FFMPEG with cuvid & nvcc issue
ok, i'm clearly not understanding this correctly. recompiling is giving me a bunch of warnings about things not present, despite using the same variables as the existing ffmpeg (would they be located in a different location?)
The docs assume a deep technical knowledge, so are quite useless.
Each time i'm prepping the ffmpeg compile (below) something else isnt found and I have to install it. Definitely cant be right?
i'm assuming based on the dockerfile it was just installed with `apt install ffmpeg` but i would have thought it would have only installed those items available on the system and installed?
The docs assume a deep technical knowledge, so are quite useless.
Each time i'm prepping the ffmpeg compile (below) something else isnt found and I have to install it. Definitely cant be right?
i'm assuming based on the dockerfile it was just installed with `apt install ffmpeg` but i would have thought it would have only installed those items available on the system and installed?
Code: Select all
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 -I/usr/local/cuda/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib -L/usr/local/cuda/lib64" --extra-version='0york0~18.04' --toolchain=hardened --libdir="/usr/lib/x86_64-linux-gnu" --incdir="/usr/include/x86_64-linux-gnu" --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-cuda --enable-cuvid --enable-nvenc --enable-libx264 --enable-shared
[code]
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Re: Recompile FFMPEG with cuvid & nvcc issue
This is absurd
Is there documented anywhere what is needed from the ffmpeg to run default Zoneminder?
Half of these libraries are named differently and there is no consistency whatsoever.
I can't imagine zoneminder is using all these libraries, despite the list output.
Is there documented anywhere what is needed from the ffmpeg to run default Zoneminder?
Half of these libraries are named differently and there is no consistency whatsoever.
I can't imagine zoneminder is using all these libraries, despite the list output.
Re: Recompile FFMPEG with cuvid & nvcc issue
Building packages from source is not for everyone. It's why binary distributions are popular.
Build options (naming) can change across versions. My approach is to at least script the build, so I can tweak and then re-run.
Do you need to bother? Probably not. Try the least options that get you your hardware encoding. You probably want x264. Then try it and also log ffmpeg debug.
Build options (naming) can change across versions. My approach is to at least script the build, so I can tweak and then re-run.
Do you need to bother? Probably not. Try the least options that get you your hardware encoding. You probably want x264. Then try it and also log ffmpeg debug.
-
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Re: Recompile FFMPEG with cuvid & nvcc issue
Thanks, yeah going to have another crack today with a lot less options.
I think a starting point for Zoneminder bare minimum compiling from source would be useful, then I can just add the —enable-cuvid etc.
Certainly been a learning curve (and a steep one)!
I think a starting point for Zoneminder bare minimum compiling from source would be useful, then I can just add the —enable-cuvid etc.
Certainly been a learning curve (and a steep one)!
Re: Recompile FFMPEG with cuvid & nvcc issue
Make sure you use the -j option to speed up the compilation when you have multiple cores.
There are some guides on the FFMPEG site that’ll help.
There are some guides on the FFMPEG site that’ll help.
-
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Re: Recompile FFMPEG with cuvid & nvcc issue
ok this is honestly STILL driving me nuts.
To summarize,
nvcc doesnt seem to be installed
shows
This is preventing me from recompiling ffmpeg.
nvcc however does exist in
I cant believe there isnt a Zoneminder FFMPEG PPA with cuvid & cuda (if I ever get this working, i will try and create one )
To summarize,
nvcc doesnt seem to be installed
Code: Select all
nvcc --version
Code: Select all
nvcc: command not found
nvcc however does exist in
Code: Select all
/usr/local/cuda/bin
Re: Recompile FFMPEG with cuvid & nvcc issue
Sounds like it’s not in your user’s path. Add the path, copy the app or do something hacky like a symlink.
-
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Re: Recompile FFMPEG with cuvid & nvcc issue
you are correct!
ok, problem 1 solved (for now ) on to the real challenge, compiling ffmpeg!
Code: Select all
export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Re: Recompile FFMPEG with cuvid & nvcc issue
ok this is just THE WORST. FFMPEG is a real PITA with dependencies!
So far:
Installs all the dependencies except for the these that need compiling:
Then I need to add the path:
and finally ffmpeg (which is where I get stuck) as it seems to compile ok, but I'm not sure the order I need?
Should I "apt remove ffmpeg" first? then make install?
So far:
Code: Select all
sudo apt-get -y --force-yes install autoconf automake cmake git build-essential libass-dev libfreetype6-dev libgpac-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config wget yasm texi2html zlib1g-dev nasm libx264-dev libx265-dev libnuma-dev \
libvpx-dev libfdk-aac-dev libmp3lame-dev libunistring-dev libaom-dev libopus-dev
Code: Select all
cd ~/ffmepg_sources/
git clone --depth=1 https://github.com/OpenVisualCloud/SVT-AV1
cd SVT-AV1
cd Build
cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
make -j4
sudo make install
cd ~/ffmpeg_sources/
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
make
sudo make install
Code: Select all
export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
Should I "apt remove ffmpeg" first? then make install?
Code: Select all
cd ~/ffmpeg_sources
git clone https://github.com/FFmpeg/FFmpeg -b master
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-version='0york0~18.04' \
--toolchain=hardened \
--libdir=/usr/lib/x86_64-linux-gnu \
--incdir=/usr/include/x86_64-linux-gnu \
--arch=amd64 \
--disable-stripping \
--enable-avresample \
--disable-filter=resample \
--extra-libs="-lpthread -lm" \
--bindir="$HOME/bin" \
--enable-cuda-nvcc \
--enable-cuda \
--enable-cuvid \
--enable-libnpp \
--extra-cflags="-I/usr/local/cuda/include/" \
--extra-ldflags=-L/usr/local/cuda/lib64/ \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-vaapi \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libsvtav1 \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
--enable-nvenc && \
PATH="$HOME/bin:$PATH" make -j$(nproc) && \
make -j$(nproc) install && \
hash -r
Re: Recompile FFMPEG with cuvid & nvcc issue
You can do a remove using your package manager, just to keep it tidy. If you don’t then your make install will overwrite anything, provided you use the exact same paths as your system has for the libraries and the binaries.
The only downside of the apt remove is when you try to install software that contains FFMPEG as a dependency. You might take the view that leaving it installed in apt and then re-running your custom install afterwards is the simpler option. Depends how you use the machine.
The only downside of the apt remove is when you try to install software that contains FFMPEG as a dependency. You might take the view that leaving it installed in apt and then re-running your custom install afterwards is the simpler option. Depends how you use the machine.
-
-
- Posts: 24
- Joined: Mon Jan 06, 2020 3:48 pm
Re: Recompile FFMPEG with cuvid & nvcc issue
welp - still going and no closer (in fact a big loop lol)
went down a gcc-10 rabbit hole
weirdly, cuda doesnt seem to be fully installed (i'm assuming it pulls down a lot more packages from Nvidia)
as despite adding the cuda location to PATH, the FFMPEG ./configure fails and complains about Error: failed checking for nvcc
I've also updated to CUDA 11.1 and driver 455.38 in the hopes that magically made it easier.
I cant believe there isnt an installer/deb for Ubuntu 18.04 with cuvid, or some kind of script where you specify what is needed and it grabs the dependencies or compiles that as well?
This is doing my head in!
went down a gcc-10 rabbit hole
weirdly, cuda doesnt seem to be fully installed (i'm assuming it pulls down a lot more packages from Nvidia)
as despite adding the cuda location to PATH, the FFMPEG ./configure fails and complains about Error: failed checking for nvcc
I've also updated to CUDA 11.1 and driver 455.38 in the hopes that magically made it easier.
I cant believe there isnt an installer/deb for Ubuntu 18.04 with cuvid, or some kind of script where you specify what is needed and it grabs the dependencies or compiles that as well?
This is doing my head in!