public class FFmpegKitConfig
extends java.lang.Object
Configuration class of FFmpegKit
library.
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
argumentsToString(java.lang.String[] arguments)
Concatenates arguments into a string adding a space character between two arguments.
|
static void |
asyncFFmpegExecute(FFmpegSession ffmpegSession)
Asynchronously executes the FFmpeg session provided.
|
static void |
asyncFFmpegExecute(FFmpegSession ffmpegSession,
java.util.concurrent.ExecutorService executorService)
Asynchronously executes the FFmpeg session provided.
|
static void |
asyncFFprobeExecute(FFprobeSession ffprobeSession)
Asynchronously executes the FFprobe session provided.
|
static void |
asyncFFprobeExecute(FFprobeSession ffprobeSession,
java.util.concurrent.ExecutorService executorService)
Asynchronously executes the FFprobe session provided.
|
static void |
asyncGetMediaInformationExecute(MediaInformationSession mediaInformationSession,
java.util.concurrent.ExecutorService executorService,
int waitTimeout)
Asynchronously executes the media information session provided.
|
static void |
asyncGetMediaInformationExecute(MediaInformationSession mediaInformationSession,
int waitTimeout)
Asynchronously executes the media information session provided.
|
static void |
clearSessions()
Clears all, including ongoing, sessions in the session history.
|
static void |
closeFFmpegPipe(java.lang.String ffmpegPipePath)
Closes a previously created
FFmpeg pipe. |
static void |
disableRedirection()
Disables log and statistics redirection.
|
static void |
enableExecuteCallback(ExecuteCallback executeCallback)
Sets a global callback function to receive execution results.
|
static void |
enableLogCallback(LogCallback logCallback)
Sets a global callback function to redirect FFmpeg/FFprobe logs.
|
static void |
enableRedirection()
Enables log and statistics redirection.
|
static void |
enableStatisticsCallback(StatisticsCallback statisticsCallback)
Sets a global callback function to redirect FFmpeg statistics.
|
static void |
ffmpegExecute(FFmpegSession ffmpegSession)
Synchronously executes the FFmpeg session provided.
|
static void |
ffprobeExecute(FFprobeSession ffprobeSession)
Synchronously executes the FFprobe session provided.
|
static int |
getAsyncConcurrencyLimit()
Returns the maximum number of async sessions that will be executed in parallel.
|
static java.lang.String |
getBuildDate()
Returns FFmpegKit library build date.
|
static java.lang.String |
getFFmpegVersion()
Returns the version of FFmpeg bundled within
FFmpegKit library. |
static Session |
getLastCompletedSession()
Returns the last session completed from the session history.
|
static Session |
getLastSession()
Returns the last session created from the session history.
|
static Level |
getLogLevel()
Returns the current log level.
|
static LogRedirectionStrategy |
getLogRedirectionStrategy()
Returns the active log redirection strategy.
|
static void |
getMediaInformationExecute(MediaInformationSession mediaInformationSession,
int waitTimeout)
Synchronously executes the media information session provided.
|
static java.lang.String |
getSafParameterForRead(android.content.Context context,
android.net.Uri uri)
Converts the given Structured Access Framework Uri (
"content:…" ) into an
input url that can be used in FFmpeg and FFprobe commands. |
static java.lang.String |
getSafParameterForWrite(android.content.Context context,
android.net.Uri uri)
Converts the given Structured Access Framework Uri (
"content:…" ) into an
output url that can be used in FFmpeg and FFprobe commands. |
static Session |
getSession(long sessionId)
Returns the session specified with
sessionId from the session history. |
static int |
getSessionHistorySize()
Returns the session history size.
|
static java.util.List<Session> |
getSessions()
Returns all sessions in the session history.
|
static java.util.List<Session> |
getSessionsByState(SessionState state)
Returns sessions that have the given state.
|
static java.util.List<java.lang.String> |
getSupportedCameraIds(android.content.Context context)
Returns the list of camera ids supported.
|
static java.lang.String |
getVersion()
Returns FFmpegKit library version.
|
static void |
ignoreSignal(Signal signal)
Registers a new ignored signal.
|
static boolean |
isLTSBuild()
Returns whether FFmpegKit release is a Long Term Release or not.
|
static int |
messagesInTransmit(long sessionId)
Returns the number of native messages that are not transmitted to the Java callbacks for
this session natively.
|
static java.lang.String[] |
parseArguments(java.lang.String command)
Parses the given command into arguments.
|
static void |
printToLogcat(int logPriority,
java.lang.String string)
Prints the given string to Logcat using the given priority.
|
static java.lang.String |
registerNewFFmpegPipe(android.content.Context context)
Creates a new named pipe to use in
FFmpeg operations. |
static void |
setAsyncConcurrencyLimit(int asyncConcurrencyLimit)
Sets the maximum number of async sessions that will be executed in parallel.
|
static int |
setEnvironmentVariable(java.lang.String variableName,
java.lang.String variableValue)
Sets an environment variable.
|
static int |
setFontconfigConfigurationPath(java.lang.String path)
Sets and overrides
fontconfig configuration directory. |
static void |
setFontDirectory(android.content.Context context,
java.lang.String fontDirectoryPath,
java.util.Map<java.lang.String,java.lang.String> fontNameMapping)
Registers the fonts inside the given path, so they become available to use in FFmpeg
filters.
|
static void |
setFontDirectoryList(android.content.Context context,
java.util.List<java.lang.String> fontDirectoryList,
java.util.Map<java.lang.String,java.lang.String> fontNameMapping)
Registers the fonts inside the given list of font directories, so they become available
to use in FFmpeg filters.
|
static void |
setLogLevel(Level level)
Sets the log level.
|
static void |
setLogRedirectionStrategy(LogRedirectionStrategy logRedirectionStrategy)
Sets the log redirection strategy
|
static void |
setSessionHistorySize(int sessionHistorySize)
Sets the session history size.
|
public static void enableRedirection()
Enables log and statistics redirection.
When redirection is enabled FFmpeg/FFprobe logs are redirected to Logcat and sessions collect log and statistics entries for the executions. It is possible to define global or session specific log/statistics callbacks as well.
Note that redirection is enabled by default. If you do not want to use its functionality
please use disableRedirection()
to disable it.
public static void disableRedirection()
Disables log and statistics redirection.
When redirection is disabled logs are printed to stderr, all logs and statistics
callbacks are disabled and FFprobe
's getMediaInformation
methods
do not work.
public static int setFontconfigConfigurationPath(java.lang.String path)
Sets and overrides fontconfig
configuration directory.
path
- directory that contains fontconfig configuration (fonts.conf)public static void setFontDirectory(android.content.Context context, java.lang.String fontDirectoryPath, java.util.Map<java.lang.String,java.lang.String> fontNameMapping)
Registers the fonts inside the given path, so they become available to use in FFmpeg filters.
Note that you need to build FFmpegKit
with fontconfig
enabled or use a prebuilt package with fontconfig
inside to be able to use
fonts in FFmpeg
.
context
- application context to access application datafontDirectoryPath
- directory that contains fonts (.ttf and .otf files)fontNameMapping
- custom font name mappings, useful to access your fonts with more
friendly namespublic static void setFontDirectoryList(android.content.Context context, java.util.List<java.lang.String> fontDirectoryList, java.util.Map<java.lang.String,java.lang.String> fontNameMapping)
Registers the fonts inside the given list of font directories, so they become available to use in FFmpeg filters.
Note that you need to build FFmpegKit
with fontconfig
enabled or use a prebuilt package with fontconfig
inside to be able to use
fonts in FFmpeg
.
context
- application context to access application datafontDirectoryList
- list of directories that contain fonts (.ttf and .otf files)fontNameMapping
- custom font name mappings, useful to access your fonts with more
friendly namespublic static java.lang.String registerNewFFmpegPipe(android.content.Context context)
Creates a new named pipe to use in FFmpeg
operations.
Please note that creator is responsible of closing created pipes.
context
- application contextpublic static void closeFFmpegPipe(java.lang.String ffmpegPipePath)
Closes a previously created FFmpeg
pipe.
ffmpegPipePath
- full path of the FFmpeg pipepublic static java.util.List<java.lang.String> getSupportedCameraIds(android.content.Context context)
FFmpeg
commands.
Note that this method requires API Level ≥ 24. On older API levels it returns an empty list.
context
- application contextpublic static java.lang.String getFFmpegVersion()
Returns the version of FFmpeg bundled within FFmpegKit
library.
public static java.lang.String getVersion()
Returns FFmpegKit library version.
public static boolean isLTSBuild()
Returns whether FFmpegKit release is a Long Term Release or not.
public static java.lang.String getBuildDate()
Returns FFmpegKit library build date.
public static void printToLogcat(int logPriority, java.lang.String string)
Prints the given string to Logcat using the given priority. If string provided is bigger than the Logcat buffer, the string is printed in multiple lines.
logPriority
- one of Log.VERBOSE
,
Log.DEBUG
,
Log.INFO
,
Log.WARN
,
Log.ERROR
,
Log.ASSERT
string
- string to be printedpublic static int setEnvironmentVariable(java.lang.String variableName, java.lang.String variableValue)
Sets an environment variable.
variableName
- environment variable namevariableValue
- environment variable valuepublic static void ignoreSignal(Signal signal)
Registers a new ignored signal. Ignored signals are not handled by FFmpegKit
library.
signal
- signal to be ignoredpublic static void ffmpegExecute(FFmpegSession ffmpegSession)
Synchronously executes the FFmpeg session provided.
ffmpegSession
- FFmpeg session which includes command options/argumentspublic static void ffprobeExecute(FFprobeSession ffprobeSession)
Synchronously executes the FFprobe session provided.
ffprobeSession
- FFprobe session which includes command options/argumentspublic static void getMediaInformationExecute(MediaInformationSession mediaInformationSession, int waitTimeout)
Synchronously executes the media information session provided.
mediaInformationSession
- media information session which includes command options/argumentswaitTimeout
- max time to wait until media information is transmittedpublic static void asyncFFmpegExecute(FFmpegSession ffmpegSession)
Asynchronously executes the FFmpeg session provided.
ffmpegSession
- FFmpeg session which includes command options/argumentspublic static void asyncFFmpegExecute(FFmpegSession ffmpegSession, java.util.concurrent.ExecutorService executorService)
Asynchronously executes the FFmpeg session provided.
ffmpegSession
- FFmpeg session which includes command options/argumentsexecutorService
- executor service that will be used to run this asynchronous operationpublic static void asyncFFprobeExecute(FFprobeSession ffprobeSession)
Asynchronously executes the FFprobe session provided.
ffprobeSession
- FFprobe session which includes command options/argumentspublic static void asyncFFprobeExecute(FFprobeSession ffprobeSession, java.util.concurrent.ExecutorService executorService)
Asynchronously executes the FFprobe session provided.
ffprobeSession
- FFprobe session which includes command options/argumentsexecutorService
- executor service that will be used to run this asynchronous operationpublic static void asyncGetMediaInformationExecute(MediaInformationSession mediaInformationSession, int waitTimeout)
Asynchronously executes the media information session provided.
mediaInformationSession
- media information session which includes command options/argumentswaitTimeout
- max time to wait until media information is transmittedpublic static void asyncGetMediaInformationExecute(MediaInformationSession mediaInformationSession, java.util.concurrent.ExecutorService executorService, int waitTimeout)
Asynchronously executes the media information session provided.
mediaInformationSession
- media information session which includes command options/argumentsexecutorService
- executor service that will be used to run this asynchronous operationwaitTimeout
- max time to wait until media information is transmittedpublic static int getAsyncConcurrencyLimit()
public static void setAsyncConcurrencyLimit(int asyncConcurrencyLimit)
asyncConcurrencyLimit
- new async concurrency limitpublic static void enableLogCallback(LogCallback logCallback)
Sets a global callback function to redirect FFmpeg/FFprobe logs.
logCallback
- log callback function or null to disable a previously defined
callbackpublic static void enableStatisticsCallback(StatisticsCallback statisticsCallback)
Sets a global callback function to redirect FFmpeg statistics.
statisticsCallback
- statistics callback function or null to disable a previously
defined callbackpublic static void enableExecuteCallback(ExecuteCallback executeCallback)
Sets a global callback function to receive execution results.
executeCallback
- execute callback function or null to disable a previously
defined callbackpublic static Level getLogLevel()
public static void setLogLevel(Level level)
level
- new log levelpublic static java.lang.String getSafParameterForRead(android.content.Context context, android.net.Uri uri)
Converts the given Structured Access Framework Uri ("content:…"
) into an
input url that can be used in FFmpeg and FFprobe commands.
Requires API Level ≥ 19. On older API levels it returns an empty url.
context
- application contexturi
- saf uripublic static java.lang.String getSafParameterForWrite(android.content.Context context, android.net.Uri uri)
Converts the given Structured Access Framework Uri ("content:…"
) into an
output url that can be used in FFmpeg and FFprobe commands.
Requires API Level ≥ 19. On older API levels it returns an empty url.
context
- application contexturi
- saf uripublic static int getSessionHistorySize()
public static void setSessionHistorySize(int sessionHistorySize)
sessionHistorySize
- session history size, should be smaller than 1000public static Session getSession(long sessionId)
sessionId
from the session history.sessionId
- session identifierpublic static Session getLastSession()
public static Session getLastCompletedSession()
public static java.util.List<Session> getSessions()
Returns all sessions in the session history.
public static void clearSessions()
Clears all, including ongoing, sessions in the session history.
Note that callbacks cannot be triggered for deleted sessions.
public static java.util.List<Session> getSessionsByState(SessionState state)
Returns sessions that have the given state.
state
- session statepublic static LogRedirectionStrategy getLogRedirectionStrategy()
public static void setLogRedirectionStrategy(LogRedirectionStrategy logRedirectionStrategy)
Sets the log redirection strategy
logRedirectionStrategy
- log redirection strategypublic static java.lang.String[] parseArguments(java.lang.String command)
Parses the given command into arguments. Uses space character to split the arguments. Supports single and double quote characters.
command
- string commandpublic static java.lang.String argumentsToString(java.lang.String[] arguments)
Concatenates arguments into a string adding a space character between two arguments.
arguments
- argumentspublic static int messagesInTransmit(long sessionId)
Returns the number of native messages that are not transmitted to the Java callbacks for this session natively.
sessionId
- id of the session