FFmpeg installation on Raspberry Pi Zero W: Undefined references to __atomic

Viewed 7300

I'm trying to install ffmpeg on my Raspberry Pi Zero W, but I get several error messages.

OS: Raspberry Pi OS (32-bit) Lite (May 2020)

I have executed the following commands:

sudo apt update
sudo apt full-upgrade
sudo apt install git
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree
make -j2
sudo make install

Output of last command:

...
LD      ffmpeg_g
/usr/bin/ld: libavformat/libavformat.a(fifo.o): in function `fifo_init':
/home/pi/FFmpeg/libavformat/fifo.c:519: undefined reference to `__atomic_store_8'
/usr/bin/ld: libavformat/libavformat.a(fifo.o): in function `fifo_write_trailer':
/home/pi/FFmpeg/libavformat/fifo.c:624: undefined reference to `__atomic_fetch_add_8'
/usr/bin/ld: /home/pi/FFmpeg/libavformat/fifo.c:631: undefined reference to `__atomic_store_8'
/usr/bin/ld: libavformat/libavformat.a(fifo.o): in function `fifo_thread_write_packet':
/home/pi/FFmpeg/libavformat/fifo.c:188: undefined reference to `__atomic_fetch_sub_8'
/usr/bin/ld: libavformat/libavformat.a(fifo.o): in function `fifo_consumer_thread':
/home/pi/FFmpeg/libavformat/fifo.c:457: undefined reference to `__atomic_load_8'
/usr/bin/ld: libavformat/libavformat.a(fifo.o): in function `fifo_write_packet':
/home/pi/FFmpeg/libavformat/fifo.c:597: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make: *** [Makefile:114: ffmpeg_g] Error 1

Maybe another package is missing? Do I have to change anything in the config?

3 Answers

Add the following to the ./configure parameters.

--extra-ldflags="-latomic"

So your command becomes:

./configure --extra-ldflags="-latomic" --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree

On arm platforms with the latest version of "something" installed, I've come across several programs (including ffmpeg) that seem to no longer automatically link the atomic library giving you this or a similar error. I haven't had the time to find out exactly what is causing it or why yet.

The above command manually tells the configure script to include atomic when linking.

Trying to enable the Pi's hardware h264 encoding by any chance?

As I don't know the reason of the above behavior, I can confirm that this happens to me too, on Raspberry Pi 3.

I found a workaround, by installing an oldest package by the next commands:

wget -O ffmpeg-4.1.5.tar.bz2 https://ffmpeg.org/releases/ffmpeg-4.1.5.tar.bz2

tar xvjf ffmpeg-4.1.5.tar.bz2

UPDATE: I found some problems with the installation from source, as Pi Zero f.ex the CPU may be hard float, so you should change some flags before compiling.

if you don't mind a version, install the already precompiled packages by:

sudo apt install ffmpeg -y

I was also trying to live stream video to Youtube with a Raspberry Pi Zero W at 1080p. However it would also crash after 2-3 min. My guess was that it couldn't handled it, so I downgraded it to 720p.

I was able to run 720p@30fps/2000Kbps without any problems. I tested it for about 2 hours without dropping any frames or any other issues, pretty stable.

The settings I've used to accomplish that are the following:

v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=4 
    v4l2-ctl --set-ctrl=rotate=180
    v4l2-ctl --overlay=1
    v4l2-ctl -p 30
    v4l2-ctl --set-ctrl=video_bitrate=2000000
    ffmpeg -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -i /dev/zero -f h264 -framerate 30 -i /dev/video0 -vcodec copy -acodec aac -ab 128k -g 60 -f flv -r 30 rtmp://a.rtmp.youtube.com/live2/YOURKEY
Related