Skip to content

Commit

Permalink
Add stand alone job to build FFmpeg binaries (#3455)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #3455

Differential Revision: D47242316

Pulled By: mthrok

fbshipit-source-id: 0eb4bdb0a45fccfe9ff97eaed79db63cd7bfc7d8
  • Loading branch information
mthrok authored and facebook-github-bot committed Jul 5, 2023
1 parent c34a1d6 commit 662f067
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 6 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/ffmpeg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This job is not directly related to regular CI pipeline.
# It is intended to create FFmpeg binaries that we upload on S3,
# which then will be used during all the build process in CI or local.
#
# This job does not include uploading part.
# Upload needs to be done manually, and it should be done only once
# par new major release of FFmepg.
name: FFmpeg Binaries

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # on sunday

jobs:
Linux-LGPL:
strategy:
fail-fast: false
matrix:
ffmpeg_version: ["4.1.8", "5.0.3", "6.0"]
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
job-name: Build LGPL FFmpeg for Linux
upload-artifact: ffmpeg-linux-lgpl
repository: pytorch/audio
script: |
export FFMPEG_VERSION="${{ matrix.ffmpeg_version }}"
export FFMPEG_ROOT="${PWD}/third_party/ffmpeg"
./packaging/ffmpeg/build.sh
cd "${FFMPEG_ROOT}/.."
tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/lib
artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/linux/"
mkdir -p "${artifact_dir}"
mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz"
macOS-LGPL:
strategy:
fail-fast: false
matrix:
ffmpeg_version: ["4.1.8", "5.0.3", "6.0"]
runner: ["macos-m1-12", "macos-12"]
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
with:
job-name: Build LGPL FFmpeg for macOS ("${{ matrix.runner }}")
upload-artifact: ffmpeg-macos-lgpl
repository: pytorch/audio
runner: "${{ matrix.runner }}"
script: |
export FFMPEG_VERSION="${{ matrix.ffmpeg_version }}"
export FFMPEG_ROOT="${PWD}/third_party/ffmpeg"
./packaging/ffmpeg/build.sh
cd "${FFMPEG_ROOT}/.."
tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/lib
artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/macos_$(uname -m)"
mkdir -p "${artifact_dir}"
mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz"
Windows-LGPL:
strategy:
fail-fast: false
matrix:
ffmpeg_version: ["4.1.8", "5.0.3", "6.0"]
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
with:
job-name: Build LGPL FFmpeg for Windows
upload-artifact: ffmpeg-windows-lgpl
repository: pytorch/audio
script: |
export FFMPEG_VERSION="${{ matrix.ffmpeg_version }}"
export FFMPEG_ROOT="${PWD}/third_party/ffmpeg"
./packaging/ffmpeg/build.bat
cd "${FFMPEG_ROOT}/.."
tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/bin
artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/windows"
mkdir -p "${artifact_dir}"
mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz"
32 changes: 26 additions & 6 deletions packaging/ffmpeg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ if [[ "$OSTYPE" == "msys" ]]; then
args="--toolchain=msvc"
fi

archive="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n${FFMPEG_VERSION:-4.1.8}.tar.gz"

build_dir=$(mktemp -d -t ffmpeg-build.XXXXXXXXXX)
cleanup() {
rm -rf "${build_dir}"
Expand All @@ -32,7 +34,7 @@ cd "${build_dir}"
# NOTE:
# When changing the version of FFmpeg, update the README so that the link to the source points
# the same version.
curl -LsS -o ffmpeg.tar.gz https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n4.1.8.tar.gz
curl -LsS -o ffmpeg.tar.gz "${archive}"
tar -xf ffmpeg.tar.gz --strip-components 1
./configure \
--prefix="${prefix}" \
Expand Down Expand Up @@ -72,11 +74,29 @@ ls ${prefix}/*
# macOS: Fix rpath so that the libraries are searched dynamically in user environment.
# In Linux, this is handled by `--enable-rpath` flag.
if [[ "$(uname)" == Darwin ]]; then
avcodec=libavcodec.58
avdevice=libavdevice.58
avfilter=libavfilter.7
avformat=libavformat.58
avutil=libavutil.56
major_ver=${FFMPEG_VERSION:0:1}
if [[ ${major_ver} == 4 ]]; then
avutil=libavutil.56
avcodec=libavcodec.58
avformat=libavformat.58
avdevice=libavdevice.58
avfilter=libavfilter.7
elif [[ ${major_ver} == 5 ]]; then
avutil=libavutil.57
avcodec=libavcodec.59
avformat=libavformat.59
avdevice=libavdevice.59
avfilter=libavfilter.8
elif [[ ${major_ver} == 6 ]]; then
avutil=libavutil.58
avcodec=libavcodec.60
avformat=libavformat.60
avdevice=libavdevice.60
avfilter=libavfilter.9
else
printf "Error: unexpected FFmpeg major version: %s\n" ${major_ver}
exit 1;
fi

otool="/usr/bin/otool"
# NOTE: miniconda has a version of otool and install_name_tool installed and we want
Expand Down

0 comments on commit 662f067

Please sign in to comment.