getModel method

Future<FFProbeDataModel> getModel(
  1. String filepath
)

Implementation

Future<FFProbeDataModel> getModel(String filepath) async {
  final resolvedPath = await checkFileExists(filepath).resolveSymbolicLinks();

  final res = await runAsync([
    "-i", resolvedPath,
    "-print_format", "json", //
    "-loglevel", "info", // Printed to stderr
    "-show_streams",
    "-show_format",
  ]);

  if (0 != res.exitCode) {
    throw CliResultException(
      exitCode: res.exitCode,
      stderr: res.stderr,
      message: switch (res.exitCode) {
        1 => "The probing probably failed, because the "
            "file at '$resolvedPath' is not a media file",
        _ => null,
      },
    );
  }

  final json = jsonDecode(res.stdout) as Map<String, dynamic>;
  return FFProbeDataModel.fromJson(json);
}