forked from Vargol/ffmpeg-apple-arm64-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Burnett
authored and
David Burnett
committed
May 8, 2021
0 parents
commit 50cf4d0
Showing
19 changed files
with
6,166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# FFmpeg | ||
This script is made to compile FFmpeg with common codecs on Linux and Mac OSX. | ||
|
||
## Result | ||
This repository builds FFmpeg and FFprobe for Mac OSX and Linux using | ||
- build tools | ||
- [cmake](https://cmake.org/) | ||
- [nasm](http://www.nasm.us/) | ||
- [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) | ||
- video codecs | ||
- [aom](https://aomedia.org/) for AV1 de-/encoding | ||
- [openh264](https://www.openh264.org/) for H.264 de-/encoding | ||
- [x264](http://www.videolan.org/developers/x264.html) for H.264 encoding | ||
- [x265](http://x265.org/) for H.265/HEVC encoding | ||
- [vpx](https://www.webmproject.org/) for VP8/VP9 de-/encoding | ||
- audio codecs | ||
- [LAME](http://lame.sourceforge.net/) for MP3 encoding | ||
- [opus](https://opus-codec.org/) for Opus de-/encoding | ||
|
||
To get a full list of all formats and codecs that are supported just execute | ||
``` | ||
./ffmpeg -formats | ||
./ffmpeg -codecs | ||
``` | ||
|
||
## Requirements | ||
There are just a few dependencies to other tools. Most of the software is compiled or downloaded during script execution. Also most of the tools should be already available on the system by default. | ||
|
||
### Required | ||
- c and c++ compiler like AppleClang (included in Xcode) or gcc (on Linux) | ||
- curl for downloading files | ||
- make | ||
|
||
### Optional | ||
- nproc (on linux) or sysctl (on Mac OSX) for multicore compilation | ||
|
||
## Execution | ||
To run this script simply execute the build.sh script. | ||
``` | ||
./build.sh | ||
``` | ||
|
||
## Folder Structure | ||
All files that are downloaded and generated through this script are placed in the current working directory. The recommendation is to use an empty folder for this. | ||
``` | ||
mkdir ffmpeg-compile | ||
cd ffmpeg-compile | ||
``` | ||
|
||
Now execute the script using: | ||
``` | ||
../path/to/repository/build.sh | ||
``` | ||
|
||
After the execution a new folder called "out" exists. It contains the compiled FFmpeg binary (in the bin sub-folder). | ||
The ffmpeg-success.zip contains also all binary files of FFmpeg. | ||
|
||
## Build failed? | ||
Check the detailed logfiles in the working directory. Each build step has its own file starting with "build-*". | ||
|
||
If the build of ffmpeg failes during the configuration phase (e.g. because it doesn't find one codec) check also the log file in ffmpeg/ffmpeg-*/ffbuild/config.log. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/bin/sh | ||
|
||
# get rid of macports - libiconv | ||
echo $PATH | ||
export PATH=`echo $PATH | sed 's/:/\n/g' | grep -v '/opt/local' | xargs | tr ' ' ':'` | ||
echo $PATH | ||
|
||
# some folder names | ||
BASE_DIR="$( cd "$( dirname "$0" )" > /dev/null 2>&1 && pwd )" | ||
echo "base directory is ${BASE_DIR}" | ||
SCRIPT_DIR="${BASE_DIR}/build" | ||
echo "script directory is ${SCRIPT_DIR}" | ||
TEST_DIR="${BASE_DIR}/test" | ||
echo "test directory is ${TEST_DIR}" | ||
WORKING_DIR="$( pwd )" | ||
echo "working directory is ${WORKING_DIR}" | ||
TOOL_DIR="$WORKING_DIR/tool" | ||
echo "tool directory is ${TOOL_DIR}" | ||
OUT_DIR="$WORKING_DIR/out" | ||
echo "output directory is ${OUT_DIR}" | ||
|
||
# load functions | ||
. $SCRIPT_DIR/functions.sh | ||
|
||
# prepare workspace | ||
echoSection "prepare workspace" | ||
mkdir "$TOOL_DIR" | ||
checkStatus $? "unable to create tool directory" | ||
PATH="$TOOL_DIR/bin:$PATH" | ||
mkdir "$OUT_DIR" | ||
checkStatus $? "unable to create output directory" | ||
|
||
# detect CPU threads (nproc for linux, sysctl for osx) | ||
CPUS=1 | ||
CPUS_NPROC="$(nproc 2> /dev/null)" | ||
if [ $? -eq 0 ] | ||
then | ||
CPUS=$CPUS_NPROC | ||
else | ||
CPUS_SYSCTL="$(sysctl -n hw.ncpu 2> /dev/null)" | ||
if [ $? -eq 0 ] | ||
then | ||
CPUS=$CPUS_SYSCTL | ||
fi | ||
fi | ||
|
||
echo "use ${CPUS} cpu threads" | ||
COMPILATION_START_TIME=$(currentTimeInSeconds) | ||
|
||
# start build | ||
#START_TIME=$(currentTimeInSeconds) | ||
#echoSection "compile nasm" | ||
#$SCRIPT_DIR/build-nasm.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "2.14.02" > "$WORKING_DIR/build-nasm.log" 2>&1 | ||
#checkStatus $? "build nasm" | ||
#echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile cmake" | ||
$SCRIPT_DIR/build-cmake.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "3.19" "3.19.1" > "$WORKING_DIR/build-cmake.log" 2>&1 | ||
checkStatus $? "build cmake" | ||
echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile pkg-config" | ||
$SCRIPT_DIR/build-pkg-config.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "0.29.2" > "$WORKING_DIR/build-pkg-config.log" 2>&1 | ||
checkStatus $? "build pkg-config" | ||
echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile aom" | ||
$SCRIPT_DIR/build-aom.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "2.0.0" > "$WORKING_DIR/build-aom.log" 2>&1 | ||
checkStatus $? "build aom" | ||
echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile openh264" | ||
$SCRIPT_DIR/build-openh264.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "2.1.1" > "$WORKING_DIR/build-openh264.log" 2>&1 | ||
checkStatus $? "build openh264" | ||
echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile x264" | ||
$SCRIPT_DIR/build-x264.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" > "$WORKING_DIR/build-x264.log" 2>&1 | ||
checkStatus $? "build x264" | ||
echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile x265" | ||
$SCRIPT_DIR/build-x265.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "3.4" > "$WORKING_DIR/build-x265.log" 2>&1 | ||
checkStatus $? "build x265" | ||
echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile vpx" | ||
$SCRIPT_DIR/build-vpx.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "1.9.0" > "$WORKING_DIR/build-vpx.log" 2>&1 | ||
checkStatus $? "build vpx" | ||
echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile lame (mp3)" | ||
$SCRIPT_DIR/build-lame.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "3.100" > "$WORKING_DIR/build-lame.log" 2>&1 | ||
checkStatus $? "build lame" | ||
echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile opus" | ||
$SCRIPT_DIR/build-opus.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "1.3.1" > "$WORKING_DIR/build-opus.log" 2>&1 | ||
checkStatus $? "build opus" | ||
echoDurationInSections $START_TIME | ||
|
||
START_TIME=$(currentTimeInSeconds) | ||
echoSection "compile ffmpeg" | ||
$SCRIPT_DIR/build-ffmpeg.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$OUT_DIR" "$CPUS" "4.4" > "$WORKING_DIR/build-ffmpeg.log" 2>&1 | ||
checkStatus $? "build ffmpeg" | ||
echoDurationInSections $START_TIME | ||
|
||
echo "compilation finished successfully" | ||
echoDurationInSections $COMPILATION_START_TIME | ||
|
||
echoSection "bundle result" | ||
cd "$OUT_DIR/bin/" | ||
checkStatus $? "change directory" | ||
zip -9 -r "$WORKING_DIR/ffmpeg-success.zip" * | ||
|
||
echoSection "run tests" | ||
$TEST_DIR/test.sh "$SCRIPT_DIR" "$TEST_DIR" "$WORKING_DIR" "$OUT_DIR" > "$WORKING_DIR/test.log" 2>&1 | ||
checkStatus $? "test" | ||
echo "tests executed successfully" |
Oops, something went wrong.