Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bogdanw

macrumors 604
Original poster
I know I can get ffmpeg binaries from https://www.osxexperts.net & https://evermeet.cx/ffmpeg/ but I wanted to build static binaries myself.
The instructions provided by both websites, and others, seem overly complicated.
I have the Command Line Tools for Xcode installed, I built & installed pkg-config, and I think I have a working building workflow:

Code:
git clone --branch n8.1 https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --prefix=/usr/local/ --disable-doc --enable-network --disable-shared --enable-static --pkg-config-flags="--static"
make -j 10
sudo make install

The commands
which ffmpeg; ffmpeg -version which ffprobe; ffprobe -version
return
/usr/local/bin/ffmpeg ffmpeg version n8.1 /usr/local/bin/ffprobe ffprobe version n8.1

Encoding using h264_videotoolbox & hevc_videotoolbox works. yt-dlp is successfully using /usr/local/bin/ffmpeg

Am I missing something?

I’ve attached the build log.
 

Attachments

Am I missing something?
Is there something you think you are missing? If they work, then they work, no?
I know I can get ffmpeg binaries from https://www.osxexperts.net & https://evermeet.cx/ffmpeg/ but I wanted to build static binaries myself.
Is there a reason why you don't use MacPorts? Any specific reason why you want static binaries? As I understand, static binaries are mainly useful if you are bundling ffmpeg along with another program.
 
Is there something you think you are missing? If they work, then they work, no?
The ffmpeg binary from osxexperts is 51.6MB, the one I compiled is 22MB and I didn't use "optimize for size"
Both are Mach-O 64-bit executable arm64
Is there a reason why you don't use MacPorts?
For the same reason I don't use Homebrew 🙂
Any specific reason why you want static binaries? As I understand, static binaries are mainly useful if you are bundling ffmpeg along with another program.
Why wouldn’t I want everything in one binary instead of a mess of “library not found”?
 
For the same reason I don't use Homebrew 🙂
I see you changed your link, MacPorts doesn't have the permissions vulnerabilities that Homebrew does. The supply chain vulnerability is a fair reason.
Why wouldn’t I want everything in one binary instead of a mess of “library not found”?
Shared libraries reduce space, multiple binaries can use the same library. It doesn't really matter if ffmpeg is the only thing you're installing, though.
The ffmpeg binary from osxexperts is 51.6MB, the one I compiled is 22MB and I didn't use "optimize for size"
Because you didn't actually make a static binary. I followed your steps exactly, with the exception of setting --prefix=/opt/staticffmpeg/ so that it doesn't overwrite anything else I have.

The directory tree is as follows for said directory: (EDIT: turns out these are unnecessarily copied)
Code:
.
├── bin
│   ├── ffmpeg
│   ├── ffplay
│   └── ffprobe
├── include
│   ├── ...
├── lib
│   ├── libavcodec.a
│   ├── libavdevice.a
│   ├── libavfilter.a
│   ├── libavformat.a
│   ├── libavutil.a
│   ├── libswresample.a
│   ├── libswscale.a
│   └── pkgconfig...
└── share
    └── ffmpeg
        ├── ...

15 directories, 193 files
And my binary sizes line up with yours:
Bash:
staticffmpeg $ du -h bin/*
 21M    bin/ffmpeg
 20M    bin/ffplay
 20M    bin/ffprobe

EDIT: Turns out it does appear to be a static binary, those other libraries are needlessly copied. I think I know what happened, because you are not pulling down external dependencies, like libx265, your binary is significantly smaller. You are using Apple's videotoolbox instead to supply most of your codecs.
If I compare the osxexprts download and the static build:
Bash:
/opt/staticffmpeg/bin/ffmpeg -codecs | grep hevc
 DEV.LS hevc                 H.265 / HEVC (High Efficiency Video Coding) (encoders: hevc_videotoolbox)
~/Downloads/ffmpeg -codecs | grep hevc
 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (encoders: libx265 hevc_videotoolbox libkvazaar)

They are bundling in dependencies.
 
Last edited:
EDIT: Turns out it does appear to be a static binary, those other libraries are needlessly copied. I think I know what happened, because you are not pulling down external dependencies, like libx265, your binary is significantly smaller. You are using Apple's videotoolbox instead to supply most of your codecs.
If I compare the osxexprts download and the static build:
Bash:
/opt/staticffmpeg/bin/ffmpeg -codecs | grep hevc
 DEV.LS hevc                 H.265 / HEVC (High Efficiency Video Coding) (encoders: hevc_videotoolbox)
~/Downloads/ffmpeg -codecs | grep hevc
 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (encoders: libx265 hevc_videotoolbox libkvazaar)

They are bundling in dependencies.
Thank you, that explains the difference.
I'll keep using my version and see if I encounter any issues.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.