|
|
@ -20,11 +20,12 @@ |
|
|
|
import 'package:ffmpeg_kit_flutter_platform_interface/ffmpeg_kit_flutter_platform_interface.dart'; |
|
|
|
import 'package:ffmpeg_kit_flutter_platform_interface/ffmpeg_kit_flutter_platform_interface.dart'; |
|
|
|
import 'package:flutter/services.dart'; |
|
|
|
import 'package:flutter/services.dart'; |
|
|
|
|
|
|
|
|
|
|
|
import 'execute_callback.dart'; |
|
|
|
|
|
|
|
import 'ffmpeg_kit_config.dart'; |
|
|
|
import 'ffmpeg_kit_config.dart'; |
|
|
|
import 'ffprobe_session.dart'; |
|
|
|
import 'ffprobe_session.dart'; |
|
|
|
|
|
|
|
import 'ffprobe_session_complete_callback.dart'; |
|
|
|
import 'log_callback.dart'; |
|
|
|
import 'log_callback.dart'; |
|
|
|
import 'media_information_session.dart'; |
|
|
|
import 'media_information_session.dart'; |
|
|
|
|
|
|
|
import 'media_information_session_complete_callback.dart'; |
|
|
|
import 'src/ffmpeg_kit_factory.dart'; |
|
|
|
import 'src/ffmpeg_kit_factory.dart'; |
|
|
|
|
|
|
|
|
|
|
|
/// Main class to run "FFprobe" commands. |
|
|
|
/// Main class to run "FFprobe" commands. |
|
|
@ -35,20 +36,18 @@ class FFprobeKit { |
|
|
|
/// to split command into arguments. You can use single or double quote |
|
|
|
/// to split command into arguments. You can use single or double quote |
|
|
|
/// characters to specify arguments inside your command. |
|
|
|
/// characters to specify arguments inside your command. |
|
|
|
static Future<FFprobeSession> execute(String command, |
|
|
|
static Future<FFprobeSession> execute(String command, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
[FFprobeSessionCompleteCallback? completeCallback = null, |
|
|
|
LogCallback? logCallback = null]) async => |
|
|
|
LogCallback? logCallback = null]) async => |
|
|
|
FFprobeKit.executeWithArguments( |
|
|
|
FFprobeKit.executeWithArguments(FFmpegKitConfig.parseArguments(command), |
|
|
|
FFmpegKitConfig.parseArguments(command), |
|
|
|
completeCallback, logCallback); |
|
|
|
executeCallback, |
|
|
|
|
|
|
|
logCallback); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Synchronously executes FFprobe with arguments provided. |
|
|
|
/// Synchronously executes FFprobe with arguments provided. |
|
|
|
static Future<FFprobeSession> executeWithArguments( |
|
|
|
static Future<FFprobeSession> executeWithArguments( |
|
|
|
List<String> commandArguments, |
|
|
|
List<String> commandArguments, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
[FFprobeSessionCompleteCallback? completeCallback = null, |
|
|
|
LogCallback? logCallback = null]) async { |
|
|
|
LogCallback? logCallback = null]) async { |
|
|
|
final session = await FFprobeSession.create( |
|
|
|
final session = await FFprobeSession.create( |
|
|
|
commandArguments, executeCallback, logCallback, null); |
|
|
|
commandArguments, completeCallback, logCallback, null); |
|
|
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.ffprobeExecute(session); |
|
|
|
await FFmpegKitConfig.ffprobeExecute(session); |
|
|
|
|
|
|
|
|
|
|
@ -59,25 +58,25 @@ class FFprobeKit { |
|
|
|
/// into arguments. You can use single or double quote characters to specify arguments inside your command. |
|
|
|
/// into arguments. You can use single or double quote characters to specify arguments inside your command. |
|
|
|
/// |
|
|
|
/// |
|
|
|
/// Note that this method returns immediately and does not wait the execution to complete. You must use an |
|
|
|
/// Note that this method returns immediately and does not wait the execution to complete. You must use an |
|
|
|
/// [ExecuteCallback] if you want to be notified about the result. |
|
|
|
/// [FFprobeSessionCompleteCallback] if you want to be notified about the result. |
|
|
|
static Future<FFprobeSession> executeAsync(String command, |
|
|
|
static Future<FFprobeSession> executeAsync(String command, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
[FFprobeSessionCompleteCallback? completeCallback = null, |
|
|
|
LogCallback? logCallback = null]) async => |
|
|
|
LogCallback? logCallback = null]) async => |
|
|
|
FFprobeKit.executeWithArgumentsAsync( |
|
|
|
FFprobeKit.executeWithArgumentsAsync( |
|
|
|
FFmpegKitConfig.parseArguments(command), |
|
|
|
FFmpegKitConfig.parseArguments(command), |
|
|
|
executeCallback, |
|
|
|
completeCallback, |
|
|
|
logCallback); |
|
|
|
logCallback); |
|
|
|
|
|
|
|
|
|
|
|
/// Starts an asynchronous FFprobe execution with arguments provided. |
|
|
|
/// Starts an asynchronous FFprobe execution with arguments provided. |
|
|
|
/// |
|
|
|
/// |
|
|
|
/// Note that this method returns immediately and does not wait the execution to complete. You must use an |
|
|
|
/// Note that this method returns immediately and does not wait the execution to complete. You must use an |
|
|
|
/// [ExecuteCallback] if you want to be notified about the result. |
|
|
|
/// [FFprobeSessionCompleteCallback] if you want to be notified about the result. |
|
|
|
static Future<FFprobeSession> executeWithArgumentsAsync( |
|
|
|
static Future<FFprobeSession> executeWithArgumentsAsync( |
|
|
|
List<String> commandArguments, |
|
|
|
List<String> commandArguments, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
[FFprobeSessionCompleteCallback? completeCallback = null, |
|
|
|
LogCallback? logCallback = null]) async { |
|
|
|
LogCallback? logCallback = null]) async { |
|
|
|
final session = await FFprobeSession.create( |
|
|
|
final session = await FFprobeSession.create( |
|
|
|
commandArguments, executeCallback, logCallback, null); |
|
|
|
commandArguments, completeCallback, logCallback, null); |
|
|
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.asyncFFprobeExecute(session); |
|
|
|
await FFmpegKitConfig.asyncFFprobeExecute(session); |
|
|
|
|
|
|
|
|
|
|
@ -86,7 +85,7 @@ class FFprobeKit { |
|
|
|
|
|
|
|
|
|
|
|
/// Extracts media information for the file specified with path. |
|
|
|
/// Extracts media information for the file specified with path. |
|
|
|
static Future<MediaInformationSession> getMediaInformation(String path, |
|
|
|
static Future<MediaInformationSession> getMediaInformation(String path, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
[MediaInformationSessionCompleteCallback? completeCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
int? waitTimeout = null]) async { |
|
|
|
int? waitTimeout = null]) async { |
|
|
|
final commandArguments = [ |
|
|
|
final commandArguments = [ |
|
|
@ -102,7 +101,7 @@ class FFprobeKit { |
|
|
|
path |
|
|
|
path |
|
|
|
]; |
|
|
|
]; |
|
|
|
return FFprobeKit.getMediaInformationFromCommandArguments( |
|
|
|
return FFprobeKit.getMediaInformationFromCommandArguments( |
|
|
|
commandArguments, executeCallback, logCallback, waitTimeout); |
|
|
|
commandArguments, completeCallback, logCallback, waitTimeout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Extracts media information using the command provided. The command |
|
|
|
/// Extracts media information using the command provided. The command |
|
|
@ -110,12 +109,12 @@ class FFprobeKit { |
|
|
|
/// successfully extract media information from it. |
|
|
|
/// successfully extract media information from it. |
|
|
|
static Future<MediaInformationSession> getMediaInformationFromCommand( |
|
|
|
static Future<MediaInformationSession> getMediaInformationFromCommand( |
|
|
|
String command, |
|
|
|
String command, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
[MediaInformationSessionCompleteCallback? completeCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
int? waitTimeout = null]) async => |
|
|
|
int? waitTimeout = null]) async => |
|
|
|
FFprobeKit.getMediaInformationFromCommandArguments( |
|
|
|
FFprobeKit.getMediaInformationFromCommandArguments( |
|
|
|
FFmpegKitConfig.parseArguments(command), |
|
|
|
FFmpegKitConfig.parseArguments(command), |
|
|
|
executeCallback, |
|
|
|
completeCallback, |
|
|
|
logCallback, |
|
|
|
logCallback, |
|
|
|
waitTimeout); |
|
|
|
waitTimeout); |
|
|
|
|
|
|
|
|
|
|
@ -123,13 +122,12 @@ class FFprobeKit { |
|
|
|
/// command passed to this method must generate the output in JSON format in |
|
|
|
/// command passed to this method must generate the output in JSON format in |
|
|
|
/// order to successfully extract media information from it. |
|
|
|
/// order to successfully extract media information from it. |
|
|
|
static Future<MediaInformationSession> |
|
|
|
static Future<MediaInformationSession> |
|
|
|
getMediaInformationFromCommandArguments( |
|
|
|
getMediaInformationFromCommandArguments(List<String> commandArguments, |
|
|
|
List<String> commandArguments, |
|
|
|
[MediaInformationSessionCompleteCallback? completeCallback = null, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
|
|
|
|
LogCallback? logCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
int? waitTimeout = null]) async { |
|
|
|
int? waitTimeout = null]) async { |
|
|
|
final session = await MediaInformationSession.create( |
|
|
|
final session = await MediaInformationSession.create( |
|
|
|
commandArguments, executeCallback, logCallback); |
|
|
|
commandArguments, completeCallback, logCallback); |
|
|
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.getMediaInformationExecute(session, waitTimeout); |
|
|
|
await FFmpegKitConfig.getMediaInformationExecute(session, waitTimeout); |
|
|
|
|
|
|
|
|
|
|
@ -139,9 +137,9 @@ class FFprobeKit { |
|
|
|
/// Starts an asynchronous FFprobe execution to extract the media information for the specified file. |
|
|
|
/// Starts an asynchronous FFprobe execution to extract the media information for the specified file. |
|
|
|
/// |
|
|
|
/// |
|
|
|
/// Note that this method returns immediately and does not wait the execution to complete. You must use an |
|
|
|
/// Note that this method returns immediately and does not wait the execution to complete. You must use an |
|
|
|
/// [ExecuteCallback] if you want to be notified about the result. |
|
|
|
/// [MediaInformationSessionCompleteCallback] if you want to be notified about the result. |
|
|
|
static Future<MediaInformationSession> getMediaInformationAsync(String path, |
|
|
|
static Future<MediaInformationSession> getMediaInformationAsync(String path, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
[MediaInformationSessionCompleteCallback? completeCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
int? waitTimeout = null]) async { |
|
|
|
int? waitTimeout = null]) async { |
|
|
|
final commandArguments = [ |
|
|
|
final commandArguments = [ |
|
|
@ -157,22 +155,22 @@ class FFprobeKit { |
|
|
|
path |
|
|
|
path |
|
|
|
]; |
|
|
|
]; |
|
|
|
return FFprobeKit.getMediaInformationFromCommandArgumentsAsync( |
|
|
|
return FFprobeKit.getMediaInformationFromCommandArgumentsAsync( |
|
|
|
commandArguments, executeCallback, logCallback, waitTimeout); |
|
|
|
commandArguments, completeCallback, logCallback, waitTimeout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Starts an asynchronous FFprobe execution to extract media information using a command. The command passed to |
|
|
|
/// Starts an asynchronous FFprobe execution to extract media information using a command. The command passed to |
|
|
|
/// this method must generate the output in JSON format in order to successfully extract media information from it. |
|
|
|
/// this method must generate the output in JSON format in order to successfully extract media information from it. |
|
|
|
/// |
|
|
|
/// |
|
|
|
/// Note that this method returns immediately and does not wait the execution to complete. You must use an |
|
|
|
/// Note that this method returns immediately and does not wait the execution to complete. You must use an |
|
|
|
/// [ExecuteCallback] if you want to be notified about the result. |
|
|
|
/// [MediaInformationSessionCompleteCallback] if you want to be notified about the result. |
|
|
|
static Future<MediaInformationSession> getMediaInformationFromCommandAsync( |
|
|
|
static Future<MediaInformationSession> getMediaInformationFromCommandAsync( |
|
|
|
String command, |
|
|
|
String command, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
[MediaInformationSessionCompleteCallback? completeCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
int? waitTimeout = null]) async => |
|
|
|
int? waitTimeout = null]) async => |
|
|
|
FFprobeKit.getMediaInformationFromCommandArgumentsAsync( |
|
|
|
FFprobeKit.getMediaInformationFromCommandArgumentsAsync( |
|
|
|
FFmpegKitConfig.parseArguments(command), |
|
|
|
FFmpegKitConfig.parseArguments(command), |
|
|
|
executeCallback, |
|
|
|
completeCallback, |
|
|
|
logCallback, |
|
|
|
logCallback, |
|
|
|
waitTimeout); |
|
|
|
waitTimeout); |
|
|
|
|
|
|
|
|
|
|
@ -182,16 +180,16 @@ class FFprobeKit { |
|
|
|
/// information from it. |
|
|
|
/// information from it. |
|
|
|
/// |
|
|
|
/// |
|
|
|
/// Note that this method returns immediately and does not wait the execution |
|
|
|
/// Note that this method returns immediately and does not wait the execution |
|
|
|
/// to complete. You must use an [ExecuteCallback] if you want to be |
|
|
|
/// to complete. You must use an [MediaInformationSessionCompleteCallback] if you want to be |
|
|
|
/// notified about the result. |
|
|
|
/// notified about the result. |
|
|
|
static Future<MediaInformationSession> |
|
|
|
static Future<MediaInformationSession> |
|
|
|
getMediaInformationFromCommandArgumentsAsync( |
|
|
|
getMediaInformationFromCommandArgumentsAsync( |
|
|
|
List<String> commandArguments, |
|
|
|
List<String> commandArguments, |
|
|
|
[ExecuteCallback? executeCallback = null, |
|
|
|
[MediaInformationSessionCompleteCallback? completeCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
LogCallback? logCallback = null, |
|
|
|
int? waitTimeout = null]) async { |
|
|
|
int? waitTimeout = null]) async { |
|
|
|
final session = await MediaInformationSession.create( |
|
|
|
final session = await MediaInformationSession.create( |
|
|
|
commandArguments, executeCallback, logCallback); |
|
|
|
commandArguments, completeCallback, logCallback); |
|
|
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.asyncGetMediaInformationExecute(session, waitTimeout); |
|
|
|
await FFmpegKitConfig.asyncGetMediaInformationExecute(session, waitTimeout); |
|
|
|
|
|
|
|
|
|
|
@ -199,10 +197,10 @@ class FFprobeKit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Lists all FFprobe sessions in the session history. |
|
|
|
/// Lists all FFprobe sessions in the session history. |
|
|
|
static Future<List<FFprobeSession>> listSessions() async { |
|
|
|
static Future<List<FFprobeSession>> listFFprobeSessions() async { |
|
|
|
try { |
|
|
|
try { |
|
|
|
await FFmpegKitConfig.init(); |
|
|
|
await FFmpegKitConfig.init(); |
|
|
|
return _platform.ffprobeKitListSessions().then((sessions) { |
|
|
|
return _platform.ffprobeKitListFFprobeSessions().then((sessions) { |
|
|
|
if (sessions == null) { |
|
|
|
if (sessions == null) { |
|
|
|
return List.empty(); |
|
|
|
return List.empty(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -214,8 +212,32 @@ class FFprobeKit { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} on PlatformException catch (e, stack) { |
|
|
|
} on PlatformException catch (e, stack) { |
|
|
|
print("Plugin listSessions error: ${e.message}"); |
|
|
|
print("Plugin listFFprobeSessions error: ${e.message}"); |
|
|
|
return Future.error("listSessions failed.", stack); |
|
|
|
return Future.error("listFFprobeSessions failed.", stack); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Lists all MediaInformation sessions in the session history. |
|
|
|
|
|
|
|
static Future<List<MediaInformationSession>> |
|
|
|
|
|
|
|
listMediaInformationSessions() async { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
await FFmpegKitConfig.init(); |
|
|
|
|
|
|
|
return _platform |
|
|
|
|
|
|
|
.ffprobeKitListMediaInformationSessions() |
|
|
|
|
|
|
|
.then((sessions) { |
|
|
|
|
|
|
|
if (sessions == null) { |
|
|
|
|
|
|
|
return List.empty(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return sessions |
|
|
|
|
|
|
|
.map((dynamic sessionObject) => FFmpegKitFactory.mapToSession( |
|
|
|
|
|
|
|
sessionObject as Map<dynamic, dynamic>)) |
|
|
|
|
|
|
|
.map((session) => session as MediaInformationSession) |
|
|
|
|
|
|
|
.toList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} on PlatformException catch (e, stack) { |
|
|
|
|
|
|
|
print("Plugin listMediaInformationSessions error: ${e.message}"); |
|
|
|
|
|
|
|
return Future.error("listMediaInformationSessions failed.", stack); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|