Skip to content

Commit 662f067

Browse files
mthrokfacebook-github-bot
authored andcommitted
Add stand alone job to build FFmpeg binaries (#3455)
Summary: Pull Request resolved: #3455 Differential Revision: D47242316 Pulled By: mthrok fbshipit-source-id: 0eb4bdb0a45fccfe9ff97eaed79db63cd7bfc7d8
1 parent c34a1d6 commit 662f067

File tree

2 files changed

+108
-6
lines changed

2 files changed

+108
-6
lines changed

.github/workflows/ffmpeg.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# This job is not directly related to regular CI pipeline.
2+
# It is intended to create FFmpeg binaries that we upload on S3,
3+
# which then will be used during all the build process in CI or local.
4+
#
5+
# This job does not include uploading part.
6+
# Upload needs to be done manually, and it should be done only once
7+
# par new major release of FFmepg.
8+
name: FFmpeg Binaries
9+
10+
on:
11+
workflow_dispatch:
12+
schedule:
13+
- cron: '0 0 * * 0' # on sunday
14+
15+
jobs:
16+
Linux-LGPL:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
ffmpeg_version: ["4.1.8", "5.0.3", "6.0"]
21+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
22+
with:
23+
job-name: Build LGPL FFmpeg for Linux
24+
upload-artifact: ffmpeg-linux-lgpl
25+
repository: pytorch/audio
26+
script: |
27+
export FFMPEG_VERSION="${{ matrix.ffmpeg_version }}"
28+
export FFMPEG_ROOT="${PWD}/third_party/ffmpeg"
29+
./packaging/ffmpeg/build.sh
30+
31+
cd "${FFMPEG_ROOT}/.."
32+
tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/lib
33+
34+
artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/linux/"
35+
mkdir -p "${artifact_dir}"
36+
mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz"
37+
38+
macOS-LGPL:
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
ffmpeg_version: ["4.1.8", "5.0.3", "6.0"]
43+
runner: ["macos-m1-12", "macos-12"]
44+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
45+
with:
46+
job-name: Build LGPL FFmpeg for macOS ("${{ matrix.runner }}")
47+
upload-artifact: ffmpeg-macos-lgpl
48+
repository: pytorch/audio
49+
runner: "${{ matrix.runner }}"
50+
script: |
51+
export FFMPEG_VERSION="${{ matrix.ffmpeg_version }}"
52+
export FFMPEG_ROOT="${PWD}/third_party/ffmpeg"
53+
./packaging/ffmpeg/build.sh
54+
55+
cd "${FFMPEG_ROOT}/.."
56+
tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/lib
57+
58+
artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/macos_$(uname -m)"
59+
mkdir -p "${artifact_dir}"
60+
mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz"
61+
62+
Windows-LGPL:
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
ffmpeg_version: ["4.1.8", "5.0.3", "6.0"]
67+
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
68+
with:
69+
job-name: Build LGPL FFmpeg for Windows
70+
upload-artifact: ffmpeg-windows-lgpl
71+
repository: pytorch/audio
72+
script: |
73+
export FFMPEG_VERSION="${{ matrix.ffmpeg_version }}"
74+
export FFMPEG_ROOT="${PWD}/third_party/ffmpeg"
75+
./packaging/ffmpeg/build.bat
76+
77+
cd "${FFMPEG_ROOT}/.."
78+
tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/bin
79+
80+
artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/windows"
81+
mkdir -p "${artifact_dir}"
82+
mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz"

packaging/ffmpeg/build.sh

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ if [[ "$OSTYPE" == "msys" ]]; then
2121
args="--toolchain=msvc"
2222
fi
2323

24+
archive="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n${FFMPEG_VERSION:-4.1.8}.tar.gz"
25+
2426
build_dir=$(mktemp -d -t ffmpeg-build.XXXXXXXXXX)
2527
cleanup() {
2628
rm -rf "${build_dir}"
@@ -32,7 +34,7 @@ cd "${build_dir}"
3234
# NOTE:
3335
# When changing the version of FFmpeg, update the README so that the link to the source points
3436
# the same version.
35-
curl -LsS -o ffmpeg.tar.gz https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n4.1.8.tar.gz
37+
curl -LsS -o ffmpeg.tar.gz "${archive}"
3638
tar -xf ffmpeg.tar.gz --strip-components 1
3739
./configure \
3840
--prefix="${prefix}" \
@@ -72,11 +74,29 @@ ls ${prefix}/*
7274
# macOS: Fix rpath so that the libraries are searched dynamically in user environment.
7375
# In Linux, this is handled by `--enable-rpath` flag.
7476
if [[ "$(uname)" == Darwin ]]; then
75-
avcodec=libavcodec.58
76-
avdevice=libavdevice.58
77-
avfilter=libavfilter.7
78-
avformat=libavformat.58
79-
avutil=libavutil.56
77+
major_ver=${FFMPEG_VERSION:0:1}
78+
if [[ ${major_ver} == 4 ]]; then
79+
avutil=libavutil.56
80+
avcodec=libavcodec.58
81+
avformat=libavformat.58
82+
avdevice=libavdevice.58
83+
avfilter=libavfilter.7
84+
elif [[ ${major_ver} == 5 ]]; then
85+
avutil=libavutil.57
86+
avcodec=libavcodec.59
87+
avformat=libavformat.59
88+
avdevice=libavdevice.59
89+
avfilter=libavfilter.8
90+
elif [[ ${major_ver} == 6 ]]; then
91+
avutil=libavutil.58
92+
avcodec=libavcodec.60
93+
avformat=libavformat.60
94+
avdevice=libavdevice.60
95+
avfilter=libavfilter.9
96+
else
97+
printf "Error: unexpected FFmpeg major version: %s\n" ${major_ver}
98+
exit 1;
99+
fi
80100

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

0 commit comments

Comments
 (0)