Jetson Nano - included ffmpeg package segmentation fault no matter the decoder, no matter the file

Need help with this.

Fresh install of a jetson nano, 2GB developer kit. Latest image. Installed jetpack. Used the instructions found here:

to install the “supported” ffmpeg version.
ffmepg -decoders | grep nvv
shows:

ffmpeg version n4.2.2-15-g6878ea5a44 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
 V..... h264_nvv4l2dec       h264 (nvv4l2dec) (codec h264)
 V..... hevc_nvv4l2dec       hevc (nvv4l2dec) (codec hevc)
 V..... mpeg2_nvv4l2dec      mpeg2 (nvv4l2dec) (codec mpeg2video)
 V..... mpeg4_nvv4l2dec      mpeg4 (nvv4l2dec) (codec mpeg4)
 V..... vp8_nvv4l2dec        vp8 (nvv4l2dec) (codec vp8)
 V..... vp9_nvv4l2dec        vp9 (nvv4l2dec) (codec vp9)

Everything looks peachy, right?

For the life of me, I can’t get ffmpeg to successfully use one of these decoders. Everything segfaults

$ ffmpeg -c:v h264_nvv4l2dec -i Big_Buck_Bunny_1080_10s_30MB.mp4 -f null -
ffmpeg version n4.2.2-15-g6878ea5a44 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Big_Buck_Bunny_1080_10s_30MB.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf57.63.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.00, start: 0.000000, bitrate: 24563 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 24559 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_nvv4l2dec) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Segmentation fault (core dumped)

Proof that it’s not just h264, using a vp8 file:

$ ffmpeg -c:v vp8_nvv4l2dec -i big-buck-bunny_trailer.webm -f null -
ffmpeg version n4.2.2-15-g6878ea5a44 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Input #0, matroska,webm, from 'big-buck-bunny_trailer.webm':
  Metadata:
    encoder         : http://sourceforge.net/projects/yamka
    creation_time   : 2010-05-20T08:21:12.000000Z
  Duration: 00:00:32.48, start: 0.000000, bitrate: 533 kb/s
    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x360, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 278
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 278
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (vp8_nvv4l2dec) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (vorbis (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Segmentation fault (core dumped)

I have tried so many things. This isn’t my first rodeo with ffmpeg, but my first foray into jetson land. What am I missing? Please tell me it’s something simple.

Hi,
For reference, please share your release version( $ head -1 /etc/nv_tegra_release )

$ head -1 /etc/nv_tegra_release
# R32 (release), REVISION: 5.1, GCID: 26202423, BOARD: t210ref, EABI: aarch64, DATE: Fri Feb 19 16:45:52 UTC 2021

Hi,
We try the steps on Batuu and it works well:
Jetson TX2 and FFmpeg - Can't initialize nvrm channel - #5 by DaneLLL

Please check if you can follow/run the steps successfully.

Sure!

$ apt source ffmpeg
Reading package lists... Done
Need to get 9,105 kB of source archives.
Get:1 https://repo.download.nvidia.com/jetson/ffmpeg main/main ffmpeg 7:4.2.2-nvidia (dsc) [592 B]
Get:2 https://repo.download.nvidia.com/jetson/ffmpeg main/main ffmpeg 7:4.2.2-nvidia (tar) [9,104 kB]
Fetched 9,105 kB in 2s (5,971 kB/s)
dpkg-source: info: extracting ffmpeg in ffmpeg-4.2.2
dpkg-source: info: unpacking ffmpeg_4.2.2-nvidia.tar.xz
$ ./configure --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs="-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils" --extra-cflags="-I /usr/src/jetson_multimedia_api/include/"
ERROR: libv4l2 not found using pkg-config

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

To attempt to solve:

$ sudo apt-get install libv4l-dev
The following additional packages will be installed:
  libv4l2rds0
The following NEW packages will be installed:
  libv4l-dev libv4l2rds0
0 upgraded, 2 newly installed, 0 to remove and 157 not upgraded.
Need to get 113 kB of archives.
After this operation, 508 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 libv4l2rds0 arm64 1.14.2-1 [14.8 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 libv4l-dev arm64 1.14.2-1 [98.6 kB]
Fetched 113 kB in 1s (107 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libv4l2rds0:arm64.
(Reading database ... 177164 files and directories currently installed.)
Preparing to unpack .../libv4l2rds0_1.14.2-1_arm64.deb ...
Unpacking libv4l2rds0:arm64 (1.14.2-1) ...
Selecting previously unselected package libv4l-dev:arm64.
Preparing to unpack .../libv4l-dev_1.14.2-1_arm64.deb ...
Unpacking libv4l-dev:arm64 (1.14.2-1) ...
Setting up libv4l2rds0:arm64 (1.14.2-1) ...
Setting up libv4l-dev:arm64 (1.14.2-1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.3) ...

Try configure again:

./configure --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs="-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils" --extra-cflags="-I /usr/src/jetson_multimedia_api/include/"

Completes successfully, notably, though, nvv* is not found in “enabled decoders”.
I do see this, though:

External libraries providing hardware acceleration:
nvv4l2dec               v4l2_m2m

Next step:
make finishes successfully

$ ./ffmpeg -c:v h264_nvv4l2dec -i ../Downloads/Big_Buck_Bunny_1080_10s_30MB.mp4 -f null -
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  WARNING: library configuration mismatch
  avutil      configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avcodec     configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avformat    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avdevice    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avfilter    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  swscale     configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  swresample  configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../Downloads/Big_Buck_Bunny_1080_10s_30MB.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf57.63.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.00, start: 0.000000, bitrate: 24563 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 24559 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_nvv4l2dec) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Segmentation fault (core dumped)

Still segfaulting.

The most concerning step in the process was having to install libv4l-dev, it’s unclear to me why that wasn’t included in either jetpack or why configure couldn’t find that library if it was included

Hi,
Please try

/opt/nvidia/deepstream/deepstream-5.1/samples/streams/sample_720p.mp4

See if it is specific to Big_Buck_Bunny_1080_10s_30MB.mp4. And do you have nvidia-l4t-jetson-multimedia-api installed?

$ ls -alh /opt/nvidia/
total 24K
drwxr-xr-x 6 root root 4.0K Feb 19 21:15 .
drwxr-xr-x 5 root root 4.0K Mar 15 15:43 ..
drwxr-xr-x 6 root root 4.0K Feb 19 20:37 jetson-io
drwxr-xr-x 2 root root 4.0K Feb 19 20:37 l4t-bootloader-config
drwxr-xr-x 2 root root 4.0K Jan 28  2018 l4t-usb-device-mode
drwxr-xr-x 7 root root 4.0K Feb 19 21:15 vpi1

I do not see a deepstream directory in /opt/nvidia/.
Big buck bunny is a common testing file for ffmpeg, but I’ll find another h264 file to try.

Meanwhile, proof that it’s not just h264:

$ ./ffmpeg -c:v vp8_nvv4l2dec -i ../Downloads/big-buck-bunny_trailer.webm -f null -
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  WARNING: library configuration mismatch
  avutil      configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avcodec     configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avformat    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avdevice    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avfilter    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  swscale     configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  swresample  configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Input #0, matroska,webm, from '../Downloads/big-buck-bunny_trailer.webm':
  Metadata:
    encoder         : http://sourceforge.net/projects/yamka
    creation_time   : 2010-05-20T08:21:12.000000Z
  Duration: 00:00:32.48, start: 0.000000, bitrate: 533 kb/s
    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x360, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 278
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 278
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (vp8_nvv4l2dec) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (vorbis (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Segmentation fault (core dumped)

Another h264 test file. Location here:
http://demo.nimius.net/video_test/videos/test.mp4
result:

$ ./ffmpeg -c:v h264_nvv4l2dec -i ../Downloads/test.mp4 -f null -
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  WARNING: library configuration mismatch
  avutil      configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avcodec     configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avformat    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avdevice    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avfilter    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  swscale     configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  swresample  configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../Downloads/test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.41.100
  Duration: 00:00:17.62, start: 0.000000, bitrate: 161 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 137 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 26 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_nvv4l2dec) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Segmentation fault (core dumped)

Finally:

$ sudo apt-get install nvidia-l4t-jetson-multimedia-api
[sudo] password for jed-grip:
Reading package lists... Done
Building dependency tree
Reading state information... Done
nvidia-l4t-jetson-multimedia-api is already the newest version (32.5.1-20210219084526).
0 upgraded, 0 newly installed, 0 to remove and 156 not upgraded.

Feel free to send along files you’d prefer me to test with, but these are valid h264 and vp8 files. I’ve personally tested code against Big Buck Bunny for years. That’s why I go back to it, because I know it’s valid. If a decoder is going to work, it should work against all valid files of that format.

You can see I’m completely stuck here. This is a brand new jetson nano, and a completely fresh install using the image on the official docs. I tried all kinds of things before wiping and starting from a fresh image just to be sure. This should be simple to replicate on actual hardware.

Hi,
We are able to decode test.mp4 on Nano-2GB/r32.5.1:

nvidia@nvidia-desktop:~/ffmpeg/ffmpeg-4.2.2$ wget http://demo.nimius.net/video_test/videos/test.mp4
--2021-03-17 11:51:26--  http://demo.nimius.net/video_test/videos/test.mp4
Resolving demo.nimius.net (demo.nimius.net)... 37.202.4.64
Connecting to demo.nimius.net (demo.nimius.net)|37.202.4.64|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 355284 (347K) [video/mp4]
Saving to: ‘test.mp4’

test.mp4            100%[===================>] 346.96K  95.4KB/s    in 3.6s

2021-03-17 11:51:30 (95.4 KB/s) - ‘test.mp4’ saved [355284/355284]

nvidia@nvidia-desktop:~/ffmpeg/ffmpeg-4.2.2$ ./ffmpeg -c:v h264_nvv4l2dec -i test.mp4 -f null -
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.41.100
  Duration: 00:00:17.62, start: 0.000000, bitrate: 161 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 137 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 26 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_nvv4l2dec) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
    Stream #0:0(und): Video: wrapped_avframe, yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.54.100 wrapped_avframe
    Stream #0:1(und): Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc58.54.100 pcm_s16le
frame=  412 fps=0.0 q=-0.0 Lsize=N/A time=00:00:17.60 bitrate=N/A speed=21.4x   
video:216kB audio:3032kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
nvidia@nvidia-desktop:~/ffmpeg/ffmpeg-4.2.2$

If you don’t execute

nvidia@nvidia-desktop:~/ffmpeg/ffmpeg-4.2.2$ export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:/home/nvidia/ffmpeg/ffmpeg-4.2.2/libavdevice:/home/nvidia/ffmpeg/ffmpeg-4.2.2/libavfilter:/home/nvidia/ffmpeg/ffmpeg-4.2.2/libavformat:/home/nvidia/ffmpeg/ffmpeg-4.2.2/libavcodec:/home/nvidia/ffmpeg/ffmpeg-4.2.2/libavformat:/home/nvidia/ffmpeg/ffmpeg-4.2.2/libswresample:/home/nvidia/ffmpeg/ffmpeg-4.2.2/libswscale:/home/nvidia/ffmpeg/ffmpeg-4.2.2/libavutil:

Do you hit this error?

nvidia@nvidia-desktop:~/ffmpeg/ffmpeg-4.2.2$ ./ffmpeg -c:v h264_nvv4l2dec -i test.mp4 -f null -
./ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory

And what is size of the SD card? We use 128GB card but it should work with 32GB card.

I haven’t seen that error at all.

I am currently using a 16GB card, and while space has been tight, I’ve never considered that it might be causing a segmentation fault, particularly on a 347K file. I can certainly try on a larger card - I will need to pick one up tomorrow.

Notably, the output from your ffmpeg does not show the warnings that mine does:

  WARNING: library configuration mismatch
  avutil      configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avcodec     configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avformat    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avdevice    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  avfilter    configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  swscale     configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  swresample  configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'

On this particular image, I have made a point of only following official doc or help forum guidance in order to ensure I haven’t bunked up a library somewhere. That I’m getting this warning and you’re not means the particular installation must diverge somewhere. It would seem that divergence is the key.

Okay, I’ve had success! Based on that library mismatch warning, I decided to just ls for libraries you were asking me to link in. I quickly realized that my username is not nvidia, and the location of where I was compiling was not ~/ffmpeg/ffmpeg-4.2.2. Changing that particular command export LD_LIBRARY_PATH=... to link in libraries located at ~/<ffmpeg download directory> got me unstuck:

jed-grip@jedgrip:~/ffmpeg-4.2.2$ ./ffmpeg -c:v h264_nvv4l2dec -i ../Downloads/Big_Buck_Bunny_1080_10s_30MB.mp4 -f nul
l -
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../Downloads/Big_Buck_Bunny_1080_10s_30MB.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf57.63.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.00, start: 0.000000, bitrate: 24563 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 24559 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_nvv4l2dec) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    genre           : Animation
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    encoder         : Lavf58.29.100
    Stream #0:0(und): Video: wrapped_avframe, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.54.100 wrapped_avframe
frame=  295 fps=104 q=-0.0 Lsize=N/A time=00:00:09.83 bitrate=N/A speed=3.46x
video:154kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

I will come back and provide a full list of commands to run to get this working for anyone looking in on this in the future

Just writing this down to compile everything I did so that maybe someone else doesn’t have to go chasing down a bunch of different posts:

Start by fetching NVIDIA ffmpeg binaries and source (you’ll need source because we’ll be compiling from scratch, sadly).

echo "deb https://repo.download.nvidia.com/jetson/ffmpeg main main" |  sudo tee -a /etc/apt/sources.list
echo "deb-src https://repo.download.nvidia.com/jetson/ffmpeg main main" |  sudo tee -a /etc/apt/sources.list
sudo apt update
apt source ffmpeg

Next we will need to add libv4l:

sudo apt-get install libv4l-dev

Now, make a cup of coffee and get ready to compile:

./configure --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs="-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils" --extra-cflags="-I /usr/src/jetson_multimedia_api/include/"
make

Finally (and this is crucial), you will need to refer to those recently compiled libraries whenever you’re running ffmpeg. Two options, export them to your LD_LIBRARY_PATH any time you’re running ffmpeg, or copy these into wherever you’re linking libraries in from. Instructions below for the former (using the compilation directory of ~/ffmpeg-4.2.2):

export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:/home/jed-grip/ffmpeg-4.2.2/libavdevice:/home/jed-grip/ffmpeg-4.2.2/libavfilter:/home/jed-grip/ffmpeg-4.2.2/libavformat:/home/jed-grip/ffmpeg-4.2.2/libavcodec:/home/jed-grip/ffmpeg-4.2.2/libavformat:/home/jed-grip/ffmpeg-4.2.2/libswresample:/home/jed-grip/ffmpeg-4.2.2/libswscale:/home/jed-grip/ffmpeg-4.2.2/libavutil:

A good suggestion is to add this to your bash profile in order to always do this :)

I can confirm this problem and solution. This was on Jetson Xavier NX.

The ffmpeg binary install from Nvidia Ubuntu repository just segfaults.

According to gdb, a thread starts executing somewhere in libnvos.so , then eventually crashes in NvxUpdateNvMMBufferToNvMediaVideoSurface in libnvmedia.so. The backtrace seems to contain no parts of ffmpeg source, only Nvidia libraries.

Using apt source to fetch the source package and compiling ffmpeg as instructed in this thread seems to make it work, i.e. decoding VP9 and VP8 works without segfault.

There was no need to use any LD_LIBRARY_PATH. Just do not use --enable-shared to configure ffmpeg build, and it will link the libraries statically into the ffmpeg binary, so there is no danger of using the wrong ffmpeg libraries from the binary package.

1 Like

Hi Juhana.Helovuo/Jedixi,
Thanks for the information. We can observe segment fault when executing downloaded ffmpeg binary. Will check and update. For a quick solution, please download the source code and build it on Jetson platforms.

@Juhana.Helovuo Thank you for confirming the issue and that insight about --enable-shared! It’s much appreciated

I am trying to make ffmpeg with the Nvidia-provided nvv4l2_dec codec work as a library (libavcodec, libavutil, etc.) as it is designed to be used. There were still segmentation fault crashes.

One of the causes seems to be an uninitialized ring buffer index variable in the capture loop. It may randomly work, if the uninitialized memory (stack) happens to contain zero, or some other suitably small number.

Adding initialization and moving the declaration outside of the buffer processing loop (to prevent multiple initialization) worked for me. Please see the patch below:

diff --git a/third_party/ffmpeg/libavcodec/nvv4l2_dec.c b/third_party/ffmpeg/libavcodec/nvv4l2_dec.c
index 086029dd0..2c7748c8b 100644
--- a/third_party/ffmpeg/libavcodec/nvv4l2_dec.c
+++ b/third_party/ffmpeg/libavcodec/nvv4l2_dec.c
@@ -803,8 +803,8 @@ static void *capture_thread(void *arg)
     }
     /* Main Capture loop for DQ and Q. */

+       int buf_index=0;
         while (!ctx->eos) {
-            int buf_index;
             struct v4l2_buffer v4l2_buf;
             struct v4l2_plane planes[MAX_PLANES];
             NvBufferRect src_rect, dest_rect;

And please feel free to incorporate this into upstream sources, if you think it is correct.

The nvv4l2_dec is still crashing after fixing the bug in the previous post.

I am not using the ffmpeg command-line application, but ffmpeg as libraries. The libraries are linked into the Chromium browser.

Trying to invoke the codec from within the browser causes a segmentation fault. If try to debug using chromium’s single-process mode, or in normal (multi-process) mode under gdb, there is no segmentation fault.

Same in list format:

  • Run Chromium with --single-process option, so browser runs within single process. Video decoder works as expected.
  • Use command-line arguments to specify starting renderer processes under gdb debugger. Video decoder works as expected.
  • Start the browser without any special options. As soon as video player within browser tries to start, the renderer process crashes.

The crash occurs within Nvidia libraries. A backtrace of the crash looks like this:

(gdb) backtrace
#0  0x0000007f967195e4 in  ()
    at /usr/lib/aarch64-linux-gnu/tegra/libnvddk_vic.so
#1  0x0000007f96719658 in  ()
    at /usr/lib/aarch64-linux-gnu/tegra/libnvddk_vic.so
#2  0x0000007f967198f8 in NvDdkVicExecuteSync ()
    at /usr/lib/aarch64-linux-gnu/tegra/libnvddk_vic.so
#3  0x0000007f96719bc0 in NvDdkVicExecute ()
    at /usr/lib/aarch64-linux-gnu/tegra/libnvddk_vic.so
#4  0x0000007f9714ced8 in  ()
    at /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_utils.so.1.0.0
#5  0x0000007f9714e4d8 in NvBufferTransform ()
    at /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_utils.so.1.0.0
#6  0x0000007f987667c0 in capture_thread ()
    at ../../third_party/ffmpeg/libavcodec/nvv4l2_dec.c:863
#7  0x0000007f98694088 in start_thread (arg=0x7f889b684f)
    at pthread_create.c:463
#8  0x0000007f97232ffc in thread_start ()
    at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78

so function capture_thread() in nvv4l2_dec.c calls NvBufferTransform. This function takes two file descriptors and a structure NVBufferTransformParams, which is initialized just before the call, AFAIK quite correctly. It is hard to see why these argument values could cause the underling libraries to crash, unless the library state has already been corrupted by a previous bad input. Surely an invalid file descriptor would trigger an error return code rather than crash.

This could be also a memory management bug within the libraries, such as using uninitialized memory. The fact that the crash is not reproduced under debugger would be explained by this.

Debugging the library state is quite hard, since I do not have source codes of the libraries, or even binaries with debug symbols. Are these available by some means? Possibly under NDA?

The call stack continues to some unknown function within libnvddk_vic.so , where the disassembly leading to the crash is

   0x0000007f967195d8:  ldr     x2, [x0, #88]
   0x0000007f967195dc:  add     x3, x2, #0x4
   0x0000007f967195e0:  str     x3, [x0, #88]
=> 0x0000007f967195e4:  str     w1, [x2]
   0x0000007f967195e8:  ret

The faulting instruction is marked by the arrow at the beginning of the line.

I am no expert on ARM64 assembly, but I imagine that in C code that would be equivalent to

x2 is pointer to 32-bit value

x2 = x0->field_88; // load pointer from struct/class field at offset 88
x0->field_88++;    // increment pointer by one
*x2 = w1;          // store through old pointer value, segmentation fault here, so pointer was invalid
return x0;         // could be also return without value

This basic block has several predecessors within the function, so the precise execution path leading to the fault cannot be traced from a core dump only.

What can I do to make this work? Or is it fixable without sources to aforementioned libraries?

Hi,
By default we don’t support hardware decoding in Chromium. Although our implementation is based on v4l2, it is possible some cases are not handled properly and hits certain issue. We will check this feature and evaluate to support it in future release.

Yes, I understand that you do not support hardware decoding in Chromium.
Chromium does not support hardware decoding on Jetson either.

Nevertheless, that is what I am trying to accomplish here, and got it working to a degree, as detailed above.

I am chasing this because our customers are looking into integrating Jetson into their products. Displaying Full HD video @ 30 fps in a browser, while also encoding the same, is a hard requirement. Nvidia hardware seems well capable of doing this, but only with dedicated video accelerator hardware in use. Encoding already works nicely via gstreamer. If the decoding is not doable, then Jetson products are not a valid component choice in this case, and there is no need for support.

As you probably already know, ffmpeg has two modes of use: Either use it as a command-line tool, or as a set of libraries to integrate into your own application. Are both of these modes supposed to work with nvv4l2_dec, or is only the command-line usage supported?

Hello again,

After some debugging, here are some more details on the segmentation fault:

The memory access causing the fault, or instruction str w1, [x2] in the message above is normally accessing a memory region that GDB identifies as “anon_inode:dmabuf”. The specimen I caught had a size of 0x8000 bytes. This piece of code is writing to increasing addresses. Sometimes the address increment between writes is 4 bytes, but sometimes bigger, e.g. 0x12 bytes.

It is still unclear what is the root cause of the crash, and why it does not occur under debugger.

When inspecting the file descriptors given to the call NvBufferTransform that eventually crashes, all of them seemed valid, but strangely, one was missing.

Debug printout from capture plane buffer creation in function query_set_capture:

[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1136
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1137
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1138
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1139
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1140
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1141
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1142
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1143
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1144
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1145
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1146
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1147
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1148
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1149
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1150
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1151
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1152
[vp9_nvv4l2dec @ 0x7e8400c310] Enqueue empty cp buffer = 1153
[vp9_nvv4l2dec @ 0x7e8400c310] Query and set capture successful

Similar printout from calling NvBufferTransform in capture_thread:

[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1137, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1138, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1139, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1140, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1141, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1142, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1143, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1144, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1145, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1146, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1147, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1148, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1149, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1150, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1151, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1152, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1153, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1137, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1138, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1139, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1140, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1141, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1142, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1143, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1144, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1145, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1146, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1147, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1148, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1149, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1150, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1151, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1152, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1153, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1137, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1138, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1139, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1140, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1141, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1142, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1143, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1144, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1145, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1146, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1147, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1148, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1149, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1150, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1151, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1152, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1153, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1137, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1138, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1139, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1140, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1141, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1142, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1143, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1144, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1145, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1146, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1147, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1148, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1149, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1150, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1151, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1152, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1153, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1137, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1138, dst fd = 1135
[vp9_nvv4l2dec @ 0x7e8400c310] NvBufferTransform src fd = 1139, dst fd = 1135
...[repeats like above]...

The suspicious thing here was that the first queued buffer, with file descriptor = 1136, never came out of the decoder. Is this normal behavior?

Hello again,

Some more findings, this time from Valgrind:

Repeating the test conditions list from above:

  • Run Chromium with --single-process option, so browser runs within single process. Video decoder works as expected.
  • Use command-line arguments to specify starting renderer processes under gdb debugger. Video decoder works as expected.
  • Start the browser without any special options. As soon as video player within browser tries to start, the renderer process crashes.

additionally:

  • Use command-line arguments to specify starting renderer processes under valgrind. Video decoder works as expected.

Could this be a race condition or other timing issue? The common thing with gdb and valgrind is that they slow down the execution.

Valgrind has some complaints, but without source, it is nearly impossible to tell if they have any practical consequences:

==20153== Warning: noted but unhandled ioctl 0x4e04 with no size/direction hints
==20153==    This could cause spurious value errors to appear.

There seem to be some Nvidia-specific ioctl calls, with type codes 0x4e, 0x41, 0x43, 0x47, and 0x48. These could confuse Valgrind, as it cannot interpret their arguments. I could not find any kernel headers where these would be declared. Are they available? the source would be necessary to tell Valgrind what these calls mean in terms of memory use.

Overlapping memcpy, but since the source and destination are exactly the same, does not look too dangerous:

==20153==
==20153== Source and destination overlap in memcpy(0xc10b250, 0xc10b250, 208)
==20153==    at 0xA42354C: __GI_memcpy (vg_replace_strmem.c:1052)
==20153==    by 0xC0F4933: v4l2_fd_open (in /usr/lib/aarch64-linux-gnu/tegra/libnvv4l2.so)
==20153==    by 0xC0F4E23: v4l2_open (in /usr/lib/aarch64-linux-gnu/tegra/libnvv4l2.so)

Uninitalized value is used in libnvparser, although this could be a false alarm due to the unknown ioctl calls above:

==20153== Thread 17:
==20153== Conditional jump or move depends on uninitialised value(s)
==20153==    at 0x1C309424: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvparser.so)
==20153==    by 0x1C31FA87: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvparser.so)
==20153==    by 0x1C2AB24F: NvMediaParserParse (in /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so)
==20153==    by 0x16E7377B: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvmmlite_video.so)
==20153==    by 0xC66E627: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvos.so)
==20153==    by 0xAB88087: start_thread (pthread_create.c:463)
==20153==    by 0xC04DFFB: thread_start (clone.S:78)

Uninitialized memory in ioctl calls, but again could be false alarm.

==20153== Thread 22:
==20153== Syscall param ioctl(generic) points to uninitialised byte(s)
==20153==    at 0xC04653C: ioctl (ioctl.S:26)
==20153==    by 0xCABD99B: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvrm_grap
hics.so)
==20153==    by 0xCABA7E3: NvRmStreamFlushFenceFd (in /usr/lib/aarch64-linux-gnu
/tegra/libnvrm_graphics.so)
==20153==    by 0xCABA807: NvRmStreamFlushSync (in /usr/lib/aarch64-linux-gnu/te
gra/libnvrm_graphics.so)
==20153==    by 0xCAFBA9B: NvDdkVicExecuteSync (in /usr/lib/aarch64-linux-gnu/te
gra/libnvddk_vic.so)
==20153==    by 0xCAFBBBF: NvDdkVicExecute (in /usr/lib/aarch64-linux-gnu/tegra/
libnvddk_vic.so)
==20153==    by 0xC0DAED7: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_uti
ls.so.1.0.0)
==20153==    by 0xC0DC4D7: NvBufferTransform (in /usr/lib/aarch64-linux-gnu/tegr
a/libnvbuf_utils.so.1.0.0)
==20153==    by 0xA50E81B: capture_thread (nvv4l2_dec.c:880)
==20153==    by 0xAB88087: start_thread (pthread_create.c:463)
==20153==    by 0xC04DFFB: thread_start (clone.S:78)
==20153==  Address 0x327fee1c is on thread 22's stack
==20153==
==20153== Syscall param ioctl(generic) points to uninitialised byte(s)
==20153==    at 0xC04653C: ioctl (ioctl.S:26)
==20153==    by 0xCABD37B: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvrm_grap
hics.so)
==20153==    by 0xCAFBC37: NvDdkVicExecute (in /usr/lib/aarch64-linux-gnu/tegra/
libnvddk_vic.so)
==20153==    by 0xC0DAED7: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_uti
ls.so.1.0.0)
==20153==    by 0xC0DC4D7: NvBufferTransform (in /usr/lib/aarch64-linux-gnu/tegr
a/libnvbuf_utils.so.1.0.0)
==20153==    by 0xA50E81B: capture_thread (nvv4l2_dec.c:880)
==20153==    by 0xAB88087: start_thread (pthread_create.c:463)
==20153==    by 0xC04DFFB: thread_start (clone.S:78)
==20153==  Address 0x135d75b4 is 4 bytes inside a block of size 4,096 alloc'd
==20153==    at 0xA41B140: malloc (vg_replace_malloc.c:380)
==20153==    by 0xCABD357: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvrm_graphics.so)
==20153==    by 0xCAFBC37: NvDdkVicExecute (in /usr/lib/aarch64-linux-gnu/tegra/libnvddk_vic.so)
==20153==    by 0xC0DAED7: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_utils.so.1.0.0)
==20153==    by 0xC0DC4D7: NvBufferTransform (in /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_utils.so.1.0.0)
==20153==    by 0xA50E81B: capture_thread (nvv4l2_dec.c:880)
==20153==    by 0xAB88087: start_thread (pthread_create.c:463)
==20153==    by 0xC04DFFB: thread_start (clone.S:78)
==20153==

Conditional depends on uninitialized value:

==20153== Conditional jump or move depends on uninitialised value(s)
==20153==    at 0xCABD3D4: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvrm_graphics.so)
==20153==    by 0xCAFBC37: NvDdkVicExecute (in /usr/lib/aarch64-linux-gnu/tegra/libnvddk_vic.so)
==20153==    by 0xC0DAED7: ??? (in /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_utils.so.1.0.0)
==20153==    by 0xC0DC4D7: NvBufferTransform (in /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_utils.so.1.0.0)
==20153==    by 0xA50E81B: capture_thread (nvv4l2_dec.c:880)
==20153==    by 0xAB88087: start_thread (pthread_create.c:463)