From 2ecf00d7733c473358b652c50b83cb95f65174ff Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Thu, 23 Feb 2023 22:18:39 +0100
Subject: FFMPEGMediaPlayer: Add implementation update for FFmpeg version 4.*
(Debian 11), 5.* (Debian 12) and 6.* (Current Development trunk)
From here on, libav support has been dropped.
Required FFmpeg libraries to be fully matched by their major runtime- and compiletime-versions are:
- avcodec
- avformat
- avutil
- swresample
Library avdevice is optional and only used for video input devices (camera).
Library avresample has been removed, since FFmpeg dropped it as well in version 6.*
and swresample is preferred for lower versions.
The matching major-versions of each library to the FFmpeg version
is documented within FFMPEGMediaPlayer class API-doc.
Each implementation version uses the non-deprecated FFmpeg code-path
and compilation using matching header files is warning-free.
---
.../opengl/util/av/impl/FFMPEGMediaPlayer.java | 110 +++++++++------------
1 file changed, 44 insertions(+), 66 deletions(-)
(limited to 'src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java')
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
index 6e44dcc37..c1a7eceda 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -56,16 +56,12 @@ import jogamp.opengl.util.av.GLMediaPlayerImpl;
import jogamp.opengl.util.av.VideoPixelFormat;
/***
- * Implementation utilizes Libav
- * or FFmpeg which are ubiquitous
+ * Implementation utilizes FFmpeg which is ubiquitous
* available and usually pre-installed on Unix platforms.
*
- * Due to legal reasons we cannot deploy binaries of it, which contains patented codecs.
- *
- *
* Besides the default BSD/Linux/.. repositories and installations,
* precompiled binaries can be found at the
- * listed location below.
+ * listed location below.
*
*
* Implementation specifics
@@ -90,29 +86,26 @@ import jogamp.opengl.util.av.VideoPixelFormat;
*
*
*
- * Libav Specifics
+ * FFmpeg Specifics
*
- * Utilizes a slim dynamic and native binding to the Lib_av
- * libraries:
+ * Utilizes a slim dynamic and native binding to the FFmpeg libraries:
*
- * - libavcodec
- * - libavformat
- * - libavutil
- * - libavresample (opt)
- * - libavdevice (opt)
+ * - avcodec
+ * - avformat
+ * - avutil
+ * - avdevice (optional for video input devices)
+ * - swresample
*
*
*
- * LibAV Compatibility
+ * FFmpeg Compatibility
*
- * Currently we are binary compatible w/:
+ * Currently we are binary compatible with the following major versions:
*
- * libav / ffmpeg | lavc | lavf | lavu | lavr/lswr | FFMPEG* class |
- * 0.8 | 53 | 53 | 51 | | FFMPEGv08 |
- * 9.0 / 1.2 | 54 | 54 | 52 | 01/00 | FFMPEGv09 |
- * 10 / 2.[0-3] | 55 | 55 | 53/52 | 01/00 | FFMPEGv10 |
- * 11 / 2.[4-8] | 56 | 56 | 54 | 02/01 | FFMPEGv11 |
- * 12 / 2.[9-x] | 57 | 57 | 55 | 02/01 | TODO |
+ * ffmpeg | lavcodec | lavformat | lavdevice | lavutil | swresample | FFMPEG* class |
+ * 4 | 58 | 58 | 58 | 56 | 03 | FFMPEGv0400 |
+ * 5 | 59 | 59 | 59 | 57 | 04 | FFMPEGv0500 |
+ * 6 | 60 | 60 | 60 | 58 | 04 | FFMPEGv0600 |
*
*
*
@@ -121,11 +114,6 @@ import jogamp.opengl.util.av.VideoPixelFormat;
*
http://ffmpeg.org/documentation.html
* http://git.videolan.org/?p=ffmpeg.git;a=blob;f=doc/APIchanges;hb=HEAD
*
- * See libav:
- *
- * - https://libav.org/documentation.html
- * - http://upstream-tracker.org/versions/libav.html
- *
*
*
* Check tag 'FIXME: Add more planar formats !'
@@ -141,15 +129,14 @@ import jogamp.opengl.util.av.VideoPixelFormat;
*
*
*
- * FFMPEG / LibAV Availability
+ * FFmpeg Availability
*
*
- * - GNU/Linux: ffmpeg or libav are deployed in most distributions.
+ * - GNU/Linux: ffmpeg is deployed in most distributions.
* - Windows:
*
* - https://ffmpeg.org/download.html#build-windows
* - http://ffmpeg.zeranoe.com/builds/ (ffmpeg) recommended, works w/ dshow
- * - http://win32.libav.org/releases/ (libav)
*
* - MacOSX
*
@@ -211,11 +198,9 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
private static final int avUtilMajorVersionCC;
private static final int avFormatMajorVersionCC;
private static final int avCodecMajorVersionCC;
- private static final int avResampleMajorVersionCC;
+ private static final int avDeviceMajorVersionCC;
private static final int swResampleMajorVersionCC;
private static final boolean available;
- private static final boolean enableAvResample;
- private static final boolean enableSwResample;
static {
// PREFER_SYSTEM_LIBS default on all systems is true for now!
@@ -230,58 +215,51 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
avCodecMajorVersionCC = natives.getAvCodecMajorVersionCC0();
avFormatMajorVersionCC = natives.getAvFormatMajorVersionCC0();
avUtilMajorVersionCC = natives.getAvUtilMajorVersionCC0();
- avResampleMajorVersionCC = natives.getAvResampleMajorVersionCC0();
+ avDeviceMajorVersionCC = natives.getAvDeviceMajorVersionCC0();
swResampleMajorVersionCC = natives.getSwResampleMajorVersionCC0();
} else {
avUtilMajorVersionCC = 0;
avFormatMajorVersionCC = 0;
avCodecMajorVersionCC = 0;
- avResampleMajorVersionCC = 0;
+ avDeviceMajorVersionCC = 0;
swResampleMajorVersionCC = 0;
}
final VersionNumber avCodecVersion = FFMPEGDynamicLibraryBundleInfo.avCodecVersion;
final VersionNumber avFormatVersion = FFMPEGDynamicLibraryBundleInfo.avFormatVersion;
final VersionNumber avUtilVersion = FFMPEGDynamicLibraryBundleInfo.avUtilVersion;
- final VersionNumber avResampleVersion = FFMPEGDynamicLibraryBundleInfo.avResampleVersion;
- final boolean avResampleLoaded = FFMPEGDynamicLibraryBundleInfo.avResampleLoaded();
+ final VersionNumber avDeviceVersion = FFMPEGDynamicLibraryBundleInfo.avDeviceVersion;
final VersionNumber swResampleVersion = FFMPEGDynamicLibraryBundleInfo.swResampleVersion;
+ final boolean avDeviceLoaded = FFMPEGDynamicLibraryBundleInfo.avDeviceLoaded();
final boolean swResampleLoaded = FFMPEGDynamicLibraryBundleInfo.swResampleLoaded();
- if( DEBUG ) {
- System.err.println("LIB_AV Codec : "+avCodecVersion+" [cc "+avCodecMajorVersionCC+"]");
- System.err.println("LIB_AV Format : "+avFormatVersion+" [cc "+avFormatMajorVersionCC+"]");
- System.err.println("LIB_AV Util : "+avUtilVersion+" [cc "+avUtilMajorVersionCC+"]");
- System.err.println("LIB_AV Resample: "+avResampleVersion+" [cc "+avResampleMajorVersionCC+", loaded "+avResampleLoaded+"]");
- System.err.println("LIB_SW Resample: "+swResampleVersion+" [cc "+swResampleMajorVersionCC+", loaded "+swResampleLoaded+"]");
- System.err.println("LIB_AV Device : [loaded "+FFMPEGDynamicLibraryBundleInfo.avDeviceLoaded()+"]");
- System.err.println("LIB_AV Class : "+(null!= natives ? natives.getClass().getSimpleName() : "n/a"));
- }
final int avCodecMajor = avCodecVersion.getMajor();
final int avFormatMajor = avFormatVersion.getMajor();
final int avUtilMajor = avUtilVersion.getMajor();
+ final int avDeviceMajor = avDeviceVersion.getMajor();
+ final int swResampleMajor = swResampleVersion.getMajor();
libAVVersionGood = avCodecMajorVersionCC == avCodecMajor &&
avFormatMajorVersionCC == avFormatMajor &&
- ( avUtilMajorVersionCC == avUtilMajor ||
- 55 == avCodecMajorVersionCC && 53 == avUtilMajorVersionCC && 52 == avUtilMajor /* ffmpeg 2.x */
- );
- enableAvResample = avResampleLoaded && avResampleMajorVersionCC == avResampleVersion.getMajor();
- enableSwResample = swResampleLoaded && swResampleMajorVersionCC == swResampleVersion.getMajor();
- if( DEBUG ) {
- System.err.println("LIB_AV Resample: enabled "+enableAvResample);
- System.err.println("LIB_SW Resample: enabled "+enableSwResample);
- }
+ avUtilMajorVersionCC == avUtilMajor &&
+ ( avDeviceMajorVersionCC == avDeviceMajor || 0 == avDeviceMajor ) &&
+ swResampleMajorVersionCC == swResampleMajor;
if( !libAVVersionGood ) {
- System.err.println("LIB_AV Not Matching Compile-Time / Runtime Major-Version");
+ System.err.println("FFmpeg Not Matching Compile-Time / Runtime Major-Version");
+ }
+ if( !libAVVersionGood || DEBUG ) {
+ System.err.println("FFmpeg Codec : "+avCodecVersion+" [cc "+avCodecMajorVersionCC+"]");
+ System.err.println("FFmpeg Format : "+avFormatVersion+" [cc "+avFormatMajorVersionCC+"]");
+ System.err.println("FFmpeg Util : "+avUtilVersion+" [cc "+avUtilMajorVersionCC+"]");
+ System.err.println("FFmpeg Device : "+avDeviceVersion+" [cc "+avDeviceMajorVersionCC+", loaded "+avDeviceLoaded+"]");
+ System.err.println("FFmpeg Resample: "+swResampleVersion+" [cc "+swResampleMajorVersionCC+", loaded "+swResampleLoaded+"]");
+ System.err.println("FFmpeg Class : "+(null!= natives ? natives.getClass().getSimpleName() : "n/a"));
}
} else {
natives = null;
avUtilMajorVersionCC = 0;
avFormatMajorVersionCC = 0;
avCodecMajorVersionCC = 0;
- avResampleMajorVersionCC = 0;
+ avDeviceMajorVersionCC = 0;
swResampleMajorVersionCC = 0;
libAVVersionGood = false;
- enableAvResample = false;
- enableSwResample = false;
}
available = libAVGood && libAVVersionGood && null != natives;
}
@@ -319,7 +297,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
if(!available) {
throw new RuntimeException("FFMPEGMediaPlayer not available");
}
- moviePtr = natives.createInstance0(this, enableAvResample, enableSwResample, DEBUG_NATIVE);
+ moviePtr = natives.createInstance0(this, DEBUG_NATIVE);
if(0==moviePtr) {
throw new GLException("Couldn't create FFMPEGInstance");
}
@@ -521,8 +499,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
/**
* Native callback
- * Converts the given libav/ffmpeg values to {@link AudioFormat} and returns {@link AudioSink#isSupported(AudioFormat)}.
- * @param audioSampleFmt ffmpeg/libav audio-sample-format, see {@link AudioSampleFormat}.
+ * Converts the given ffmpeg values to {@link AudioFormat} and returns {@link AudioSink#isSupported(AudioFormat)}.
+ * @param audioSampleFmt ffmpeg audio-sample-format, see {@link AudioSampleFormat}.
* @param audioSampleRate sample rate in Hz (1/s)
* @param audioChannels number of channels
*/
@@ -537,8 +515,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
}
/**
- * Returns {@link AudioFormat} as converted from the given libav/ffmpeg values.
- * @param audioSampleFmt ffmpeg/libav audio-sample-format, see {@link AudioSampleFormat}.
+ * Returns {@link AudioFormat} as converted from the given ffmpeg values.
+ * @param audioSampleFmt ffmpeg audio-sample-format, see {@link AudioSampleFormat}.
* @param audioSampleRate sample rate in Hz (1/s)
* @param audioChannels number of channels
*/
@@ -853,7 +831,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
}
final int errno = natives.play0(moviePtr);
if( DEBUG_NATIVE && errno != 0 && errno != -ENOSYS) {
- System.err.println("libav play err: "+errno);
+ System.err.println("ffmpeg play err: "+errno);
}
return true;
}
@@ -865,7 +843,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
}
final int errno = natives.pause0(moviePtr);
if( DEBUG_NATIVE && errno != 0 && errno != -ENOSYS) {
- System.err.println("libav pause err: "+errno);
+ System.err.println("ffmpeg pause err: "+errno);
}
return true;
}
--
cgit v1.2.3