Unable to install package ha-av

and again I do not stick to my resolutions :slight_smile:

if someone want to know his ffmpeg version, go to:

https://git.ffmpeg.org/gitweb/ffmpeg.git/blob_plain/e5b5dd6:/RELEASE

and replace the 7 digits with the version number from

ffmpeg -version

ROTFL, me too. Iā€™m actually trying to build ffmpeg from scratch but having some troubles wit zimg and AOM probably because Iā€™m on a aarch64 OS version.

i have only compiled ffmpeg as at the end and disregarded the additions.

Compiling FFmpeg on the Raspberry Pi - Pi My Life Up

donā€™t forget:

ā€“enable-pic
ā€“disable-static
ā€“enable-shared

and when everything is finished to run

ldconfig

1 Like

During compilation of AOM 64 bit i am getting :

[ 31%] Building C object CMakeFiles/aom_av1_encoder.dir/third_party/vector/vector.c.o
[ 31%] Building C object CMakeFiles/aom_av1_encoder.dir/av1/encoder/dwt.c.o
[ 31%] Built target aom_av1_encoder
make: *** [Makefile:149: all] Error 2
pi@raspberrypi4:~/ffmpeg-libraries/aom/aom_build $

using make without -J4 give more details:

/home/pi/ffmpeg-libraries/aom/aom_dsp/arm/sum_neon.h:148:25: error: incompatible types when initializing type ā€˜uint16x8_tā€™ using type ā€˜intā€™
148 | const uint16x8_t a1 = vpaddq_u16(sum[2], sum[3]);

Solved with the hints from @zevele and @00lex! :partying_face:

@Maurizion you probably were fooled, like me, by the fact that we might have a 64bit kernel, but the userland is only 32bit, so all compiles should be done for the 32bit version.

Doing a recap for the newcomers, to fix building of ha-av in HA 2023.6.x on a Core installation on Raspbian OS, you should do only the following part from the aforementioned guide, compiling only ffmpeg with the basic set of libraries (@00lex please correct me if Iā€™m wrong). You should choose the most appropriate Git branch for your scenario altering the --branch release/6.0 option from the git clone command:

sudo apt -y install autoconf automake build-essential cmake doxygen git graphviz imagemagick libasound2-dev libass-dev libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libfreetype6-dev libgmp-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopus-dev librtmp-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev libsnappy-dev libsoxr-dev libssh-dev libssl-dev libtool libv4l-dev libva-dev libvdpau-dev libvo-amrwbenc-dev libvorbis-dev libwebp-dev libx264-dev libx265-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-xfixes0-dev libxcb1-dev libxml2-dev lzma-dev nasm pkg-config python3-dev python3-pip texinfo wget yasm zlib1g-dev libdrm-dev

git clone --branch release/6.0 --depth 1 https://github.com/FFmpeg/FFmpeg.git ~/FFmpeg

cd ~/FFmpeg

./configure \
    --extra-cflags="-I/usr/local/include" \
    --extra-ldflags="-L/usr/local/lib" \
    --extra-libs="-lpthread -lm -latomic" \
    --arch=armel \
    --enable-gmp \
    --enable-gpl \
    --enable-libass \
    --enable-libdrm \
    --enable-libfreetype \
    --enable-libmp3lame \
    --enable-libopencore-amrnb \
    --enable-libopencore-amrwb \
    --enable-libopus \
    --enable-librtmp \
    --enable-libsnappy \
    --enable-libsoxr \
    --enable-libssh \
    --enable-libvorbis \
    --enable-libwebp \
    --enable-libx264 \
    --enable-libx265 \
    --enable-libxml2 \
    --enable-mmal \
    --enable-nonfree \
    --enable-version3 \
    --target-os=linux \
    --enable-pthreads \
    --enable-openssl \
    --enable-hardcoded-tables \
    --enable-pic \
    --disable-static \
    --enable-shared

make -j$(nproc)

sudo make install

sudo ldconfig
20 Likes

I get an error on configure step
ERROR: libfdk_aac not found
I removed line

ā€“enable-libfdk-aac \

from configure command and all done successfully. I donā€™t know if it important.
Also ldconfig should be run with sudo.
After that
pip3.11 install --upgrade ha-av
done successfully.
Thank you for brief instruction!

Another error I got in HA journal

Logger: haffmpeg.core
Source: /srv/homeassistant/lib/python3.11/site-packages/haffmpeg/core.py:139
First occurred: 12:08:06 (1 occurrences)
Last logged: 12:08:06

FFmpeg fails [Errno 2] No such file or directory: '/usr/bin/ffmpeg'

Solved by
sudo cp ~/FFmpeg/ffmpeg /usr/bin/

Right, fdk was an optional lib, Iā€™ll edit the post.

Thanks , compiling 32bit has solved the problem!

1 Like

Thank you, this solved the issue. I was able to upgrade ha-av succesfully now and can install and run HA Core 2023.6.1.

1 Like

I have tried doing this several times now, and I still canā€™t get it right. :frowning: Only one thing is confusing me, and that may be why:

You should choose the most appropriate Git branch for your scenario altering the --branch release/6.0 option from the git clone command:

I have Bullseye fully updated with the latest Python 3.11 should the git clone command in the message work for me then? Thatā€™s about all I can think about that I may have done wrong. When Hass finally starts, it uses a lot of CPU, like 30-40 %. Never seen that before. But if I disable Stream (that was probably the last media related thing that wasnā€™t already disabled), it seems to work much better.

Thank you, exactly what I needed. I use HassOS for home to keep things simple, but setting up a special Pi deployment for my toy hauler and havenā€™t setup a core installation in years.

Reason is simple:

  • AV_FRAME_DATA_SEI_UNREGISTERED has been added with FFmpeg 4.4: avutil: add AV_FRAME_DATA_SEI_UNREGISTERED side data type Ā· FFmpeg/FFmpeg@bc8ab08 Ā· GitHub
  • Debian Bullseye provides FFmpeg 4.3: https://packages.debian.org/bullseye/ffmpeg
  • So either ha-av making use of AV_FRAME_DATA_SEI_UNREGISTERED gets reverted, or it wonā€™t be possible to compile it on any Debian version below Bookworm (and many other distros), unless FFmpeg (the development headers) is compiled as well.

If you are just installing it with pip, which is also what HA core does on first service start, then this is only relevant on 32-bit ARM and RISC-V (and other rare architectures), as PyPI provides pre-compiled wheels for x86 and aarch64: https://pypi.org/project/ha-av/#files

For 32-bit ARM Debian and Raspbian (and some Ubuntu versions where library versions match), piwheels is an alternative. But well, it provides Python 3.7 and 3.9 wheels only, until they decide to add support for Bookworm, and as it builds against respective Debian repo libraries, recent builds fail for exactly the same reason: https://piwheels.org/project/ha-av/

I do understand that going with recent dependencies/features is great, sometimes make certain things much easier, and users using distros which natively ship too old software is not an issue of upstream developers. But it would make the life of many 32-bit ARM users much easier if:

Sorry for the code-formatted links, as new users are restricted to 2 links per post.

2 Likes

Thanks man. Save my life

1 Like

Hello. If these instructions are not working for someone, use 5.1 branch instead of 6.0. ffmpeg has no support for python 3.11 yet or whatever.

1 Like

This is actually the question of few lines patch to define two missing enums for the distros without recent ffmpeg libraries:

--- include/libavcodec/avcodec.pxd.orig    2023-08-26 16:56:22.637714080 +0200
+++ include/libavcodec/avcodec.pxd 2023-08-26 17:29:08.000000000 +0200
@@ -11,6 +11,15 @@

 cdef extern from "libavcodec/avcodec.h" nogil:
+    """
+    // AV_FRAME_DATA_SEI_UNREGISTERED available since version 56.54.100 of libavutil (FFmpeg >= 4.4)
+    #define HAS_AV_FRAME_DATA_SEI_UNREGISTERED  (LIBAVUTIL_VERSION_INT >= 3683940)
+
+    #if !HAS_AV_FRAME_DATA_SEI_UNREGISTERED
+        #define AV_FRAME_DATA_SEI_UNREGISTERED -1
+        #define AV_CODEC_CAP_OTHER_THREADS AV_CODEC_CAP_AUTO_THREADS
+    #endif
+    """

     # custom
     cdef set pyav_get_available_codecs()
1 Like

If one anyway needs to recompile it, why not just compile FFmpeg 5?

  • Those sources compiled during ha-av module installation anyway.

  • it is NOT ā€œjust compile FFmpeg 5ā€. This will require system libraries replacement with the compiled ones, which could broke some other applications. Also ā€œjust compile FFmpeg 5ā€ will require a lot of other dependencies to be installed or upgraded (recompiled).

Ah you mean to patch this in actual ha-av code? I thought it is a comment as explanation, but probably I do not understand how these .pxd files work. Part of it is already there, actually the important part?

Would you mind to open a PR if your extension really restores FFmpeg <4.4 support?

Exactly. And FFmpeg (its libraries) has a whole lot of dependencies, so I would recommend to upgrade the distribution instead (if the patch does not work).