V- Modal AI: Visual Video / Image Search - Flutter Video SDK
Dart android-sdkflutterflutter-appflutter-packageflutter-sdkflutter-videoflutter-video-editingflutter-video-playerflutter-video-sdkflutter-videosflutter-videosdkmobile-videomobile-video-editor-sdkmobile-video-sdkvideo-editingvideo-sdkvideo-searchvideo-search-enginevideo-streaming
Release Flutter SDK from ab0b046c7287919a75e4d9503f67ddb6e06b37e4
vmodal-release-app0809511a9f73
diff --git a/RELEASE_METADATA b/RELEASE_METADATAindex 67f48c9..1c0b840 100644--- a/RELEASE_METADATA+++ b/RELEASE_METADATA@@ -1 +1 @@-Source-vmx-api: 29cc6d52fe76510c69f865a8bafc4b0c541991ed+Source-vmx-api: ab0b046c7287919a75e4d9503f67ddb6e06b37e4diff --git a/SOURCE_MANIFEST.sha256 b/SOURCE_MANIFEST.sha256index 2458e5e..1b61f85 100644--- a/SOURCE_MANIFEST.sha256+++ b/SOURCE_MANIFEST.sha256@@ -4,8 +4,8 @@ a98f72526420d47e76b9b4e67ac86acd06b7088ad1f4c35617b11b09e59346ea ./.gitleaks.to5115d06bd9913f466d50fcbf8ad8890372349060c54a4581f3481ea084cfdec6 ./.pubignore0e35aa931a7e39b40c6bac4c0a4ee4ddc6e0de1e26d8f0a47d4f7e72326f3574 ./CHANGELOG.md37b7148216ac6090e36adfb699d642b8dd1e1b8ba99870e65e88733947a59fa6 ./LICENSE-1be06a25568413c841ecaa731b6ff438a435b2f6597ecaafac1f9af9d2f910b1 ./README.md-b49d12f61e804993865ca5d4e20346388af2be332ad034fcc0c6776aceed1846 ./RELEASE_METADATA+255ed17c4382a0475ed1c9045326576f317aae45ffe6610b04fcbf000383a539 ./README.md+898841030ca942c182063684a15043f14711683540cd48cc2b1e561fd9f569fd ./RELEASE_METADATAdef7e4f643adff5b01b877b6a7fa5b2381612b693c0bf06bd232ee0f7197d342 ./analysis_options.yaml8c2d096dc399d9bea2fcc5ae19d987e7458c8503cf2a7edf1f1497ae00d681aa ./build.sh4f18642680fb433554a5523d00bd99e0d650af340bcaebe628f59f63ac84e458 ./dartdoc_options.yaml@@ -14,6 +14,7 @@ cae6114908952cf81a908b7fcc8c0ba4ce3f866e9dbaf974303273f334e0e3f6 ./doc/release.9658204ef997b490bc8634b919fbbe01e53455aa65e3bfef4010d3be798c8e9d ./doc/sdk_contract.md2c07c5319044416d722732f731cc709fc6f6f3e375861bb6b5326a8768258de5 ./doc/sdk_doc.md67e61ba8626a46ccf7de847a39f4900bdb2a2d36b0102b5ad703ca5a5ef05080 ./doc/search_app.md+7b0acfc01cfa4c8bf3af8aeb19741e65b8e9406935d9ab8e0f4cb84547483e55 ./doc/transcode_360.mde246ed229511a24a1ee7e98529c203ef90d1d352290ce8486caebe05683db3a0 ./env.shc5ce516b547327aab5b6fa27a523d4c76e66294ada3248b293c54b9595cd3a87 ./example/01_full_app/.metadata7b50a141c330c810a229422ca37d5ca28d34b9a9ec2ac701ec38d7bb1f49c8fb ./example/01_full_app/README.md@@ -95,20 +96,21 @@ fa541e11cb4b9b791630b658c6856743ec4c31d957deb285ed031e7d4c2d48c6 ./example/02_u7becacd31a8d134fa435b39cd819798d5fbf58f89b9f30c50362e2dcf757aaed ./lib/src/adaptive_upload.dart9464fff0c519a1ce70cddefb3e3eaa95d07b97ccdaf5b8381c01d7c88767ae83 ./lib/src/api_key_provider.dartd796fc674bb0b8c784fac0f0470b6ff816c98d9ace4b90f593912e5479e45d4e ./lib/src/client.dart-ef4f3226baaefde24d45c7b4d8e9592665d85e1abbdafae4c7e59c462fd42b7d ./lib/src/collection_uploads.dart+0058facd770c5785cc8afcb747683a74962eccc212e2454cf6176d4f90925a07 ./lib/src/collection_uploads.dart58e4e7162a6c46d2981935649a3f1d40c969dc1fc3a81cab34f518673a479e6a ./lib/src/config.dartd3e03d9a72a499659c70f2296115d1d3138b9370a017e027d8255f85f7fb1c5c ./lib/src/content_scope.dart873d969cfed5c725d34df0fd0c8769462b56992cf523710fcf741a81fa1bbcad ./lib/src/errors.dart2ad9b4183bce96eacd91c5514de9231b1f0a4f269392726e174507cfa507981a ./lib/src/http.dart-52d09295f014fc4f8f8ff1ad714a8be830729b7e29cd6aa5421678e58edd2f0e ./lib/src/models.dart+7670598bf28a23808d0e0bd3e3ea1ec7270fbc450caef2ecc1c0ab0921d17538 ./lib/src/models.darted22b7665e09c9f2f4158c225affe6527b7d3eb921db0ccdf06c01c8cf31db96 ./lib/src/resources.dart43770c621bffccf69eacebd1e3b297503ca288093c848f0e8ccbd118d7f0d88a ./lib/src/routes.dart27056230065682f3ea3aa747c39c08950dcdca87387f4733adfad18f4b345b06 ./lib/src/routes.g.dart+42331852249c8f99874a5e3889c752fd344ad8a5301ede246d5a4fbccb4191f2 ./lib/src/transcode.dartf0e69d1016f82fbad2a96434129a54a0129f095a0e138cce555db37c8120023f ./lib/src/transport.dart-d407a3846da3236f37c5dc6af6c231116cc4f23844f623eb22db5365c6616bb5 ./lib/src/upload.dart+b32d388d73edf7d824cc4391b6af55c21a20bcb1e721d66afca1a69b559287f4 ./lib/src/upload.dart732e7f2f942e1c427e19ee3bdb766053f625f69e87dcf770d969555dbc7a9881 ./lib/src/utils.dartb226ddcc0b8cb58b4753545752c2df1c6301bdf76842730e7f6ecf2d06d29892 ./lib/src/vmodal.dart-120c8c5cd98d4aebaa4fe39525c1370b53bc89413ab54d73a8ea642d661555ea ./lib/vmodal_sdk_flutter.dart+5cc38f87cde8643b914a6f54f2e691d4c12a36533be9177ae6174905055230f7 ./lib/vmodal_sdk_flutter.dart72fff91181fd3e25fd9afd766930a67025205b61096fd35c55cbdd9a3178ecf0 ./pubspec.lock2b969fbd1d82d89a5dc7822032ce9fe0df4bda625da969bc8e93c57e43fcf2c2 ./pubspec.yamla80b38547f5d9ca1874f60e71c648e3fc12ab5f7cb88d1bead6d5b863d3c0245 ./readme_assets/dev_homepage.jpg@@ -130,6 +132,7 @@ cfcc97997e08295d08e08f27b3ad860088075f3822947f6b6200553847f859ec ./test/new_api86b093ffdab0bc6b2d412cd8f41667058bbc1117cedae9082d2635e98ef6488e ./test/regression_manifest_test.dartec2d3ab09457fdccf30fc338585b89cf466f5d8f7fc8ce5f6c0ae52357390277 ./test/resources_models_test.dart8619ce113bb8669612f9a2a16b1b334ac68435c5972e84828a789511467fcb77 ./test/shell_scripts_test.dart+7f698c5a5eef265a5b24dbae4b48a0e57dd64a998275658c1ac6aec3aa733147 ./test/transcode_upload_test.dart79e3de3c03451cd9d62327430106edf861da6aeb97b546bbac2d93a0bcbbe3d3 ./test/transport_test.dartc13557f89597f0be73f48dc8463aa7513e9e814c0e6a0ab871e441834687abb1 ./test/upload_test.dartaf4a5b0eaca0bc1b2ef86cb88900fb67185b619cd90e6b5598ff9276a147d0b5 ./test/workflow_layout_test.dartdiff --git a/doc/transcode_360.md b/doc/transcode_360.mdnew file mode 100644index 0000000..e46d4f6--- /dev/null+++ b/doc/transcode_360.md@@ -0,0 +1,93 @@+# Pre-upload 360px video transcode++The SDK can reduce a video to a smaller resolution (longer side = 360px) *before*+uploading, to cut upload bytes. The core package stays free of native code: it owns only+the `VideoTranscoder` interface and the upload lifecycle. **By default there is no+transcoding** (`PassthroughVideoTranscoder`). Your app injects a real reducer.++This mirrors the Python SDK `video_upload(reduce_size=...)` contract.++## Contract++- Provide a **file-backed** source: `UploadSource.fromFile(File(path))`. A non-passthrough+ transcoder on a stream-only source raises `ValidationException`.+- Set the transcoder in options: `VideoUploadOptions(transcoder: My360Transcoder())`.+- Your `reduce(File input)` returns a `TranscodeResult(output, reused: ...)`:+ - return `input` unchanged for an identity passthrough (no cleanup);+ - return a **new** file to upload that temp instead — the SDK deletes it after a+ successful upload and leaves your original untouched;+ - set `reused: true` when you served a cached reduced file.+- The 100 MB limit is checked against the **original** file first.++## Response fields (parity with Python)++On `VideoUploadResponse`:++- `reduceSize` — true when a reduce path ran.+- `sizeBytes` — bytes actually uploaded (the temp).+- `sourceSizeBytes` — original file size.+- `sourceFilePath` / `filePath` — the original local path.+- `temporaryFileDeleted` — true when a produced temp was deleted.+- `temporaryFileReused` — true when the reduced file came from your cache.++## App-side example++Add a transcoding plugin to your **app** `pubspec.yaml` (the SDK does not depend on it),+for example `ffmpeg_kit_flutter` or `video_compress`, then implement `VideoTranscoder`:++```dart+import 'dart:io';+import 'package:ffmpeg_kit_flutter/ffmpeg_kit.dart';+import 'package:path_provider/path_provider.dart';+import 'package:vmodal_sdk_flutter/vmodal_sdk_flutter.dart';++/// Reduces a video so its longer side is 360px, writing an mp4 to the temp dir.+class Ffmpeg360Transcoder implements VideoTranscoder {+ @override+ bool get isPassthrough => false;++ @override+ Future<TranscodeResult> reduce(File input) async {+ final dir = await getTemporaryDirectory();+ final out = File('${dir.path}/${input.uri.pathSegments.last}.360.mp4');+ if (out.existsSync() && out.lengthSync() > 0) {+ return TranscodeResult(out, reused: true); // served from cache+ }+ // Longer side -> 360, keep aspect, even dimensions.+ const scale =+ "scale='if(gte(iw,ih),min(360,iw),-2)':'if(gte(iw,ih),-2,min(360,ih))'";+ await FFmpegKit.execute(+ "-y -i '${input.path}' -vf \"$scale\" "+ '-c:v libx264 -preset veryfast -crf 28 -pix_fmt yuv420p '+ "-c:a aac -b:a 96k -movflags +faststart '${out.path}'",+ );+ return TranscodeResult(out);+ }+}+```++Use it through a scope:++```dart+final task = project+ .scope(collectionName: 'user_123', streamName: 'clips')+ .upload(+ UploadSource.fromFile(File('/path/to/clip.mp4')),+ options: ScopedUploadOptions(+ uploadOptions: VideoUploadOptions(transcoder: Ffmpeg360Transcoder()),+ ),+ );+final res = await task.result;+assert(res.reduceSize == true);+```++Or call the client extension directly:++```dart+final task = client.collections.videoUpload(+ UploadSource.fromFile(File('/path/to/clip.mp4')),+ collectionName: 'user_123',+ subCollectionName: 'clips',+ options: VideoUploadOptions(transcoder: Ffmpeg360Transcoder()),+);+```diff --git a/lib/src/collection_uploads.dart b/lib/src/collection_uploads.dartindex 319a3d7..929f50b 100644--- a/lib/src/collection_uploads.dart+++ b/lib/src/collection_uploads.dart@@ -1,5 +1,6 @@import 'dart:async';import 'dart:convert';+import 'dart:io';import 'dart:math';import 'package:crypto/crypto.dart';@@ -9,6 +10,7 @@ import 'errors.dart';import 'models.dart';import 'resources.dart';import 'routes.dart';+import 'transcode.dart';import 'transport.dart';import 'upload.dart';import 'utils.dart';@@ -29,6 +31,7 @@ class VideoUploadOptions {this.resume = true,this.sessionStore,this.adaptiveConditions,+ this.transcoder = const PassthroughVideoTranscoder(),});/// Enables experimental multipart upload behavior.@@ -58,6 +61,13 @@ class VideoUploadOptions {/// Optional device/network snapshot for adaptive preset selection.final UploadConditions? adaptiveConditions;+ /// Pre-upload reducer; defaults to [PassthroughVideoTranscoder] (no transcode).+ ///+ /// A non-passthrough transcoder requires a file-backed source+ /// ([UploadSource.fromFile]) and produces the parity fields on+ /// [VideoUploadResponse] mirroring the Python `video_upload(reduce_size=...)`.+ final VideoTranscoder transcoder;+/// Effective checkpoint store.UploadSessionStore get store => sessionStore ?? UploadSessionStores.memory;@@ -84,6 +94,7 @@ class VideoUploadOptions {bool? resume,UploadSessionStore? sessionStore,UploadConditions? adaptiveConditions,+ VideoTranscoder? transcoder,}) => VideoUploadOptions(multipart: multipart ?? this.multipart,multipartThresholdBytes:@@ -95,10 +106,20 @@ class VideoUploadOptions {resume: resume ?? this.resume,sessionStore: sessionStore ?? this.sessionStore,adaptiveConditions: adaptiveConditions ?? this.adaptiveConditions,+ transcoder: transcoder ?? this.transcoder,);- /// Validates multipart constraints for a source of [size] bytes.+ /// Max size for a single video upload (100 MB). Larger files are rejected.+ static const int maxVideoUploadBytes = 100 * 1024 * 1024;++ /// Validates the source [size] and multipart constraints.void validate(int size) {+ if (size > maxVideoUploadBytes) {+ throw ValidationException(+ 'video file too large: $size bytes exceeds the '+ '$maxVideoUploadBytes bytes (100 MB) limit',+ );+ }if (!multipart) return;if (partSizeBytes < 5 * 1024 * 1024) {throw const ValidationException('part_size_bytes must be at least 5 MiB');@@ -254,6 +275,19 @@ extension CollectionUploads on CollectionsResource {CancellationToken cancellation,void Function(UploadProgress) emit,) async {+ if (!options.transcoder.isPassthrough) {+ return _transcodeUploadRun(+ source,+ collection,+ stream,+ mode,+ modality,+ ttl,+ options,+ cancellation,+ emit,+ );+ }if (!options.multipart) {return _singleUpload(source,@@ -287,6 +321,69 @@ extension CollectionUploads on CollectionsResource {}}+ /// Reduces the source with [options.transcoder], uploads the produced temp,+ /// deletes it, and augments the response with Python-parity reduce fields.+ Future<VideoUploadResponse> _transcodeUploadRun(+ UploadSource source,+ String collection,+ String stream,+ String mode,+ String modality,+ int ttl,+ VideoUploadOptions options,+ CancellationToken cancellation,+ void Function(UploadProgress) emit,+ ) async {+ final input = source.localFile;+ if (input == null) {+ throw const ValidationException(+ 'transcoding requires a file-backed source (UploadSource.fromFile)',+ );+ }+ final sourceSize = source.contentLength;+ final result = await options.transcoder.reduce(input);+ final produced = result.output.absolute.path != input.absolute.path;+ final temp = UploadSource.fromFile(+ result.output,+ contentType: source.contentType,+ );+ if (produced && temp.contentLength <= 0) {+ throw const ValidationException('transcoder produced an empty file');+ }+ final pass = options+ .copyWith(transcoder: const PassthroughVideoTranscoder())+ .resolvedFor(temp.contentLength);+ pass.validate(temp.contentLength);+ final res = await _videoUploadRun(+ temp,+ collection,+ stream,+ mode,+ modality,+ ttl,+ pass,+ cancellation,+ emit,+ );+ if (produced) {+ if (await result.output.exists()) await result.output.delete();+ if (await result.output.exists()) {+ throw const ApiException(+ 'upload completed but reduced temporary video still exists',+ );+ }+ }+ return VideoUploadResponse(<String, Object?>{+ ...res.raw,+ 'reduce_size': true,+ 'filepath_local': input.path,+ 'source_filepath_local': input.path,+ 'source_size_bytes': sourceSize,+ 'temporary_file_deleted': produced,+ 'temporary_file_reused': result.reused,+ });+ }+Future<VideoUploadResponse> _singleUpload(UploadSource source,String collection,diff --git a/lib/src/models.dart b/lib/src/models.dartindex 95de986..f21c55f 100644--- a/lib/src/models.dart+++ b/lib/src/models.dart@@ -549,7 +549,13 @@ class VideoUploadResponse extends JsonBackedResponse {partsUploaded = intValue(raw['parts_uploaded']),resumed = raw['resumed'] == true,attemptCount = intValue(raw['attempt_count']),- destPath = '${raw['dest_path'] ?? ''}';+ destPath = '${raw['dest_path'] ?? ''}',+ reduceSize = raw['reduce_size'] == true,+ filePath = '${raw['filepath_local'] ?? ''}',+ sourceFilePath = '${raw['source_filepath_local'] ?? ''}',+ sourceSizeBytes = intValue(raw['source_size_bytes']),+ temporaryFileDeleted = raw['temporary_file_deleted'] == true,+ temporaryFileReused = raw['temporary_file_reused'] == true;final String userId;final String key;@@ -568,6 +574,24 @@ class VideoUploadResponse extends JsonBackedResponse {final bool resumed;final int attemptCount;final String destPath;++ /// Whether the file was transcoded to a smaller temp before upload.+ final bool reduceSize;++ /// Original local file path (equals [sourceFilePath] when [reduceSize]).+ final String filePath;++ /// Path of the caller's original file before reduction.+ final String sourceFilePath;++ /// Size in bytes of the original file before reduction.+ final int sourceSizeBytes;++ /// Whether the produced temp was deleted after a successful upload.+ final bool temporaryFileDeleted;++ /// Whether the reduced file came from the transcoder's reuse cache.+ final bool temporaryFileReused;}/// Ordered results for a bulk signed upload.diff --git a/lib/src/transcode.dart b/lib/src/transcode.dartnew file mode 100644index 0000000..02a7982--- /dev/null+++ b/lib/src/transcode.dart@@ -0,0 +1,47 @@+import 'dart:io';++/// Outcome of a pre-upload video transcode.+///+/// [output] is the file to upload. When it equals the transcoder input the run+/// is an identity passthrough and nothing is deleted afterwards. [reused] is+/// `true` when the transcoder returned a previously-cached reduced file.+class TranscodeResult {+ /// Creates a result wrapping the [output] file.+ const TranscodeResult(this.output, {this.reused = false});++ /// File whose bytes are uploaded.+ final File output;++ /// Whether [output] came from a transcoder-side cache.+ final bool reused;+}++/// Optional on-device video reducer applied before a signed upload.+///+/// The core SDK stays free of native/plugin transcoding code: it owns only this+/// interface and the upload lifecycle. Apps inject a real 360px reducer+/// (ffmpeg_kit / video_compress) via [VideoUploadOptions.transcoder]; the+/// default is [PassthroughVideoTranscoder] (no transcoding).+abstract interface class VideoTranscoder {+ /// Returns the file to upload, reducing [input] when applicable.+ ///+ /// Returning a file whose path differs from [input] marks it a produced temp+ /// that the SDK deletes after a successful upload. Returning [input] itself is+ /// an identity passthrough.+ Future<TranscodeResult> reduce(File input);++ /// Whether this transcoder performs no work and can be skipped entirely.+ bool get isPassthrough => false;+}++/// Identity transcoder: uploads the original file unchanged.+class PassthroughVideoTranscoder implements VideoTranscoder {+ /// Creates the default no-op transcoder.+ const PassthroughVideoTranscoder();++ @override+ Future<TranscodeResult> reduce(File input) async => TranscodeResult(input);++ @override+ bool get isPassthrough => true;+}diff --git a/lib/src/upload.dart b/lib/src/upload.dartindex 678550a..a33d529 100644--- a/lib/src/upload.dart+++ b/lib/src/upload.dart@@ -22,6 +22,7 @@ class UploadSource {this.contentType = 'application/octet-stream',String? sourceId,this.versionTag = '',+ this.localFile,Stream<List<int>> Function(int offset)? rangeOpener,}) : sourceId = sourceId ?? fileName,_opener = opener,@@ -49,6 +50,7 @@ class UploadSource {contentType: contentType ?? guessContentType(name),sourceId: file.absolute.path,versionTag: '${stat.size}:${stat.modified.millisecondsSinceEpoch}',+ localFile: file,opener: file.openRead,rangeOpener: (int offset) => file.openRead(offset),);@@ -68,6 +70,11 @@ class UploadSource {/// Version marker used to reject stale resume checkpoints.final String versionTag;++ /// Backing file when this source was created by [UploadSource.fromFile].+ ///+ /// Required for pre-upload transcoding; `null` for stream-only sources.+ final File? localFile;final Stream<List<int>> Function() _opener;final Stream<List<int>> Function(int offset)? _rangeOpener;diff --git a/lib/vmodal_sdk_flutter.dart b/lib/vmodal_sdk_flutter.dartindex 62fb0f2..6be3e68 100644--- a/lib/vmodal_sdk_flutter.dart+++ b/lib/vmodal_sdk_flutter.dart@@ -38,6 +38,7 @@ export 'src/errors.dart';export 'src/models.dart';export 'src/resources.dart';export 'src/routes.dart' show RouteCategory, RouteSpec, Routes;+export 'src/transcode.dart';export 'src/transport.dart'showCancellationToken,diff --git a/test/transcode_upload_test.dart b/test/transcode_upload_test.dartnew file mode 100644index 0000000..928ec30--- /dev/null+++ b/test/transcode_upload_test.dart@@ -0,0 +1,147 @@+import 'dart:io';++import 'package:flutter_test/flutter_test.dart';+import 'package:vmodal_sdk_flutter/vmodal_sdk_flutter.dart';++import 'fakes.dart';++/// Writes [output] (a smaller temp) beside the input and reports it produced.+class FakeReduceTranscoder implements VideoTranscoder {+ FakeReduceTranscoder(this.output, {this.reused = false});++ final File output;+ final bool reused;+ int calls = 0;++ @override+ Future<TranscodeResult> reduce(File input) async {+ calls++;+ return TranscodeResult(output, reused: reused);+ }++ @override+ bool get isPassthrough => false;+}++VmodalClient _client(FakeTransport api, FakeSignedUploadTransport signed) =>+ VmodalClient(+ config: SdkConfig(baseUrl: 'https://gateway.test', token: 'key'),+ transport: api,+ signedUploadTransport: signed,+ );++void main() {+ test('passthrough default uploads the original, no reduce fields', () async {+ final dir = Directory.systemTemp.createTempSync('vmx_tc_');+ addTearDown(() => dir.deleteSync(recursive: true));+ final original = File('${dir.path}/a.mp4')..writeAsBytesSync(<int>[1, 2, 3, 4]);+ final api = FakeTransport()+ ..addResponse(+ jsonResponse('{"url":"https://objects.test/u","method":"PUT","key":"k"}'),+ )+ ..addResponse(jsonResponse('{"dest_path":"done/a.mp4"}'));+ final signed = FakeSignedUploadTransport()+ ..queued.add(const SignedUploadResult(statusCode: 200, etag: 'e'));+ final client = _client(api, signed);+ final result = await client.collections+ .videoUpload(+ UploadSource.fromFile(original),+ collectionName: 'g',+ subCollectionName: 's',+ )+ .result;+ expect(result.reduceSize, isFalse);+ expect(result.sizeBytes, 4);+ expect(result.temporaryFileDeleted, isFalse);+ expect(original.existsSync(), isTrue);+ });++ test('injected transcoder uploads temp, deletes it, sets parity fields', () async {+ final dir = Directory.systemTemp.createTempSync('vmx_tc_');+ addTearDown(() => dir.deleteSync(recursive: true));+ final original = File('${dir.path}/big.mp4')+ ..writeAsBytesSync(List<int>.filled(10, 7));+ final temp = File('${dir.path}/big.reduced.mp4')+ ..writeAsBytesSync(<int>[1, 2, 3]);+ final api = FakeTransport()+ ..addResponse(+ jsonResponse('{"url":"https://objects.test/u","method":"PUT","key":"k"}'),+ )+ ..addResponse(jsonResponse('{"dest_path":"done/big.mp4"}'));+ final signed = FakeSignedUploadTransport()+ ..queued.add(const SignedUploadResult(statusCode: 200, etag: 'e'));+ final client = _client(api, signed);+ final result = await client.collections+ .videoUpload(+ UploadSource.fromFile(original),+ collectionName: 'g',+ subCollectionName: 's',+ options: VideoUploadOptions(+ transcoder: FakeReduceTranscoder(temp),+ ),+ )+ .result;+ expect(result.reduceSize, isTrue);+ expect(result.sizeBytes, 3);+ expect(result.sourceSizeBytes, 10);+ expect(result.sourceFilePath, original.path);+ expect(result.filePath, original.path);+ expect(result.temporaryFileDeleted, isTrue);+ expect(result.temporaryFileReused, isFalse);+ expect(signed.calls.single.length, 3);+ expect(original.existsSync(), isTrue);+ expect(temp.existsSync(), isFalse);+ });++ test('reused flag propagates from the transcoder', () async {+ final dir = Directory.systemTemp.createTempSync('vmx_tc_');+ addTearDown(() => dir.deleteSync(recursive: true));+ final original = File('${dir.path}/c.mp4')+ ..writeAsBytesSync(List<int>.filled(8, 5));+ final temp = File('${dir.path}/c.reduced.mp4')..writeAsBytesSync(<int>[9, 9]);+ final api = FakeTransport()+ ..addResponse(+ jsonResponse('{"url":"https://objects.test/u","method":"PUT","key":"k"}'),+ )+ ..addResponse(jsonResponse('{"dest_path":"done/c.mp4"}'));+ final signed = FakeSignedUploadTransport()+ ..queued.add(const SignedUploadResult(statusCode: 200, etag: 'e'));+ final result = await _client(api, signed)+ .collections+ .videoUpload(+ UploadSource.fromFile(original),+ collectionName: 'g',+ subCollectionName: 's',+ options: VideoUploadOptions(+ transcoder: FakeReduceTranscoder(temp, reused: true),+ ),+ )+ .result;+ expect(result.temporaryFileReused, isTrue);+ expect(result.temporaryFileDeleted, isTrue);+ });++ test('stream-only source with a real transcoder is rejected', () async {+ final dir = Directory.systemTemp.createTempSync('vmx_tc_');+ addTearDown(() => dir.deleteSync(recursive: true));+ final temp = File('${dir.path}/t.mp4')..writeAsBytesSync(<int>[1]);+ final source = UploadSource(+ fileName: 'stream.mp4',+ contentLength: 2,+ sourceId: 'stream',+ opener: () => Stream<List<int>>.value(<int>[1, 2]),+ );+ final client = _client(FakeTransport(), FakeSignedUploadTransport());+ await expectLater(+ client.collections+ .videoUpload(+ source,+ collectionName: 'g',+ subCollectionName: 's',+ options: VideoUploadOptions(transcoder: FakeReduceTranscoder(temp)),+ )+ .result,+ throwsA(isA<ValidationException>()),+ );+ });+}