0

I'm trying to enable libopenjpeg in ffmpeg 5.1. I have compiled openjpeg from OpenJPEG git repository, and it is installed in the system as per the instructions in Installation Guide. I can verify the installation with "pkg-config" using,

pkg-config --libs --cflags "libopenjp2 >= 2.1.0".

This outputs:

-I/ffmpeg_build/include/openjpeg-2.5 -L/ffmpeg_build/lib -lopenjp2

However, when trying to run ./configure to compile ffmpeg,I get the following error

ERROR: libopenjp2 >= 2.1.0 not found using pkg-config

The ./configure command I'm using is:

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 -L$HOME/ffmpeg_build/lib64" --extra-libs=-lpthread     --extra-libs=-lm --bindir="$HOME/bin" --enable-libfdk_aac  --enable-libfreetype  --enable-libmp3lame  --enable-libopus --enable-libvpx --enable-libx264 --enable-libx265  --enable-nonfree  --enable-openssl        --enable-demuxer=spdif        --enable-decoder=dolby_e        --enable-decoder=ac3     --enable-gpl     --enable-decoder=eac3     --enable-indev=alsa     --enable-outdev=alsa     --enable-libsrt     --enable-nonfree     --enable-openssl     --enable-shared  --enable-libopenjpeg

The ffbuild/config.log output which contain the error shows the following.

gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -I/home/ffmpeg_build/include -I/home/ffmpeg_build/include/openjpeg-2.5 -std=c11 -fomit-frame-pointer -fPIC -pthread -I/home/ffmpeg_build/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -pthread -I/home/ffmpeg_build/include/openjpeg-2.5 -DOPJ_STATIC -L/home/ffmpeg_build/lib -DOPJ_STATIC -c -o /tmp/ffconf.ZnMEl1ya/test.o /tmp/ffconf.ZnMEl1ya/test.c gcc -L/home/ffmpeg_build/lib -L/home/ffmpeg_build/lib64 -Wl,--as-needed -Wl,-z,noexecstack -I/home/ffmpeg_build/include/openjpeg-2.5 -DOPJ_STATIC -L/home/ffmpeg_build/lib -DOPJ_STATIC -o /tmp/ffconf.ZnMEl1ya/test /tmp/ffconf.ZnMEl1ya/test.o -lopenjp2 -lm -lm -lpthread /usr/bin/ld: /tmp/ffconf.ZnMEl1ya/test.o: in function check_opj_version': test.c:(.text+0x3): undefined reference to opj_version' /usr/bin/ld: /tmp/ffconf.ZnMEl1ya/test: hidden symbol `opj_version' isn't defined /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status ERROR: libopenjp2 >= 2.1.0 not found using pkg-config

I'm on Fedora 38, with Linux kernel 6.8.9. How do I get pkg-config in ffmpeg's configure to see the existence of libopenjp2?

1 Answer 1

0

In case anyone runs into this issue again, I thought I'd post my solution here.

  • Compile openjpeg using following cmake settings.

cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:bool=off -DBUILD_STATIC_LIBS:bool=on -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DCMAKE_C_FLAGS=-DOPJ_STATIC -DBUILD_THIRDPARTY:BOOL=ON

  • Configure ffmpeg to statically link libopenjpeg. The configuration command I used is:

PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --extra-libs=-lpthread --extra-libs=-lm --bindir="$HOME/bin" --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264 --enable-nonfree --enable-openssl --enable-demuxer=spdif --enable-decoder=dolby_e --enable-decoder=ac3 --enable-gpl --enable-decoder=eac3 --enable-indev=alsa --enable-outdev=alsa --enable-libsrt --enable-nonfree --enable-openssl --enable-static --disable-shared --enable-libopenjpeg

Here is the command I used to encode a raw yuv file with openjpeg:

./ffmpeg -y -c:v rawvideo -s:v 1920x1080 -pix_fmt yuv422p -i ~/Documents/1080p50_video_raw.yuv -i ~/Documents/1080p50_2ch_audio.wav -map 0:0 -map 1:0 -c:v libopenjpeg -c:a libfdk_aac -ac 2 -ar 48000 -b:a 128k -async 1 ~/Documents/1080p50_2ch_jp2_aac.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.