BtbN / FFmpeg-Builds

MIT License
6.99k stars 958 forks source link

Mac support #294

Closed ffxsam closed 5 months ago

ffxsam commented 10 months ago

I'm opening this as a draft PR for discussion. I know there are a lot of developers on macOS who are interested in custom ffmpeg builds, so I wanted to put this out there.

I tested amd64 & arm64 builds and both worked fine, at least with my particular selection of scripts in scripts.d. Some of them raised exceptions when building, but I don't have time to dig into those at the moment. This needs to be fully tested on Linux. I don't have access to a Linux system, and I was told that running this on a Linux VM may not behave predictably.

A few notes about some of these changes.

bash ./generate.sh "$TARGET" "$VARIANT" "${ADDINS[@]}"`

This was done to avoid using the super dusty /bin/bash on macOS. Doing it this way allows someone to install a newer version of bash via Homebrew and use that instead.

shopt -s nullglob
for STAGE in scripts.d/*.sh scripts.d/*/*.sh; do
    to_df "FROM base AS $(layername "$STAGE")"
    exec_dockerstage_dl "$STAGE"
done
shopt -u nullglob

This was done to handle cases where someone happens to remove all folders in scripts.d, otherwise it would throw an error:

./generate.sh: line 38: scripts.d/*/*.sh: No such file or directory

On line 100 in generate.sh:

for ID in $(ls -1d scripts.d/??-* | sed 's|^.*/\(..\).*|\1|' | sort -u); do

The -s option for sed doesn't exist on Darwin, so I removed it. I did compare the sed results on Mac vs Linux, and the -s flag didn't appear to make a difference as far as I could tell.

If all of this is too hacky and isn't appropriate to merge, I get it, and I'll just keep this fork handy for my own purposes and anyone else who wishes to use it.

MrRickwi commented 7 months ago

Hi, would love to see this merge request to be accepted - I'm using Windows and Linux builds from here, and OS X builds would be great.

MrRickwi commented 7 months ago

Could you explain what has to be done to build FFmpeg/FFprobe 5.1 using this fork of BtbN:master?

BtbN commented 7 months ago

I think you are misunderstanding this PR. It will still only produce Windows and Linux builds, but built on OSX.

MrRickwi commented 7 months ago

You're right - I misunderstood that. I hoped we could get OSX builds of ffmpeg/ffprobe here. Sorry for the inconvinience I caused...

BtbN commented 7 months ago

To build for OSX itself, we'd need a properly working cross compiler, and Apple is doing its utmost to prevent that from happening.

I also would have no way to test anything (beyond compiling itself) without spending way too much money on at least two Apple devices. For that reason I'm also rather conflicted about this PR alone, and still haven't merged or worked on it more. I can't test it at all, and will very likely accidentally break it again soon after merging.

MrRickwi commented 7 months ago

So if there will be a cross compiler, you can add me to the list of people willing to help building and testing an OSX version

ffxsam commented 6 months ago

@MrRickwi What's your specific use case? Any reason just installing it via Homebrew won't work for you?

MrRickwi commented 6 months ago

Use case is to have same version across windows, linux and mac environments, build with exactly same features. And to have statically linked executables in all cases to reduce installation overhead. Nevertheless, currently it's fine to use the brew installed version.

ffxsam commented 6 months ago

@MrRickwi That's actually a great point. Many times, I've been bitten by ffmpeg in production failing because it's a more limited build than the one on my Mac.

ffxsam commented 5 months ago

Moving to #335