Class FFmpegKitConfig
- java.lang.Object
-
- com.arthenica.ffmpegkit.FFmpegKitConfig
-
public class FFmpegKitConfig extends java.lang.ObjectConfiguration class of
FFmpegKitlibrary.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringargumentsToString(java.lang.String[] arguments)Concatenates arguments into a string adding a space character between two arguments.static voidasyncFFmpegExecute(FFmpegSession ffmpegSession)Starts an asynchronous FFmpeg execution for the given session.static voidasyncFFmpegExecute(FFmpegSession ffmpegSession, java.util.concurrent.ExecutorService executorService)Starts an asynchronous FFmpeg execution for the given session.static voidasyncFFprobeExecute(FFprobeSession ffprobeSession)Starts an asynchronous FFprobe execution for the given session.static voidasyncFFprobeExecute(FFprobeSession ffprobeSession, java.util.concurrent.ExecutorService executorService)Starts an asynchronous FFprobe execution for the given session.static voidasyncGetMediaInformationExecute(MediaInformationSession mediaInformationSession, int waitTimeout)Starts an asynchronous FFprobe execution for the given media information session.static voidasyncGetMediaInformationExecute(MediaInformationSession mediaInformationSession, java.util.concurrent.ExecutorService executorService, int waitTimeout)Starts an asynchronous FFprobe execution for the given media information session.static voidclearSessions()Clears all, including ongoing, sessions in the session history.static voidcloseFFmpegPipe(java.lang.String ffmpegPipePath)Closes a previously createdFFmpegpipe.static voiddisableRedirection()Disables log and statistics redirection.static voidenableFFmpegSessionCompleteCallback(FFmpegSessionCompleteCallback ffmpegSessionCompleteCallback)Sets a global FFmpegSessionCompleteCallback to receive execution results for FFmpeg sessions.static voidenableFFprobeSessionCompleteCallback(FFprobeSessionCompleteCallback ffprobeSessionCompleteCallback)Sets a global FFprobeSessionCompleteCallback to receive execution results for FFprobe sessions.static voidenableLogCallback(LogCallback logCallback)Sets a global callback to redirect FFmpeg/FFprobe logs.static voidenableMediaInformationSessionCompleteCallback(MediaInformationSessionCompleteCallback mediaInformationSessionCompleteCallback)Sets a global MediaInformationSessionCompleteCallback to receive execution results for MediaInformation sessions.static voidenableRedirection()Enables log and statistics redirection.static voidenableStatisticsCallback(StatisticsCallback statisticsCallback)Sets a global callback to redirect FFmpeg statistics.static voidffmpegExecute(FFmpegSession ffmpegSession)Synchronously executes the FFmpeg session provided.static voidffprobeExecute(FFprobeSession ffprobeSession)Synchronously executes the FFprobe session provided.static intgetAsyncConcurrencyLimit()Returns the maximum number of async sessions that will be executed in parallel.static java.lang.StringgetBuildDate()Returns FFmpegKit library build date.static FFmpegSessionCompleteCallbackgetFFmpegSessionCompleteCallback()Returns the global FFmpegSessionCompleteCallback set.static java.util.List<FFmpegSession>getFFmpegSessions()Returns all FFmpeg sessions in the session history.static java.lang.StringgetFFmpegVersion()Returns the version of FFmpeg bundled withinFFmpegKitlibrary.static FFprobeSessionCompleteCallbackgetFFprobeSessionCompleteCallback()Returns the global FFprobeSessionCompleteCallback set.static java.util.List<FFprobeSession>getFFprobeSessions()Returns all FFprobe sessions in the session history.static SessiongetLastCompletedSession()Returns the last session completed from the session history.static SessiongetLastSession()Returns the last session created from the session history.static LevelgetLogLevel()Returns the current log level.static LogRedirectionStrategygetLogRedirectionStrategy()Returns the active log redirection strategy.static voidgetMediaInformationExecute(MediaInformationSession mediaInformationSession, int waitTimeout)Synchronously executes the media information session provided.static MediaInformationSessionCompleteCallbackgetMediaInformationSessionCompleteCallback()Returns the global MediaInformationSessionCompleteCallback set.static java.util.List<MediaInformationSession>getMediaInformationSessions()Returns all MediaInformation sessions in the session history.static java.lang.StringgetSafParameter(android.content.Context context, android.net.Uri uri, java.lang.String openMode)Converts the given Structured Access Framework Uri ("content:…") into an SAF protocol url that can be used in FFmpeg and FFprobe commands.static java.lang.StringgetSafParameterForRead(android.content.Context context, android.net.Uri uri)Converts the given Structured Access Framework Uri ("content:…") into an SAF protocol url that can be used in FFmpeg and FFprobe commands.static java.lang.StringgetSafParameterForWrite(android.content.Context context, android.net.Uri uri)Converts the given Structured Access Framework Uri ("content:…") into an SAF protocol url that can be used in FFmpeg and FFprobe commands.static SessiongetSession(long sessionId)Returns the session specified withsessionIdfrom the session history.static intgetSessionHistorySize()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.StringgetVersion()Returns FFmpegKit library version.static voidignoreSignal(Signal signal)Registers a new ignored signal.static booleanisLTSBuild()Returns whether FFmpegKit release is a Long Term Release or not.static intmessagesInTransmit(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 voidprintToLogcat(int logPriority, java.lang.String string)Prints the given string to Logcat using the given priority.static java.lang.StringregisterNewFFmpegPipe(android.content.Context context)Creates a new named pipe to use inFFmpegoperations.static java.lang.StringsessionStateToString(SessionState state)Converts session state to string.static voidsetAsyncConcurrencyLimit(int asyncConcurrencyLimit)Sets the maximum number of async sessions that will be executed in parallel.static intsetEnvironmentVariable(java.lang.String variableName, java.lang.String variableValue)Sets an environment variable.static intsetFontconfigConfigurationPath(java.lang.String path)Sets and overridesfontconfigconfiguration directory.static voidsetFontDirectory(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 voidsetFontDirectoryList(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 voidsetLogLevel(Level level)Sets the log level.static voidsetLogRedirectionStrategy(LogRedirectionStrategy logRedirectionStrategy)Sets the log redirection strategystatic voidsetSessionHistorySize(int sessionHistorySize)Sets the session history size.
-
-
-
Method Detail
-
enableRedirection
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.
-
disableRedirection
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'sgetMediaInformationmethods do not work.
-
setFontconfigConfigurationPath
public static int setFontconfigConfigurationPath(java.lang.String path)
Sets and overrides
fontconfigconfiguration directory.- Parameters:
path- directory that contains fontconfig configuration (fonts.conf)- Returns:
- zero on success, non-zero on error
-
setFontDirectory
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
FFmpegKitwithfontconfigenabled or use a prebuilt package withfontconfiginside to be able to use fonts inFFmpeg.- Parameters:
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 names
-
setFontDirectoryList
public 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
FFmpegKitwithfontconfigenabled or use a prebuilt package withfontconfiginside to be able to use fonts inFFmpeg.- Parameters:
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 names
-
registerNewFFmpegPipe
public static java.lang.String registerNewFFmpegPipe(android.content.Context context)
Creates a new named pipe to use in
FFmpegoperations.Please note that creator is responsible of closing created pipes.
- Parameters:
context- application context- Returns:
- the full path of the named pipe
-
closeFFmpegPipe
public static void closeFFmpegPipe(java.lang.String ffmpegPipePath)
Closes a previously created
FFmpegpipe.- Parameters:
ffmpegPipePath- full path of the FFmpeg pipe
-
getSupportedCameraIds
public static java.util.List<java.lang.String> getSupportedCameraIds(android.content.Context context)
Returns the list of camera ids supported. These devices can be used inFFmpegcommands.Note that this method requires API Level ≥ 24. On older API levels it returns an empty list.
- Parameters:
context- application context- Returns:
- list of camera ids supported or an empty list if no supported cameras are found
-
getFFmpegVersion
public static java.lang.String getFFmpegVersion()
Returns the version of FFmpeg bundled within
FFmpegKitlibrary.- Returns:
- the version of FFmpeg
-
getVersion
public static java.lang.String getVersion()
Returns FFmpegKit library version.
- Returns:
- FFmpegKit version
-
isLTSBuild
public static boolean isLTSBuild()
Returns whether FFmpegKit release is a Long Term Release or not.
- Returns:
- true/yes or false/no
-
getBuildDate
public static java.lang.String getBuildDate()
Returns FFmpegKit library build date.
- Returns:
- FFmpegKit library build date
-
printToLogcat
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.
- Parameters:
logPriority- one ofLog.VERBOSE,Log.DEBUG,Log.INFO,Log.WARN,Log.ERROR,Log.ASSERTstring- string to be printed
-
setEnvironmentVariable
public static int setEnvironmentVariable(java.lang.String variableName, java.lang.String variableValue)Sets an environment variable.
- Parameters:
variableName- environment variable namevariableValue- environment variable value- Returns:
- zero on success, non-zero on error
-
ignoreSignal
public static void ignoreSignal(Signal signal)
Registers a new ignored signal. Ignored signals are not handled by
FFmpegKitlibrary.- Parameters:
signal- signal to be ignored
-
ffmpegExecute
public static void ffmpegExecute(FFmpegSession ffmpegSession)
Synchronously executes the FFmpeg session provided.
- Parameters:
ffmpegSession- FFmpeg session which includes command options/arguments
-
ffprobeExecute
public static void ffprobeExecute(FFprobeSession ffprobeSession)
Synchronously executes the FFprobe session provided.
- Parameters:
ffprobeSession- FFprobe session which includes command options/arguments
-
getMediaInformationExecute
public static void getMediaInformationExecute(MediaInformationSession mediaInformationSession, int waitTimeout)
Synchronously executes the media information session provided.
- Parameters:
mediaInformationSession- media information session which includes command options/argumentswaitTimeout- max time to wait until media information is transmitted
-
asyncFFmpegExecute
public static void asyncFFmpegExecute(FFmpegSession ffmpegSession)
Starts an asynchronous FFmpeg execution for the given session.
Note that this method returns immediately and does not wait the execution to complete. You must use an
FFmpegSessionCompleteCallbackif you want to be notified about the result.- Parameters:
ffmpegSession- FFmpeg session which includes command options/arguments
-
asyncFFmpegExecute
public static void asyncFFmpegExecute(FFmpegSession ffmpegSession, java.util.concurrent.ExecutorService executorService)
Starts an asynchronous FFmpeg execution for the given session.
Note that this method returns immediately and does not wait the execution to complete. You must use an
FFmpegSessionCompleteCallbackif you want to be notified about the result.- Parameters:
ffmpegSession- FFmpeg session which includes command options/argumentsexecutorService- executor service that will be used to run this asynchronous operation
-
asyncFFprobeExecute
public static void asyncFFprobeExecute(FFprobeSession ffprobeSession)
Starts an asynchronous FFprobe execution for the given session.
Note that this method returns immediately and does not wait the execution to complete. You must use an
FFprobeSessionCompleteCallbackif you want to be notified about the result.- Parameters:
ffprobeSession- FFprobe session which includes command options/arguments
-
asyncFFprobeExecute
public static void asyncFFprobeExecute(FFprobeSession ffprobeSession, java.util.concurrent.ExecutorService executorService)
Starts an asynchronous FFprobe execution for the given session.
Note that this method returns immediately and does not wait the execution to complete. You must use an
FFprobeSessionCompleteCallbackif you want to be notified about the result.- Parameters:
ffprobeSession- FFprobe session which includes command options/argumentsexecutorService- executor service that will be used to run this asynchronous operation
-
asyncGetMediaInformationExecute
public static void asyncGetMediaInformationExecute(MediaInformationSession mediaInformationSession, int waitTimeout)
Starts an asynchronous FFprobe execution for the given media information session.
Note that this method returns immediately and does not wait the execution to complete. You must use a
MediaInformationSessionCompleteCallbackif you want to be notified about the result.- Parameters:
mediaInformationSession- media information session which includes command options/argumentswaitTimeout- max time to wait until media information is transmitted
-
asyncGetMediaInformationExecute
public static void asyncGetMediaInformationExecute(MediaInformationSession mediaInformationSession, java.util.concurrent.ExecutorService executorService, int waitTimeout)
Starts an asynchronous FFprobe execution for the given media information session.
Note that this method returns immediately and does not wait the execution to complete. You must use a
MediaInformationSessionCompleteCallbackif you want to be notified about the result.- Parameters:
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 transmitted
-
getAsyncConcurrencyLimit
public static int getAsyncConcurrencyLimit()
Returns the maximum number of async sessions that will be executed in parallel.- Returns:
- maximum number of async sessions that will be executed in parallel
-
setAsyncConcurrencyLimit
public static void setAsyncConcurrencyLimit(int asyncConcurrencyLimit)
Sets the maximum number of async sessions that will be executed in parallel. If more sessions are submitted those will be queued.- Parameters:
asyncConcurrencyLimit- new async concurrency limit
-
enableLogCallback
public static void enableLogCallback(LogCallback logCallback)
Sets a global callback to redirect FFmpeg/FFprobe logs.
- Parameters:
logCallback- log callback or null to disable a previously defined callback
-
enableStatisticsCallback
public static void enableStatisticsCallback(StatisticsCallback statisticsCallback)
Sets a global callback to redirect FFmpeg statistics.
- Parameters:
statisticsCallback- statistics callback or null to disable a previously defined callback
-
enableFFmpegSessionCompleteCallback
public static void enableFFmpegSessionCompleteCallback(FFmpegSessionCompleteCallback ffmpegSessionCompleteCallback)
Sets a global FFmpegSessionCompleteCallback to receive execution results for FFmpeg sessions.
- Parameters:
ffmpegSessionCompleteCallback- complete callback or null to disable a previously defined callback
-
getFFmpegSessionCompleteCallback
public static FFmpegSessionCompleteCallback getFFmpegSessionCompleteCallback()
Returns the global FFmpegSessionCompleteCallback set.
- Returns:
- global FFmpegSessionCompleteCallback or null if it is not set
-
enableFFprobeSessionCompleteCallback
public static void enableFFprobeSessionCompleteCallback(FFprobeSessionCompleteCallback ffprobeSessionCompleteCallback)
Sets a global FFprobeSessionCompleteCallback to receive execution results for FFprobe sessions.
- Parameters:
ffprobeSessionCompleteCallback- complete callback or null to disable a previously defined callback
-
getFFprobeSessionCompleteCallback
public static FFprobeSessionCompleteCallback getFFprobeSessionCompleteCallback()
Returns the global FFprobeSessionCompleteCallback set.
- Returns:
- global FFprobeSessionCompleteCallback or null if it is not set
-
enableMediaInformationSessionCompleteCallback
public static void enableMediaInformationSessionCompleteCallback(MediaInformationSessionCompleteCallback mediaInformationSessionCompleteCallback)
Sets a global MediaInformationSessionCompleteCallback to receive execution results for MediaInformation sessions.
- Parameters:
mediaInformationSessionCompleteCallback- complete callback or null to disable a previously defined callback
-
getMediaInformationSessionCompleteCallback
public static MediaInformationSessionCompleteCallback getMediaInformationSessionCompleteCallback()
Returns the global MediaInformationSessionCompleteCallback set.
- Returns:
- global MediaInformationSessionCompleteCallback or null if it is not set
-
getLogLevel
public static Level getLogLevel()
Returns the current log level.- Returns:
- current log level
-
setLogLevel
public static void setLogLevel(Level level)
Sets the log level.- Parameters:
level- new log level
-
getSafParameter
public static java.lang.String getSafParameter(android.content.Context context, android.net.Uri uri, java.lang.String openMode)Converts the given Structured Access Framework Uri (
"content:…") into an SAF protocol url that can be used in FFmpeg and FFprobe commands.Requires API Level 19+. On older API levels it returns an empty url.
- Parameters:
context- application contexturi- SAF uriopenMode- file mode to use as defined inContentProvider.openFile- Returns:
- input/output url that can be passed to FFmpegKit or FFprobeKit
-
getSafParameterForRead
public static java.lang.String getSafParameterForRead(android.content.Context context, android.net.Uri uri)Converts the given Structured Access Framework Uri (
"content:…") into an SAF protocol url that can be used in FFmpeg and FFprobe commands.Requires API Level ≥ 19. On older API levels it returns an empty url.
- Parameters:
context- application contexturi- SAF uri- Returns:
- input url that can be passed to FFmpegKit or FFprobeKit
-
getSafParameterForWrite
public static java.lang.String getSafParameterForWrite(android.content.Context context, android.net.Uri uri)Converts the given Structured Access Framework Uri (
"content:…") into an SAF protocol url that can be used in FFmpeg and FFprobe commands.Requires API Level ≥ 19. On older API levels it returns an empty url.
- Parameters:
context- application contexturi- SAF uri- Returns:
- output url that can be passed to FFmpegKit or FFprobeKit
-
getSessionHistorySize
public static int getSessionHistorySize()
Returns the session history size.- Returns:
- session history size
-
setSessionHistorySize
public static void setSessionHistorySize(int sessionHistorySize)
Sets the session history size.- Parameters:
sessionHistorySize- session history size, should be smaller than 1000
-
getSession
public static Session getSession(long sessionId)
Returns the session specified withsessionIdfrom the session history.- Parameters:
sessionId- session identifier- Returns:
- session specified with sessionId or null if it is not found in the history
-
getLastSession
public static Session getLastSession()
Returns the last session created from the session history.- Returns:
- the last session created or null if session history is empty
-
getLastCompletedSession
public static Session getLastCompletedSession()
Returns the last session completed from the session history.- Returns:
- the last session completed. If there are no completed sessions in the history this method will return null
-
getSessions
public static java.util.List<Session> getSessions()
Returns all sessions in the session history.
- Returns:
- all sessions in the session history
-
clearSessions
public static void clearSessions()
Clears all, including ongoing, sessions in the session history.
Note that callbacks cannot be triggered for deleted sessions.
-
getFFmpegSessions
public static java.util.List<FFmpegSession> getFFmpegSessions()
Returns all FFmpeg sessions in the session history.
- Returns:
- all FFmpeg sessions in the session history
-
getFFprobeSessions
public static java.util.List<FFprobeSession> getFFprobeSessions()
Returns all FFprobe sessions in the session history.
- Returns:
- all FFprobe sessions in the session history
-
getMediaInformationSessions
public static java.util.List<MediaInformationSession> getMediaInformationSessions()
Returns all MediaInformation sessions in the session history.
- Returns:
- all MediaInformation sessions in the session history
-
getSessionsByState
public static java.util.List<Session> getSessionsByState(SessionState state)
Returns sessions that have the given state.
- Parameters:
state- session state- Returns:
- sessions that have the given state from the session history
-
getLogRedirectionStrategy
public static LogRedirectionStrategy getLogRedirectionStrategy()
Returns the active log redirection strategy.- Returns:
- log redirection strategy
-
setLogRedirectionStrategy
public static void setLogRedirectionStrategy(LogRedirectionStrategy logRedirectionStrategy)
Sets the log redirection strategy
- Parameters:
logRedirectionStrategy- log redirection strategy
-
sessionStateToString
public static java.lang.String sessionStateToString(SessionState state)
Converts session state to string.- Parameters:
state- session state- Returns:
- string value
-
parseArguments
public 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.
- Parameters:
command- string command- Returns:
- array of arguments
-
argumentsToString
public static java.lang.String argumentsToString(java.lang.String[] arguments)
Concatenates arguments into a string adding a space character between two arguments.
- Parameters:
arguments- arguments- Returns:
- concatenated string containing all arguments
-
messagesInTransmit
public static int messagesInTransmit(long sessionId)
Returns the number of native messages that are not transmitted to the Java callbacks for this session natively.
- Parameters:
sessionId- id of the session- Returns:
- number of native messages that are not transmitted to the Java callbacks for this session natively
-
-