Skip to content

Commit 0583d8c

Browse files
committed
build: update FFmpeg to 8.1
The submodule moves to n8.1, and the libraries the module loads to the major versions that release carries: avutil 60, avcodec and avformat 62, swresample 6 and swscale 9. FFmpeg 8 removed libpostproc, and with it the configure option that turned it off. Everything else the build enables is still there under the same name. Updating showed that neither the install nor the jar ever lost a library. Rebuilding FFmpeg installed over the earlier release, and the jar's staging directory only ever gained files, so the first build shipped the 7.1.1 libraries beside the new ones. A rebuild now starts from an empty install directory, cleared only when the record of an earlier build of ours shows it is ours to clear, and the staging directory is filled afresh on every build. A test now checks that the loaded FFmpeg is the release the pom pins, and that it is an LGPL build.
1 parent 72e81c1 commit 0583d8c

6 files changed

Lines changed: 94 additions & 20 deletions

File tree

‎webrtc-java-media/pom.xml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<properties>
2020
<!-- The FFmpeg release the third-party/ffmpeg submodule is pinned to. -->
21-
<ffmpeg.version>7.1.1</ffmpeg.version>
21+
<ffmpeg.version>8.1</ffmpeg.version>
2222
<!-- Where the compiled FFmpeg libraries are installed and looked for. A
2323
build reuses an existing install instead of building again, the way
2424
the WebRTC checkout is reused. -->
@@ -72,6 +72,12 @@
7272
<additionalClasspathElements>
7373
<additionalClasspathElement>${project.build.directory}/natives</additionalClasspathElement>
7474
</additionalClasspathElements>
75+
<!-- The release the libraries on that path have to be,
76+
so that a test catches an install left over from an
77+
earlier one. -->
78+
<systemPropertyVariables>
79+
<ffmpeg.version>${ffmpeg.version}</ffmpeg.version>
80+
</systemPropertyVariables>
7581
</configuration>
7682
</plugin>
7783

‎webrtc-java-media/src/main/cpp/CMakeLists.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@ endif()
126126
#
127127
set(NATIVES_DIR "${CMAKE_CURRENT_BINARY_DIR}/../natives")
128128

129+
# The directory is filled afresh on every build, rather than added to: a
130+
# library that is no longer part of the build, such as one of an earlier
131+
# FFmpeg release under its older major version, must not stay in it and end
132+
# up in the jar. The commands below run in the order they are declared.
129133
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
134+
COMMAND ${CMAKE_COMMAND} -E remove_directory "${NATIVES_DIR}"
130135
COMMAND ${CMAKE_COMMAND} -E make_directory "${NATIVES_DIR}"
131136
COMMAND ${CMAKE_COMMAND} -E copy_if_different
132137
"$<TARGET_FILE:${PROJECT_NAME}>" "${NATIVES_DIR}"

‎webrtc-java-media/src/main/cpp/dependencies/ffmpeg/CMakeLists.txt‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ else()
273273
--disable-programs
274274
--disable-avdevice
275275
--disable-avfilter
276-
--disable-postproc
277276
--disable-network
278277
--disable-everything
279278
--disable-autodetect
@@ -412,7 +411,21 @@ else()
412411

413412
# Build out of tree so the submodule working tree stays clean.
414413
set(FFMPEG_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg-build")
415-
file(MAKE_DIRECTORY "${FFMPEG_BUILD_DIR}")
414+
415+
# A rebuild starts from nothing. make install only adds to the install
416+
# directory, so the libraries of an earlier FFmpeg would stay beside the
417+
# new ones, under the older major version in their names, and be packaged
418+
# into the jar with them. The install directory is only cleared when the
419+
# record of an earlier build of ours shows it is ours to clear, since it
420+
# can be pointed anywhere. The build directory always belongs to this
421+
# build, and objects compiled from another release are no use to it.
422+
if(EXISTS "${FFMPEG_COMPONENTS_FILE}")
423+
message(STATUS "Clearing the earlier FFmpeg build in ${FFMPEG_INSTALL_DIR}")
424+
file(REMOVE_RECURSE "${FFMPEG_INSTALL_DIR}")
425+
endif()
426+
427+
file(REMOVE_RECURSE "${FFMPEG_BUILD_DIR}")
428+
file(MAKE_DIRECTORY "${FFMPEG_INSTALL_DIR}" "${FFMPEG_BUILD_DIR}")
416429
to_shell_path("${FFMPEG_BUILD_DIR}" FFMPEG_BUILD_DIR_SH)
417430

418431
string(REPLACE ";" " " FFMPEG_CONFIGURE_ARGS_STR "${FFMPEG_CONFIGURE_ARGS}")

‎webrtc-java-media/src/main/java/dev/onvoid/webrtc/media/player/FFmpeg.java‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private FFmpeg() {
5151

5252
/**
5353
* Returns the FFmpeg version the loaded native library was built against,
54-
* for example {@code 7.1.1}. Useful to confirm which FFmpeg an application
54+
* for example {@code 8.1}. Useful to confirm which FFmpeg an application
5555
* actually ended up with, since the libraries may be replaced.
5656
*
5757
* @return The FFmpeg version string.
@@ -88,29 +88,29 @@ private static String[] dependencies() {
8888

8989
if (osName.startsWith("windows")) {
9090
return new String[] {
91-
"avutil-59.dll",
92-
"swresample-5.dll",
93-
"swscale-8.dll",
94-
"avcodec-61.dll",
95-
"avformat-61.dll"
91+
"avutil-60.dll",
92+
"swresample-6.dll",
93+
"swscale-9.dll",
94+
"avcodec-62.dll",
95+
"avformat-62.dll"
9696
};
9797
}
9898
if (osName.startsWith("mac os")) {
9999
return new String[] {
100-
"libavutil.59.dylib",
101-
"libswresample.5.dylib",
102-
"libswscale.8.dylib",
103-
"libavcodec.61.dylib",
104-
"libavformat.61.dylib"
100+
"libavutil.60.dylib",
101+
"libswresample.6.dylib",
102+
"libswscale.9.dylib",
103+
"libavcodec.62.dylib",
104+
"libavformat.62.dylib"
105105
};
106106
}
107107

108108
return new String[] {
109-
"libavutil.so.59",
110-
"libswresample.so.5",
111-
"libswscale.so.8",
112-
"libavcodec.so.61",
113-
"libavformat.so.61"
109+
"libavutil.so.60",
110+
"libswresample.so.6",
111+
"libswscale.so.9",
112+
"libavcodec.so.62",
113+
"libavformat.so.62"
114114
};
115115
}
116116

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2026 Alex Andres
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package dev.onvoid.webrtc.media.player;
18+
19+
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertNotNull;
21+
import static org.junit.jupiter.api.Assertions.assertTrue;
22+
23+
import org.junit.jupiter.api.Test;
24+
25+
/**
26+
* Tests which FFmpeg the module actually loads.
27+
*
28+
* @author Alex Andres
29+
*/
30+
class FFmpegTest {
31+
32+
@Test
33+
void loadsPinnedRelease() {
34+
// Set by the build from the version the submodule is pinned to.
35+
String expected = System.getProperty("ffmpeg.version");
36+
37+
assertNotNull(expected, "ffmpeg.version is not set");
38+
39+
// A release build names itself after its tag, n<version>.
40+
assertEquals("n" + expected, FFmpeg.version());
41+
}
42+
43+
@Test
44+
void isLgpl() {
45+
// What the module ships under; a GPL or non-free build must not be
46+
// what ended up in the jar.
47+
assertTrue(FFmpeg.license().startsWith("LGPL"), FFmpeg.license());
48+
}
49+
50+
}
Submodule ffmpeg updated 4742 files

0 commit comments

Comments
 (0)