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.
71 lines
2.0 KiB
Dart
71 lines
2.0 KiB
Dart
import 'dart:math' as math;
|
|
import 'dart:ui' as ui;
|
|
|
|
import 'package:cutdex_sdk/runtime.dart';
|
|
import 'package:flutter/painting.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
Future<double> verifyEditedExport(
|
|
CutdexRuntime runtime, {
|
|
required Uri edited,
|
|
required Uri baseline,
|
|
}) async {
|
|
final editedMedia = MediaReference(id: 'edited', uri: edited);
|
|
final editedInfo = await runtime.probe(editedMedia);
|
|
expect(editedInfo.duration.seconds, closeTo(4, .1));
|
|
expect(editedInfo.audioTrackCount, 1);
|
|
final thumbnail = await runtime.thumbnail(
|
|
ThumbnailRequest(
|
|
media: editedMedia,
|
|
time: MediaTime(1, 1),
|
|
maximumWidth: 320,
|
|
maximumHeight: 180,
|
|
),
|
|
);
|
|
final image = await decodeImageFromList(thumbnail.data);
|
|
try {
|
|
final pixels = (await image.toByteData(
|
|
format: ui.ImageByteFormat.rawRgba,
|
|
))!;
|
|
// The authored half-size mask must leave the canvas corners black.
|
|
for (final at in [
|
|
0,
|
|
(image.width - 1) * 4,
|
|
(image.height - 1) * image.width * 4,
|
|
]) {
|
|
expect(
|
|
pixels.getUint8(at) + pixels.getUint8(at + 1) + pixels.getUint8(at + 2),
|
|
lessThan(35),
|
|
);
|
|
}
|
|
} finally {
|
|
image.dispose();
|
|
}
|
|
final originalWave = await runtime.waveform(
|
|
WaveformRequest(
|
|
media: MediaReference(id: 'baseline', uri: baseline),
|
|
baseBucketCount: 64,
|
|
levelCount: 1,
|
|
),
|
|
);
|
|
final editedWave = await runtime.waveform(
|
|
WaveformRequest(media: editedMedia, baseBucketCount: 64, levelCount: 1),
|
|
);
|
|
double rms(MediaWaveform wave) {
|
|
final values = [
|
|
for (final channel in wave.levels.first.channels)
|
|
for (var i = 2; i < channel.length; i += 3) channel[i],
|
|
];
|
|
return math.sqrt(
|
|
values.fold<double>(0, (sum, value) => sum + value * value) /
|
|
values.length,
|
|
);
|
|
}
|
|
|
|
final baseRms = rms(originalWave);
|
|
expect(baseRms, greaterThan(0));
|
|
final ratio = rms(editedWave) / baseRms;
|
|
expect(ratio, closeTo(math.pow(10, -6 / 20).toDouble(), .08));
|
|
return ratio;
|
|
}
|