Project

General

Profile

Help with transcoding - vaapi: encode: unsupported codec: h264_vaapi and/or profile: (null)

Added by dorin ilut about 4 years ago

hi all,

I have an Ubuntu 20.04 system. I am usually building tvheadend from git. i am encountering issues that I would need your help with in regards to transcoding. I already tried the solutions outlined here https://tvheadend.org/boards/5/topics/42180 and here https://tvheadend.org/boards/4/topics/24116. But still no go :(

for example:

2020-11-12 11:21:46.753 subscription: 004D: "188.60.141.85 [ dorin | Kodi Media Center ]" subscribing on channel "AMC HD", weight: 100, adapter: "HDHomeRun DVB-C Tuner #3 (192.168.1.202)", network: "rcs", mux: "522MHz", provider: "AMC Networks Int CE", service: "AMC HD", profile="dt", hostname="188.60.141.85", username="dorin", client="Kodi Media Center"
2020-11-12 11:21:47.473 transcode: 0001: 01:H264: > Using profile dt
2020-11-12 11:21:47.473 transcode: 0001: 02:MPEG2AUDIO: > Copy
2020-11-12 11:21:47.473 transcode: 0001: 03:MPEG2AUDIO: > Copy
2020-11-12 11:21:47.473 transcode: 0001: 04:DVBSUB: > Copy
2020-11-12 11:21:47.812 libav: AVCodecContext: mmco: unref short failure
2020-11-12 11:21:47.846 libav: AVCodecContext: reference picture missing during reorder
2020-11-12 11:21:47.846 libav: AVCodecContext: Missing reference picture, default is 2147483647
2020-11-12 11:21:47.851 libav: AVCodecContext: mmco: unref short failure
2020-11-12 11:21:47.887 vaapi: encode: unsupported codec: h264_vaapi and/or profile: (null)

in the build section I can see that vaapi is enabled:

Configure arguments:
--build=x86_64-linux-gnu --prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libexecdir=${prefix}/lib/tvheadend --disable-maintainer-mode --disable-dependency-tracking --disable-bintray_cache --enable-vaapi --enable-nvenc --jobs=8

Compiler:
Using C compiler: cc
Using LD flags: -ldvbcsa
Build for arch: x86_64

Binaries:
Using PYTHON: python
Using GZIP: gzip
Using BZIP2: bzip2

Options:
pie yes
ccdebug no
cardclient yes
cwc yes
cccam yes
capmt yes
constcw yes
linuxdvb yes
satip_server yes
satip_client yes
hdhomerun_client yes
hdhomerun_static yes
iptv yes
tsfile yes
dvbscan yes
timeshift yes
trace yes
avahi yes
zlib yes
libav yes
ffmpeg_static yes
libx264 yes
libx264_static yes
libx265 yes
libx265_static yes
libvpx yes
libvpx_static yes
libtheora yes
libtheora_static yes
libvorbis yes
libvorbis_static yes
libfdkaac no
libfdkaac_static no
libopus yes
libopus_static yes
nvenc yes
vaapi yes
mmal no
omx no
inotify yes
epoll yes
pcre no
pcre2 yes
uriparser yes
ccache no
tvhcsa yes
bundle no
pngquant no
kqueue no
dbus_1 yes
android no
gtimer_check no
slow_memoryinfo no
libsystemd_daemon no
pcloud_cache yes
ddci yes
cclang_threadsan no
gperftools no
execinfo yes
mmx yes
sse2 yes
W_unused_result yes
f_stack_protector yes
f_stack_protector_strong yes
f_stack_check yes
f_PIE yes
fdatasync yes
getloadavg yes
atomic32 yes
atomic64 yes
atomic_time_t yes
atomic_ptr yes
bitops64 yes
lockowner yes
qsort_r yes
gmtoff yes
recvmmsg yes
sendmmsg yes
ifnames yes
py_gzip yes
bin_pkg_config yes
bin_xgettext yes
bin_msgmerge yes
bin_gzip yes
bin_bzip2 yes
ssl yes
linuxdvbapi yes
linuxdvb_ca yes
upnp yes
bin_cmake yes
stdcpp yes
libogg_static yes
hwaccels yes
inotify_h yes
inotify_init1 yes
dvbcsa yes
epoll_create1 yes
mpegts yes
mpegts_dvb yes

Packages:
openssl 1.1.1f
zlib 1.2.11
libpcre2-8 10.34
liburiparser 0.9.3
avahi-client 0.7
libva 1.7.0
libva-x11 1.7.0
libva-drm 1.7.0
dbus-1 1.12.16

Installation paths:
Prefix: /usr
Binaries: ${prefix}/bin
Libraries: ${prefix}/lib
Data files: ${prefix}/share
Man pages: /usr/share/man

Attached are print screens for the stream profile and codec profile.

Any guidance would be more than welcomed.


Replies (12)

RE: Help with transcoding - vaapi: encode: unsupported codec: h264_vaapi and/or profile: (null) - Added by dorin ilut about 4 years ago

Hi Saen,

I have a Dell Latitude with a Intel Xeon processor, 32Gb Ram, and two video cards: an Intel HD Graphics P530 and and Nvidia Quadro M1000M. Funny thing is that transcoding works in a docker container that has a much older version of tvheadend. The reasoning for having a docker container and a local install is because I wanted to separate adapters.

dorin@dorin:~$ sudo lshw -C display
*-display
description: 3D controller
product: GM107GLM [Quadro M1000M]
vendor: NVIDIA Corporation
physical id: 0
bus info: pci@0000:01:00.0
version: a2
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list rom
configuration: driver=nvidia latency=0
resources: irq:148 memory:dc000000-dcffffff memory:b0000000-bfffffff memory:c0000000-c1ffffff ioport:e000(size=128) memory:dd000000-dd07ffff
*-display
description: VGA compatible controller
product: HD Graphics P530
vendor: Intel Corporation
physical id: 2
bus info: pci@0000:00:02.0
version: 06
width: 64 bits
clock: 33MHz
capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
configuration: driver=i915 latency=0
resources: irq:146 memory:db000000-dbffffff memory:70000000-7fffffff ioport:f000(size=64) memory:c0000-dffff

RE: Help with transcoding - vaapi: encode: unsupported codec: h264_vaapi and/or profile: (null) - Added by dorin ilut almost 4 years ago

find below:

dorin@dorin:~$ sudo vainfo
[sudo] password for dorin: 
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.6.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 20.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
dorin@dorin:~$ sudo nvidia-smi
Fri Nov 13 07:41:37 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.80.02    Driver Version: 450.80.02    CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Quadro M1000M       Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   25C    P8    N/A /  N/A |    437MiB /  2004MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1221      G   /usr/lib/xorg/Xorg                436MiB |
+-----------------------------------------------------------------------------+

RE: Help with transcoding - vaapi: encode: unsupported codec: h264_vaapi and/or profile: (null) - Added by dorin ilut almost 4 years ago

also as an idea that I do not think there is an issue with the drivers or hardware, but rather something in the build. see below how it looks in the docker container running HTS Tvheadend 4.3-1857~g221c29b40

020-11-13 06:49:29.181 subscription: 00F3: "172.17.0.1 [ dorin | Kodi Media Center ]" subscribing on channel "AMC HD", weight: 100, adapter: "Philips TDA10023 DVB-C #0 : DVB-C #0", network: "digi", mux: "522MHz", provider: "AMC Networks Int CE", service: "AMC HD", profile="dt", hostname="172.17.0.1", username="dorin", client="Kodi Media Center" 
2020-11-13 06:49:29.515 transcode: 0001: 01:H264: ==> Using profile dt
2020-11-13 06:49:29.515 transcode: 0001: 02:MPEG2AUDIO: ==> Copy
2020-11-13 06:49:29.515 transcode: 0001: 03:MPEG2AUDIO: ==> Copy
2020-11-13 06:49:29.515 transcode: 0001: 04:DVBSUB: ==> Copy

RE: Help with transcoding - vaapi: encode: unsupported codec: h264_vaapi and/or profile: (null) - Added by dorin ilut almost 4 years ago

Can't test, as the docker container does not have nvidia configured. here are the config options from the tvheadend in docker container:

Configure arguments:
  --disable-ffmpeg_static --disable-libfdkaac_static --disable-libtheora_static --disable-libopus_static --disable-libvorbis_static --disable-libvpx_static --disable-libx264_static --disable-libx265_static --disable-libfdkaac --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --disable-avahi --disable-dbus_1 --disable-bintray_cache --disable-hdhomerun_static --enable-hdhomerun_client --enable-libav --enable-pngquant --enable-trace --enable-vaapi --infodir=/usr/share/info --localstatedir=/var --mandir=/usr/share/man --prefix=/usr --sysconfdir=/config

Compiler:
  Using C compiler:                        cc
  Using LD flags:                           -lhdhomerun -ldvbcsa
  Build for arch:                          x86_64

Binaries:
  Using PYTHON:                            python
  Using GZIP:                              gzip
  Using BZIP2:                             bzip2

Options:
  pie                                      yes
  ccdebug                                  no
  cardclient                               yes
  cwc                                      yes
  cccam                                    yes
  capmt                                    yes
  constcw                                  yes
  linuxdvb                                 yes
  satip_server                             yes
  satip_client                             yes
  hdhomerun_client                         yes
  hdhomerun_static                         no
  iptv                                     yes
  tsfile                                   yes
  dvbscan                                  yes
  timeshift                                yes
  trace                                    yes
  avahi                                    no
  zlib                                     yes
  libav                                    yes
  ffmpeg_static                            no
  libx264                                  yes
  libx264_static                           no
  libx265                                  yes
  libx265_static                           no
  libvpx                                   yes
  libvpx_static                            no
  libtheora                                yes
  libtheora_static                         no
  libvorbis                                yes
  libvorbis_static                         no
  libfdkaac                                no
  libfdkaac_static                         no
  libopus                                  yes
  libopus_static                           no
  nvenc                                    no
  vaapi                                    yes
  mmal                                     no
  omx                                      no
  inotify                                  yes
  epoll                                    yes
  pcre                                     no
  pcre2                                    yes
  uriparser                                yes
  ccache                                   no
  tvhcsa                                   yes
  bundle                                   no
  pngquant                                 yes
  kqueue                                   no
  dbus_1                                   no
  android                                  no
  gtimer_check                             no
  slow_memoryinfo                          no
  libsystemd_daemon                        no
  pcloud_cache                             yes
  ddci                                     yes
  cclang_threadsan                         no
  gperftools                               no
  mmx                                      yes
  sse2                                     yes
  W_unused_result                          yes
  f_stack_protector                        yes
  f_stack_protector_strong                 yes
  f_stack_check                            yes
  f_PIE                                    yes
  strlcat                                  yes
  strlcpy                                  yes
  fdatasync                                yes
  getloadavg                               yes
  atomic32                                 yes
  atomic64                                 yes
  atomic_time_t                            yes
  atomic_ptr                               yes
  bitops64                                 yes
  stime                                    yes
  gmtoff                                   yes
  recvmmsg                                 yes
  sendmmsg                                 yes
  libiconv                                 yes
  ifnames                                  yes
  py_gzip                                  yes
  bin_pkg_config                           yes
  bin_xgettext                             yes
  bin_msgmerge                             yes
  bin_gzip                                 yes
  bin_bzip2                                yes
  ssl                                      yes
  linuxdvbapi                              yes
  linuxdvb_ca                              yes
  libhdhomerun                             yes
  upnp                                     yes
  hwaccels                                 yes
  inotify_h                                yes
  inotify_init1                            yes
  dvbcsa                                   yes
  epoll_create1                            yes
  mpegts                                   yes
  mpegts_dvb                               yes

Packages:
  openssl                                  1.1.1d
  zlib                                     1.2.11
  libpcre2-8                               10.34
  liburiparser                             0.9.3
  libavfilter                              7.57.100
  libswresample                            3.5.100
  libavresample                            4.0.0
  libswscale                               5.5.100
  libavformat                              58.29.100
  libavcodec                               58.54.100
  libavutil                                56.31.100
  libva                                    1.6.0
  libva-x11                                1.6.0
  libva-drm                                1.6.0

Installation paths:
  Prefix:                                  /usr
  Binaries:                                ${prefix}/bin
  Libraries:                               ${prefix}/lib
  Data files:                              ${prefix}/share
  Man pages:                               /usr/share/man

RE: Help with transcoding - vaapi: encode: unsupported codec: h264_vaapi and/or profile: (null) - Added by dorin ilut almost 4 years ago

Both. so on this system there are two running instances. the one in the docker can tanscode with vaapi. the one that is native cannot.

RE: Help with transcoding - vaapi: encode: unsupported codec: h264_vaapi and/or profile: (null) - Added by dorin ilut almost 4 years ago

it might be. I am only transcoding one channel. therefore don't need too much power. only the possibility of getting the stream down to 2000kbs when i go to uncivilised counties like Germany, where they don't have internet connections.

RE: Help with transcoding - vaapi: encode: unsupported codec: h264_vaapi and/or profile: (null) - Added by dorin ilut almost 4 years ago

Happy to report I finally solved my issue. Now I can transcode using both the Intel GPU (vaapi) and Nvidia using nvenc. I found the ffmpeg build code on Github and I adjusted the code for tvheadend build from saen.

My hardware:
CPU: Intel(R) Xeon(R) CPU E3-1505M
Intel GPU: Intel Corporation HD Graphics P530
Nvidia GPU: Quadro M1000M

Leaving this here for anyone who might find it useful:

To build ffmpeg with vaapi and nvenc

dorin@dorin:~$ cat ffmpeg_build.sh

#!/bin/bash

#This script will compile and install a static ffmpeg build with support for nvenc un ubuntu.
#See the prefix path and compile options if edits are needed to suit your needs.

#install required things from apt
installLibs(){
echo "Installing prerequisites" 
sudo apt-get update
sudo apt-get -y --force-yes install autoconf automake 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 texi2html zlib1g-dev
}

#install CUDA SDK
InstallCUDASDK(){
echo "Installing CUDA and the latest driver repositories from repositories" 
cd ~/ffmpeg_sources
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" 
sudo apt update
sudo apt install -y nvidia-kernel-source-455
sudo apt install -y nvidia-dkms-455
sudo apt install -y nvidia-driver-455
sudo apt install -y cuda-drivers-455
sudo apt install -y cuda-runtime-11-1
sudo apt install -y cuda-11-1
echo 'export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}' >> $HOME/.bashrc
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update && sudo apt-get -y upgrade
}

#Install nvidia SDK
installSDK(){
echo "Installing the nVidia NVENC SDK." 
cd ~/ffmpeg_sources
cd ~/ffmpeg_sources
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
make
sudo make install
}

#Compile nasm
compileNasm(){
echo "Compiling nasm" 
cd ~/ffmpeg_sources
wget http://www.nasm.us/pub/nasm/releasebuilds/2.14rc0/nasm-2.14rc0.tar.gz
tar xzvf nasm-2.14rc0.tar.gz
cd nasm-2.14rc0
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" 
make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
}

#Compile libx264
compileLibX264(){
echo "Compiling libx264" 
get https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.bz2
rm -rf x264-*/ || :
tar xjvf x264-master.tar.bz2
cd x264-master/
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static
PATH="$HOME/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
}

#Compile libfdk-acc
compileLibfdkcc(){
echo "Compiling libfdk-cc" 
sudo apt-get install unzip
cd ~/ffmpeg_sources
wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master
unzip fdk-aac.zip
cd mstorsjo-fdk-aac*
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
}

#Compile libmp3lame
compileLibMP3Lame(){
echo "Compiling libmp3lame" 
sudo apt-get install nasm
cd ~/ffmpeg_sources
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
}

#Compile libopus
compileLibOpus(){
echo "Compiling libopus" 
cd ~/ffmpeg_sources
wget http://downloads.xiph.org/releases/opus/opus-1.2.1.tar.gz
tar xzvf opus-1.2.1.tar.gz
cd opus-1.2.1
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
}

#Compile libvpx
compileLibPvx(){
echo "Compiling libvpx" 
cd ~/ffmpeg_sources
git clone https://chromium.googlesource.com/webm/libvpx
cd libvpx
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --enable-runtime-cpu-detect --enable-vp9 --enable-vp8 \
--enable-postproc --enable-vp9-postproc --enable-multi-res-encoding --enable-webm-io --enable-better-hw-compatibility --enable-vp9-highbitdepth --enable-onthefly-bitpacking --enable-realtime-only \
--cpu=native --as=nasm
PATH="$HOME/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) clean
}

#Compile ffmpeg
compileFfmpeg(){
echo "Compiling ffmpeg" 
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" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --bindir="$HOME/bin" \
  --enable-libnpp \
  --enable-gpl \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-vaapi \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libtheora \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-nonfree \
  --enable-nvenc
PATH="$HOME/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
hash -r
}

#The process
cd ~
mkdir ffmpeg_sources
installLibs
InstallCUDASDK
installSDK
compileNasm
compileLibX264
compileLibfdkcc
compileLibMP3Lame
compileLibOpus
compileLibPvx
compileFfmpeg
echo "Complete!" 

To build tvheadend:

dorin@dorin:~$ cat tvheadend_build.sh

#!/bin/bash
BASE=$(dirname "$0")
(
  if [ -d "$BASE/tvheadend" ]; then
    cd "$BASE/tvheadend" 
    git pull
  else
    cd "$BASE" 
    git clone https://github.com/tvheadend/tvheadend.git tvheadend # --depth=5 (need version tag workaround else 0.0.0 version)
    cd "$BASE/tvheadend" 
  fi
  time AUTOBUILD_CONFIGURE_EXTRA="--disable-ffmpeg_static --disable-libfdkaac_static --disable-libtheora_static --disable-libopus_static --disable-libvorbis_static --disable-libvpx_static --disable-libx264_static --disable-libx265_static --disable-libfdkaac --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --disable-avahi --disable-dbus_1 --disable-bintray_cache --enable-hdhomerun_static --enable-hdhomerun_client --enable-libav --enable-pngquant --enable-trace --enable-vaapi --enable-nvenc" ./Autobuild.sh -j$(nproc)
) | tee "$BASE/build.log" 
    (1-12/12)