Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade ubuntu image to 24.04 (LTS), alpine to 320 and ffmpeg to 7.1 #408

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
af98e79
fix dockerfile template for ubuntu point at correct base 'ubuntu:22.04'
jsheffie Oct 3, 2024
4265cdc
got '7.1-ubuntu' 'docker-images/7.1/ubuntu2404' to build with no 'vul…
jsheffie Oct 4, 2024
077ae5f
notes:
jsheffie Oct 4, 2024
c620353
updates
jsheffie Oct 8, 2024
6acdaa0
update build to support ffmpeg libs for newer versions
jsheffie Oct 8, 2024
3a03055
updates
jsheffie Oct 8, 2024
dea29c8
read_ffmpeg_template_content_based_on_version
jsheffie Oct 8, 2024
3072aa1
code cleanup
jsheffie Oct 8, 2024
d0b4454
renaming function for readibility
jsheffie Oct 8, 2024
25f0f59
clean up to build the latest OS's
jsheffie Oct 10, 2024
e15e9e9
builder updates: ubuntu2404 and alpine320 are working
jsheffie Oct 11, 2024
7bcd805
incremental checkin got 'ubuntu2404' working again
jsheffie Oct 16, 2024
8041199
updates
jsheffie Oct 16, 2024
7527022
updates
jsheffie Oct 16, 2024
174ca6d
incremental
jsheffie Oct 17, 2024
1cf5054
got the ubuntu2404 image going, and down to 200 megs
jsheffie Oct 17, 2024
552d2f5
work in progress
jsheffie Oct 20, 2024
0c65fc6
incremental commit ( working through pre-commit )
jsheffie Oct 21, 2024
51f1527
fixing pre-commit
jsheffie Oct 21, 2024
6a36ea2
image 'ffmpeg-7.1-ubuntu2404' is working again
jsheffie Oct 22, 2024
d3baed4
incremental checkin 'ubuntu2404', 'ubuntu2404-edge' are working and '…
jsheffie Oct 24, 2024
22ceeed
working out alpine320 and alpine scratch
jsheffie Oct 25, 2024
1e8924d
updates to the alpine scratch320 build
jsheffie Oct 25, 2024
9378439
linting
jsheffie Oct 25, 2024
13aec77
getting close
jsheffie Oct 25, 2024
10781bc
working scratch320
jsheffie Oct 26, 2024
1df1c01
fix readme
jsheffie Oct 26, 2024
7f98563
README.md fixes
jsheffie Oct 26, 2024
c81177a
do multi stage build for alpine320
jsheffie Oct 26, 2024
401f7e2
code review cleanup
jsheffie Oct 27, 2024
fe8b066
remove docker-images ( added to .gitignore) there were 167 files to r…
jsheffie Oct 27, 2024
63a968c
reverting docker-images
jsheffie Oct 27, 2024
fd2570b
revert docker-images dir
jsheffie Oct 27, 2024
753c8d5
properly handle building 'ffmpeg-<ver>' and add ffmpeg-5.1 to SKIP_VA…
jsheffie Oct 27, 2024
a0e281c
cleanup readme
jsheffie Oct 27, 2024
dad192d
pre-commit enforced
jrottenberg Oct 28, 2024
171e94e
fixing pre-commit error
jsheffie Oct 28, 2024
7c27d2a
fixing 'alpine320' build
jsheffie Oct 28, 2024
021e38f
fixing 'alpine320' 'install_ffmpeg.sh' for the build
jsheffie Oct 28, 2024
4bc420a
re-add the 'docker-images' files (pre code review feedback)
jsheffie Oct 28, 2024
b84de55
re-sync w/ upstream
jsheffie Oct 29, 2024
92b7cec
added --enable-libharfbuzz
jsheffie Nov 4, 2024
53228e8
take nvidia and scratch builds out for ffmpeg 6.1 (took over an hour …
jsheffie Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
image 'ffmpeg-7.1-ubuntu2404' is working again
  • Loading branch information
jsheffie committed Oct 22, 2024
commit 6a36ea29ddc9e9a6250418026b9de004c95ec68e
61 changes: 61 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,68 @@ docker build -t my-build docker-images/VERSION/
find ffmpeg/ -name Dockerfile | xargs dirname | parallel --no-notice -j 4 --results logs docker build -t {} {}
```

<details><summary>Some detailed examples, of building and running</summary>

If you are not running the amd64 platform, you may need to pass in the --platform flag to build with docker desktop
- 7.1-ubuntu2404

```sh
$ ./update.py; time docker build --no-cache --platform linux/amd64 -t ffmpeg-7.1-ubuntu2404-desktop-build docker-images/7.1/ubuntu2404
$ docker run -it --rm --entrypoint='bash' --platform="linux/amd64" ffmpeg-7.1-ubuntu2404-desktop-build:latest
```

- 7.1-ubuntu2404-edge

```sh
$ ./update.py; time docker build --no-cache --platform linux/amd64 -t ffmpeg-7.1-ubuntu2404-edge-desktop-build docker-images/7.1/ubuntu2404-edge
$ docker run -it --rm --entrypoint='bash' --platform="linux/amd64" ffmpeg-7.1-ubuntu2404-edge-desktop-build:latest
```

- 7.1-nvidia2204 ( the older LTS one )

```sh
$ ./update.py; time docker build --no-cache --platform linux/amd64 -t ffmpeg-7.1-nvidia2204-desktop-build docker-images/7.1/nvidia2204
```

- 7.1-nvidia2404

```sh
$ ./update.py; time docker build --no-cache --platform linux/amd64 -t ffmpeg-7.1-nvidia2404-desktop-build docker-images/7.1/nvidia2404
```
```sh
$ ./update.py; docker build --no-cache --platform linux/amd64 -t ffmpeg-5.1-alpine320-desktop-build docker-images/5.1/alpine320
$ ./update.py; time docker build --no-cache --platform linux/amd64 -t ffmpeg-7.1-scratch320-desktop-build docker-images/7.1/scratch320
$ ./update.py; time docker build --no-cache --platform linux/amd64 -t ffmpeg-6.1-scratch320-desktop-build docker-images/6.1/scratch320
```

</details>

<details><summary>More testing notes</summary>


```
1: simply run the image: which should output the ffmpeg help
`docker run -it --rm --platform="linux/amd64" ffmpeg-7.1-ubuntu2404-desktop-build:latest`

2: now run the image in bash
`docker run -it --rm --entrypoint=bash --platform="linux/amd64" ffmpeg-7.1-ubuntu2404-desktop-build:latest`

In the bash shell, run the following commands
$ ffmpeg
$ ffmpeg -h
$ ldd `which ffmpeg`
$ for i in ogg amr vorbis theora mp3lame opus vpx xvid fdk x264 x265;do echo $i; find /usr/local/ -name *$i*;done
$ ffmpeg -buildconf

3: Convert an avi file to an mp4 file.
`docker run --rm -v $(pwd):$(pwd) -w $(pwd) --platform="linux/amd64" ffmpeg-7.1-ubuntu2404-desktop-build:latest -i drop_video_1.avi outfile/dv_converted.mp4`

4: Convert a asf file to an mp4
`docker run --rm -v $(pwd):$(pwd) -w $(pwd) --platform="linux/amd64" ffmpeg-7.1-ubuntu2404-desktop-build:latest -i MU_2_Discharge_Bottle___Inlet_to_Discharge.asf outfile/mpu2_discharge_bottle_converted.mp4`

```

</details>

# Reviewing

Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ Below is a table that provides examples for the nomenclature:

| image name | OS ver | ffmpeg ver | variant | description
| --- | --- | --- | --- | --- |
| ffmpeg-7.1-ubuntu2404 | 24.04 | 7.1 | [ubuntu](https://releases.ubuntu.com/) | external libraries are installed from os packages, and ffmpeg is built from source. See [Ubunu Compilation Guide](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) for details on this. |
| ffmpeg-7.0-ubuntu2404-edge | 24.04 | 7.0 | [ubuntu](https://releases.ubuntu.com/) | libs and ffmpeg are built from source. See [Ubunu Compilation Guide](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) for details on this. |
| ffmpeg-6.1-vaapi2404 | 24.04 | 6.1 | [ubuntu](https://releases.ubuntu.com/) | like: `ubuntu2404` but enables: [Video Acceleration API (VAAPI)](https://trac.ffmpeg.org/wiki/HWAccelIntro#VAAPI) in ffmpeg |
| ffmpeg-5.1-nvidia2204-edge | 22.04 | 5.1 | [ubuntu](https://releases.ubuntu.com/) | Built w/ [NVIDIA's hardware-accelerated encoding and decoding APIs](https://trac.ffmpeg.org/wiki/HWAccelIntro#CUDANVENCNVDEC) enabled |
| ffmpeg-7.1-alpine320 | 3.20 | 7.1 | [alpine](https://alpinelinux.org/releases/) | vendor libs, but ffmpeg is built from source |
| ffmpeg-7.0-scratch | 3.20 | 7.0 | [alpine](https://alpinelinux.org/releases/) | vendor libs, and ffmpeg are built from source. Also we make the distro as small as possible by not installing any packages in base and striping symbols of installed libs |
| ffmpeg-7.1-ubuntu2404 | 24.04 | 5.x - 7.x | [ubuntu](https://releases.ubuntu.com/) | external libraries are installed from os packages, and ffmpeg is built from source. See [Ubunu Compilation Guide](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) for details on this. |
| ffmpeg-7.0-ubuntu2404-edge | 24.04 | 5.x - 7.x | [ubuntu](https://releases.ubuntu.com/) | libs and ffmpeg are built from source. See [Ubunu Compilation Guide](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) for details on this. |
| ffmpeg-7.0-ubuntu2404-debug | 24.04 | 5.x - 7.x | [ubuntu](https://releases.ubuntu.com/) | Developer only build, disabled when checked in. This will make a large container with all of the source built, if something fails the docker image still builds |
|
| ffmpeg-6.1-vaapi2404 | 24.04 | 5.x - 7.x | [ubuntu](https://releases.ubuntu.com/) | like: `ubuntu2404` but enables: [Video Acceleration API (VAAPI)](https://trac.ffmpeg.org/wiki/HWAccelIntro#VAAPI) in ffmpeg |
| ffmpeg-5.1-nvidia2204-edge | 22.04 | 5.x - 7.x | [ubuntu](https://releases.ubuntu.com/) | Built w/ [NVIDIA's hardware-accelerated encoding and decoding APIs](https://trac.ffmpeg.org/wiki/HWAccelIntro#CUDANVENCNVDEC) enabled |
| ffmpeg-7.1-alpine320 | 3.20 | 5.x - 7.x | [alpine](https://alpinelinux.org/releases/) | vendor libs, but ffmpeg is built from source |
| ffmpeg-7.0-scratch | 3.20 | 5.x - 7.x | [alpine](https://alpinelinux.org/releases/) | vendor libs, and ffmpeg are built from source. Also we make the distro as small as possible by not installing any packages in base and striping symbols of installed libs |

ffmpeg `<version>` can be one of the following: `5.1`, `6.1`, `7.0`, `7.1` with the above table.

Note: I changed the ffmpeg version number in the table above as an example of how this works. Probably best to stick with the latest ffmpeg.
Note: The current versions of ffmpeg supported are anything newer than 3 years old and not exceeded the end-of-life


<details><summary>Here are some additional older builds</summary>
Expand Down
120 changes: 72 additions & 48 deletions build_source.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
#!/usr/bin/env bash

manifestJsonFile="/tmp/workdir/generated_build_manifest.json"
manifestJsonVersionsFile="/tmp/workdir/generated_build_manifest_versions.json"
# Stop execution on any error
# Note: we can override this in the Dockerfile RUN command with an || true.
# this is useful for debugging
set -e

extract_tarball() {
local tarball_name=$1
# grab the extension of the tarball
local extension="${tarball_name##*.}"
# tar extraction args: -z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma
if [ "$extension" == "gz" ]; then
tar -zx --strip-components=1 -f ${tarball_name}
elif [ "$extension" == "bz2" ]; then
tar -jx --strip-components=1 -f ${tarball_name}
elif [ "$extension" == "zx" ]; then
tar -Jx --strip-components=1 -f ${tarball_name}
else
echo "Error while extract_tarball, got an unknown extension: $extension"
fi
}

# read_data_from_manifest() {
# local lib_name=$1
# local data=$(jq -r '.[] | select(.library_name == "'$lib_name'")' $manifestJsonFile)
# local build_dir=$(echo "$data" | jq -r '.build_dir')
# local tarball_name=$(echo "$data" | jq -r '.tarball_name')
# echo "$build_dir $tarball_name"
# }
manifestJsonFile="/tmp/workdir/generated_build_manifest.json"
manifestJsonVersionsFile="/tmp/workdir/generated_build_versions_manifest.json"

######################### Callback build functions #########################
build_libopencore-amr() {
./configure --prefix="${PREFIX}" --enable-shared && \
make && \
Expand All @@ -42,13 +24,9 @@ build_libx264() {
build_libx265() {
cd build/linux && \
sed -i "/-DEXTRA_LIB/ s/$/ -DCMAKE_INSTALL_PREFIX=\${PREFIX}/" multilib.sh && \
sed -i "/^cmake/ s/$/ -DENABLE_CLI=OFF/" multilib.sh && \
sed -i "/^cmake/ s/$/ -DENABLE_CLI=OFF/" multilib.sh
./multilib.sh && \
make -C 8bit install && \
rm -rf ${DIR}
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DENABLE_SHARED=on -DENABLE_PIC=on . && \
make && \
make install
make -C 8bit install
}

build_libogg() {
Expand All @@ -71,7 +49,7 @@ build_libvorbis() {

build_libvpx() {
./configure --prefix="${PREFIX}" --enable-vp8 --enable-vp9 --enable-vp9-highbitdepth --enable-pic --enable-shared \
--disable-debug --disable-examples --disable-docs --disable-install-bins && \
--disable-debug --disable-examples --disable-docs --disable-install-bins && \
make && \
make install
}
Expand All @@ -96,7 +74,7 @@ build_libxvid() {

build_libfdk-aac() {
autoreconf -fiv && \
./configure --prefix="${PREFIX}" --enable-shared --datadir="${DIR}" && \
./configure --prefix="${PREFIX}" --disable-shared && \
make && \
make install
}
Expand Down Expand Up @@ -141,29 +119,38 @@ build_libass() {
}

build_kvazaar() {
./autogen.sh && \
# ./autogen.sh && \
./configure --prefix="${PREFIX}" --disable-static --enable-shared && \
make && \
make install
}

# aom is a git clone ( to get source, so not in the loop using the callback function)
build_aom(){
local dir = "/tmp/aom"
build_aom() {
local data=$(jq -r '.[] | select(.library_name == "aom")' $manifestJsonFile)
local dir=$(echo "$data" | jq -r '.build_dir')
local aom_version=$(jq -r '.["aom"]' $manifestJsonVersionsFile) # Access value with key "aom"
echo "Building aom-${aom_version}"
git clone --branch ${aom_version} --depth 1 https://aomedia.googlesource.com/aom ${dir} ; \
cd ${dir} ; \
mkdir -p ./aom_build ; \
cd ./aom_build ; \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DBUILD_SHARED_LIBS=1 -DENABLE_NASM=on ..; \
if [ -n "$aom_version" ] && [[ "$aom_version" != "null" ]]; then
echo "Building [aom-${aom_version}] in [${dir}]"
else
echo "Error: aom version is empty or unset"
if [[ "$continue_on_build_failure" == false ]]; then
exit 1
fi
fi
version="v${aom_version}"
git clone --branch ${version} --depth 1 https://aomedia.googlesource.com/aom ${dir} && \
cd ${dir} && \
mkdir -p ./aom_build && \
cd ./aom_build && \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DBUILD_SHARED_LIBS=1 -DENABLE_NASM=on .. && \
make && \
make install
}

build_libsvtav1() {
cd Build && \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=OFF ..; \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=OFF .. \
make && \
make install
}
Expand Down Expand Up @@ -214,14 +201,13 @@ build_libzmq() {
./autogen.sh && \
./configure --prefix="${PREFIX}" && \
make && \
make check && \
make install
}

# another special, code clone situation ( actually currently using the tarball build approach )
build_libpng() {
local dir = "/tmp/png"
local libpng_version=$(jq -r '.["libpng"]' $manifestJsonVersionsFile) # Access value with key "libpng"
# local libpng_version=$(jq -r '.["libpng"]' $manifestJsonVersionsFile) # Access value with key "libpng"
# git clone https://git.code.sf.net/p/libpng/code ${dir} -b v${libpng_version} --depth 1 && \
./autogen.sh && \
./configure --prefix="${PREFIX}" && \
Expand Down Expand Up @@ -265,12 +251,33 @@ build_libsrt() {
build_libvmaf() {
mkdir ./libvmaf/build && \
cd ./libvmaf/build && \
meson setup -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=static .. --prefix "${PREFIX}" && \
meson setup -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=static --prefix "${PREFIX}" .. && \
ninja && \
ninja install
}

build_ffmpeg() {
# Here is a list of things that we enable in the ffmpeg build: that are not in the
# track configuration guide: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu#FFmpeg
# --enable-fontconfig
# --enable-libaribb24
# --enable-libbluray
# --enable-libkvazaar
# --enable-libopencore-amrnb
# --enable-libopencore-amrwb
# --enable-libopenjpeg
# --enable-libsrt
# --enable-libtheora
# --enable-libvmaf
# --enable-libwebp
# --enable-libxvid
# --enable-libzimg
# --enable-libzmq
# --enable-openssl
# --enable-postproc
# --enable-small
# --enable-version3

# export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
./configure %%FFMPEG_CONFIG_FLAGS%% && \
make && \
Expand All @@ -280,7 +287,22 @@ build_ffmpeg() {
hash -r && \
cd tools && \
make qt-faststart && cp qt-faststart ${PREFIX}/bin/

}
######################### Helper functions #########################
extract_tarball() {
local tarball_name=$1
# grab the extension of the tarball
local extension="${tarball_name##*.}"
# tar extraction args: -z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma
if [ "$extension" == "gz" ]; then
tar -zx --strip-components=1 -f ${tarball_name}
elif [ "$extension" == "bz2" ]; then
tar -jx --strip-components=1 -f ${tarball_name}
elif [ "$extension" == "zx" ]; then
tar -Jx --strip-components=1 -f ${tarball_name}
else
echo "Error while extract_tarball, got an unknown extension: $extension"
fi
}


Expand All @@ -291,6 +313,7 @@ build_support_libraries() {
lib_name=${libs[$i]}
# handle the clone source case's ( there are only two )
if [ "$lib_name" == "libsvtav1" ]; then
echo "-------------------- Running callback: build_aom --------------------"
echo "Building 'aom' before we build $lib_name"
build_aom
fi
Expand All @@ -304,7 +327,7 @@ build_support_libraries() {
tarball_name=$(echo "$data" | jq -r '.tarball_name')
sha256sum=$(echo "$data" | jq -r '.sha256sum')

echo "Building $lib_name: in [${build_dir}] from [$tarball_name] source"
echo "Building $lib_name: from ${build_dir}/$tarball_name]"
cd $build_dir
extract_tarball $tarball_name
if [ -n "$sha256sum" ] && [[ "$sha256sum" != "null" ]]; then
Expand All @@ -313,6 +336,7 @@ build_support_libraries() {
fi
# make a callback function to build the library
# if anything fails, we will exit with a non-zero status
echo "-------------------- Running callback: build_${lib_name} --------------------"
build_${lib_name} ${build_dir}
done
}
Expand Down
Loading