3

I run Ffmpeg in Docker for transcoding purposes. I've been using static builds from John Van Sickle's website for around 5 years now without issues.

We've packaged Ffmpeg with a .NET application to handle the process around using Ffmpeg for transcoding (talking to the database, downloading videos from storage, uploading transcoded videos to storage, etc.) so we run inside a Microsoft base image. We recently updated from .NET 6.0 to .NET 8.0, so our base image updated, and encoding still works, converting to .ts still works, but concatenating video doesn't: Ffmpeg puts out a segmentation fault after outputting the Ffmpeg header.

Here's a Dockerfile that reproduces the issue:

# works
# FROM mcr.microsoft.com/dotnet/sdk:6.0

doesn't work

FROM mcr.microsoft.com/dotnet/sdk:8.0

works

FROM ubuntu:20.04

Install a static ffmpeg build

RUN apt-get update && apt-get install -y xz-utils curl
&& curl https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o ffmpeg.tar.xz
&& mkdir /ffmpeg
&& tar xf ffmpeg.tar.xz -C /ffmpeg
&& mv /ffmpeg/$(ls /ffmpeg)/* /ffmpeg
&& chmod +x /ffmpeg/ffmpeg

Prepare video

RUN curl https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4 -o Bunny.mp4
&& /ffmpeg/ffmpeg -nostdin -i "Bunny.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts "Bunny.ts"

Contact video

ENTRYPOINT ["/bin/bash", "-c", "/ffmpeg/ffmpeg -loglevel debug -nostdin -i "concat:Bunny.ts|Bunny.ts" -c copy -bsf:a aac_adtstoasc Output.mp4 && echo -----"]

Output:

ffmpeg version 7.0.2-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-nostdin' ... matched as option 'stdin' (enable or disable interaction on standard input) with argument 0.
Reading option '-i' ... matched as input url with argument 'concat:Bunny.ts|Bunny.ts'.
Reading option '-c' ... matched as option 'c' (select encoder/decoder ('copy' to copy stream without reencoding)) with argument 'copy'.
Reading option '-bsf:a' ... matched as option 'bsf' (A comma-separated list of bitstream filters) with argument 'aac_adtstoasc'.
Reading option 'Output.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option nostdin (enable or disable interaction on standard input) with argument 0.
Successfully parsed a group of options.
Parsing a group of options: input url concat:Bunny.ts|Bunny.ts.
Successfully parsed a group of options.
Opening an input file: concat:Bunny.ts|Bunny.ts.
[AVFormatContext @ 0x86f6dc0] Opening 'concat:Bunny.ts|Bunny.ts' for reading
[concat @ 0x86f7600] Setting default whitelist 'concat,file,subfile'
[mpegts @ 0x86f6dc0] Format mpegts probed with size=2048 and score=50
/bin/bash: line 1:     8 Segmentation fault 

You can change the base image to see the difference.

What is causing this segmentation fault? It's a static build so it doesn't depend on any outside libraries - I can't really make sense of this. Any help would be very much appreciated.

1 Answers1

1

I don't know why I was using sdk:8.0 in my example and not runtime:8.0, but they both exhibit the same behaviour.

As suggested in the comments, I switched to another flavour of the 8.0 image (runtime:8.0-jammy) and it is now running without the segmentation fault.