JJ_MKVMaker/lib/services/media_tool.dart

41 lines
1.2 KiB
Dart

import '../core/models.dart';
/// 진행률 콜백 (0.0 ~ 1.0)
typedef ProgressCallback = void Function(double progress);
class MediaToolException implements Exception {
final String message;
const MediaToolException(this.message);
@override
String toString() => message;
}
/// FFmpeg / FFprobe 실행 경계.
///
/// Windows: 동봉한 ffmpeg.exe 를 프로세스로 실행
/// Android: (이식 시) 앱에 포함한 FFmpeg 라이브러리로 구현
abstract class MediaTool {
/// 사용 가능 여부와 버전 문자열
Future<String?> version();
Future<MediaInfo> probe(String path);
/// 사용 가능한 인코더 이름 목록 (libx264, libx265 ...)
Future<Set<String>> encoders();
/// FFmpeg 실행. [duration] 이 있으면 진행률을 계산해 [onProgress] 로 알린다.
/// [tag] (239): 이 실행만 골라 취소할 때 ([cancelTagged]) 쓰는 표 (예: 만드는 동영상)
Future<void> runFfmpeg(
List<String> args, {
Duration? duration,
ProgressCallback? onProgress,
Object? tag,
});
/// 실행 중인 작업 취소
void cancel();
/// 239: [tag] 를 붙여 실행한 것만 취소 (동시에 도는 다른 것은 그대로)
void cancelTagged(Object tag);
}