Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile ffmpeg in new l4t 34.1 ubuntu 20.04 #115

Open
aimaicai opened this issue Apr 19, 2022 · 12 comments
Open

Unable to compile ffmpeg in new l4t 34.1 ubuntu 20.04 #115

aimaicai opened this issue Apr 19, 2022 · 12 comments

Comments

@aimaicai
Copy link

Hi, I've recently upgrade my jetson agx to the latest version (ubuntu 20.04 with l4t 34.1). I follow the guide to enable the nvmpi codec for ffmpeg (4.2.2), but it fail on configure:
ERROR: nvmpi not found using pkg-config
The package is present, so i check the configure.log in the ffbuild folder and I get this:
/usr/bin/ld: /usr/local/lib/libnvmpi.so: undefined reference to NvBufSurfaceMap' /usr/bin/ld: /usr/local/lib/libnvmpi.so: undefined reference to NvBufSurfaceFromFd'
/usr/bin/ld: /usr/local/lib/libnvmpi.so: undefined reference to `NvBufSurfaceUnMap'
Have anyone been able to compile ffmpeg with the nvmpi codecs enabled?
Thanks

@russ-go
Copy link

russ-go commented May 4, 2022

From the 34.1 Developer Preview Release Notes:

Buffer management and buffer transform related API based on nvbuf_utils, defined in
nvbuf_utils.h, are deprecated in this release. From Jetson Linux release 34.0.1 EA
forward, NVIDIA recommends using the new API based on nvutils, defined in
nvbufsurface.h and nvbufsurftransform.h.
See the nvbuf_utils to NvUtils Migration Guide for information to facilitate your migration to
the new API.

Likely the case. I'm checking out the migration guide now....
migration guide

I'm not a programmer, but the migration seems pretty straight forward.

@eusoubrasileiro
Copy link

@russ-go I am looking forward for your progress, on the same page as you.

@vladirai
Copy link

Same issue on jetson xavier nx with the latest version (Jetpack 5.0.1, ubuntu 20.04 with l4t 34.1.1). Attaching config.log
config.log
.

@xsacha
Copy link

xsacha commented Jul 19, 2022

Has anyone done this conversion yet? So I don't redo all their work.

@21ramil
Copy link

21ramil commented Sep 20, 2022

@aimaicai I'm wondering how you solved this problem

@xsacha
Copy link

xsacha commented Sep 20, 2022

Apparently nvidia has added hardware jetson decoder support to ffmpeg, 2 years ago, already.
https://forums.developer.nvidia.com/t/hardware-accelerated-video-playback-with-l4t-ffmpeg/154019/7

There's also this fork, which has nvidia's method and this method (for encoding support mainly) + ported to ffmpeg 4.4:
https://github.com/LinusCDE/mad-jetson-ffmpeg

@HTani
Copy link

HTani commented Jan 17, 2023

You can build it by adding "-L/usr/lib/aarch 64 -linux-gnu/tegra-lnvbufsurface" to Libs in jetson-ffmeg/nvmpi.pc.in.

--- nvmpi.pc.in.org 2023-01-13 10:40:43.210327891 +0900
+++ nvmpi.pc.in 2023-01-16 13:16:17.057770034 +0900
@@ -8,5 +8,5 @@
Version: @PROJECT_VERSION@

Requires:
-Libs: -L${libdir} -lnvmpi
+Libs: -L${libdir} -lnvmpi -L/usr/lib/aarch64-linux-gnu/tegra -lnvbufsurface
Cflags: -I${includedir}

It works on ffmpeg-4.2.7, Ubuntu 20.04.04 LTS/Orin (JetPack 5.0.2).

@shunguang
Copy link

shunguang commented Jan 18, 2023

os: ubuntu 20.04 LTS,
jetpack: 5.0.2-b231
ffmpeg git info:
remote.origin.url=git://source.ffmpeg.org/ffmpeg.git
remote.origin.fetch=+refs/heads/release/4.2:refs/remotes/origin/release/4.2
branch.release/4.2.remote=origin
branch.release/4.2.merge=refs/heads/release/4.2

I follow @HTani 's suggestion, but has new errors

----- from ./ffbuild/config.log -----------
BEGIN /tmp/ffconf.lUMlGBb1/test.c
1 #include <nvmpi.h>
2 #include <stdint.h>
3 long check_nvmpi_create_decoder(void) { return (long) nvmpi_create_decoder; }
4 int main(void) { int ret = 0;
5 ret |= ((intptr_t)check_nvmpi_create_decoder) & 0xFFFF;
6 return ret; }
END /tmp/ffconf.lUMlGBb1/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -I/usr/local/cuda-11.4/include -I/usr/local/include -std=c11 -fomit-frame-pointer -fPIC -pthread -I/usr/local/include -c -o /tmp/ffconf.lUMlGBb1/test.o /tmp/ffconf.lUMlGBb1/test.c
gcc -L/usr/local/cuda-11.4/lib64 -L/usr/local/lib -L/usr/lib/aarch64-linux-gnu -Wl,--as-needed -Wl,-z,noexecstack -I/usr/local/include -o /tmp/ffconf.lUMlGBb1/test /tmp/ffconf.lUMlGBb1/test.o
/usr/bin/ld: /tmp/ffconf.lUMlGBb1/test.o: in function check_nvmpi_create_decoder': test.c:(.text+0x0): **undefined reference to nvmpi_create_decoder'**
/usr/bin/ld: test.c:(.text+0x4): undefined reference to `nvmpi_create_decoder'
collect2: error: ld returned 1 exit status
ERROR: nvmpi not found using pkg-config
``
Any suggestions @HTani ? Thanks

@shunguang
Copy link

P.S.:
(1) By the following check, nvmpi_create_decoder is in the lib.
nvidia@ubuntu:/usr/local/lib$ nm /usr/local/lib/libnvmpi.a | grep -w T | grep -E 'nvmpi_create_decoder'
0000000000000d3c T nvmpi_create_decoder
nvidia@ubuntu:/usr/local/lib$ nm /usr/local/lib/libnvmpi.so | grep -w T | grep -E 'nvmpi_create_decoder'
00000000000118e0 T nvmpi_create_decoder

(2) here is my config cmd:
/media/nvidia/pkg/ffmpeg$ ./configure --disable-static --enable-shared --enable-nonfree --enable-libnpp --enable-nvmpi --enable-gpl --disable-opencl --extra-cflags="-I/usr/local/cuda-11.4/include -I/usr/local/include" --extra-ldflags="-L/usr/local/cuda-11.4/lib64 -L/usr/local/lib -L/usr/lib/aarch64-linux-gnu"

@minghaohsu410168
Copy link

You can build it by adding "-L/usr/lib/aarch 64 -linux-gnu/tegra-lnvbufsurface" to Libs in jetson-ffmeg/nvmpi.pc.in.

--- nvmpi.pc.in.org 2023-01-13 10:40:43.210327891 +0900
+++ nvmpi.pc.in 2023-01-16 13:16:17.057770034 +0900
@@ -8,5 +8,5 @@
Version: @PROJECT_VERSION@
Requires:
-Libs: -L${libdir} -lnvmpi
+Libs: -L${libdir} -lnvmpi -L/usr/lib/aarch64-linux-gnu/tegra -lnvbufsurface
Cflags: -I${includedir}

It works on ffmpeg-4.2.7, Ubuntu 20.04.04 LTS/Orin (JetPack 5.0.2).

@HTani It works after I modified nvmpi.pc file. You save my life!! Thank you.

@HTani
Copy link

HTani commented Jan 31, 2023

@shunguang
Have you added the path of the nvmpi.pc file to the environment variable PKG_CONFIG_PATH?

@shunguang
Copy link

shunguang commented Feb 3, 2023

@HTani and @minghaohsu410168 Thanks for your kindly reply. it was a silly mistake when interpreted your following message.

-Libs: -L${libdir} -lnvmpi
+Libs: -L${libdir} -lnvmpi -L/usr/lib/aarch64-linux-gnu/tegra -lnvbufsurface

at here "-Libs" and "+Libs" came from your git diff, notthe contents in your nvmpi.pc.in file. When i changed them as

# Libs: -L${libdir} -lnvmpi
Libs: -L${libdir} -lnvmpi -L/usr/lib/aarch64-linux-gnu/tegra -lnvbufsurface

in my nvmpi.pc.in, it passed. but still have some minor issues. Anyway, here is my build note
https://github.com/shunguang/HowTo/blob/master/how-to-build-ffmpeg-4-jetson.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants