Main class to run FFmpeg
commands. Supports executing commands both
* synchronously and asynchronously.
*
* FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v libxvid file1.avi"]; * * FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withExecuteCallback:executeCallback]; **
Provides overloaded execute
methods to define session specific callbacks.
*
* FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; **/ @interface FFmpegKit : NSObject /** *
Synchronously executes FFmpeg with arguments provided. * * @param arguments FFmpeg command options/arguments as string array * @return FFmpeg session created for this execution */ + (FFmpegSession*)executeWithArguments:(NSArray*)arguments; /** *
Asynchronously executes FFmpeg with arguments provided. * * @param arguments FFmpeg command options/arguments as string array * @param executeCallback callback that will be called when the execution is completed * @return FFmpeg session created for this execution */ + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; /** *
Asynchronously executes FFmpeg with arguments provided. * * @param arguments FFmpeg command options/arguments as string array * @param executeCallback callback that will be called when the execution is completed * @param logCallback callback that will receive logs * @param statisticsCallback callback that will receive statistics * @return FFmpeg session created for this execution */ + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; /** *
Asynchronously executes FFmpeg with arguments provided. * * @param arguments FFmpeg command options/arguments as string array * @param executeCallback callback that will be called when the execution is completed * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFmpeg session created for this execution */ + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; /** *
Asynchronously executes FFmpeg with arguments provided. * * @param arguments FFmpeg command options/arguments as string array * @param executeCallback callback that will be called when the execution is completed * @param logCallback callback that will receive logs * @param statisticsCallback callback that will receive statistics * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFmpeg session created for this execution */ + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue; /** *
Synchronously executes FFmpeg command provided. Space character is used to split command * into arguments. You can use single or double quote characters to specify arguments inside * your command. * * @param command FFmpeg command * @return FFmpeg session created for this execution */ + (FFmpegSession*)execute:(NSString*)command; /** *
Asynchronously executes FFmpeg command provided. Space character is used to split command * into arguments. You can use single or double quote characters to specify arguments inside * your command. * * @param command FFmpeg command * @param executeCallback callback that will be called when the execution is completed * @return FFmpeg session created for this execution */ + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback; /** *
Asynchronously executes FFmpeg command provided. Space character is used to split command * into arguments. You can use single or double quote characters to specify arguments inside * your command. * * @param command FFmpeg command * @param executeCallback callback that will be called when the execution is completed * @param logCallback callback that will receive logs * @param statisticsCallback callback that will receive statistics * @return FFmpeg session created for this execution */ + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; /** *
Asynchronously executes FFmpeg command provided. Space character is used to split command * into arguments. You can use single or double quote characters to specify arguments inside * your command. * * @param command FFmpeg command * @param executeCallback callback that will be called when the execution is completed * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFmpeg session created for this execution */ + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; /** *
Asynchronously executes FFmpeg command provided. Space character is used to split command * into arguments. You can use single or double quote characters to specify arguments inside * your command. * * @param command FFmpeg command * @param executeCallback callback that will be called when the execution is completed * @param logCallback callback that will receive logs * @param statisticsCallback callback that will receive statistics * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFmpeg session created for this execution */ + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue; /** *
Cancels all running sessions. * *
This function does not wait for termination to complete and returns immediately. */ + (void)cancel; /** *
Cancels the session specified with sessionId
.
*
*
This function does not wait for termination to complete and returns immediately. * * @param sessionId id of the session that will be cancelled */ + (void)cancel:(long)sessionId; /** *
Lists all FFmpeg sessions in the session history. * * @return all FFmpeg sessions in the session history */ + (NSArray*)listSessions; /** *
Parses the given command into arguments. Uses space character to split the arguments. * Supports single and double quote characters. * * @param command string command * @return array of arguments */ + (NSArray*)parseArguments:(NSString*)command; /** *
Concatenates arguments into a string adding a space character between two arguments. * * @param arguments arguments * @return concatenated string containing all arguments */ + (NSString*)argumentsToString:(NSArray*)arguments; @end #endif // FFMPEG_KIT_H