Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
20 lines
685 B
Dart
20 lines
685 B
Dart
import 'package:cutdex/errors/app_failure.dart';
|
|
|
|
import 'package:cutdex_sdk/runtime.dart';
|
|
import 'package:cutdex_sdk/timeline/model.dart';
|
|
|
|
/// Convert source metadata once, without extending the range past its end.
|
|
RationalTime mediaTimelineDuration(MediaTime duration) {
|
|
final ticks =
|
|
BigInt.from(duration.numerator) *
|
|
BigInt.from(TimelineClock.ticksPerSecond) ~/
|
|
BigInt.from(duration.denominator);
|
|
if (ticks <= BigInt.zero) {
|
|
throw AppException(AppErrorCode.invalidMediaDuration);
|
|
}
|
|
if (ticks > BigInt.from(0x7fffffffffffffff)) {
|
|
throw AppException(AppErrorCode.mediaDurationOutOfRange);
|
|
}
|
|
return RationalTime.timelineTicks(ticks.toInt());
|
|
}
|