process method
Future<VideoEncodingConvertEntity>
process(
- Map<
String, List< transformers, {VideoTransformation> > - bool? storeMode,
Run a processing job
transformers
is a Map with video id
and list of VideoTransformation
When storeMode
is set to false
, the outputs will only be available for 24 hours.
Example:
...
final videoEncoding = ApiVideoEncoding(options);
final result = await videoEncoding.process({
'video-id-1': [
CutTransformation(
const const Duration(seconds: 10),
length: const Duration(
seconds: 30,
),
)
],
'video-id-2': [
VideoResizeTransformation(const Size(512, 384)),
VideoThumbsGenerateTransformation(10),
]
})
...
Implementation
Future<VideoEncodingConvertEntity> process(
Map<String, List<VideoTransformation>> transformers, {
bool? storeMode,
}) async {
final request = createRequest('POST', buildUri('$apiUrl/convert/video/'))
..body = jsonEncode({
'paths': transformers.entries.map((entry) {
assert(() {
return !entry.value.any((transformation) =>
transformation is QualityTransformation &&
transformation.value == QualityTValue.Smart);
}(), 'QualityTValue.Smart cannot be used with VideoTransformation');
return PathTransformer('${entry.key}/video',
transformations: entry.value
..sort((a, b) =>
b is VideoThumbsGenerateTransformation ? -1 : 1))
.path;
}).toList(),
'store': resolveStoreModeParam(storeMode),
});
return VideoEncodingConvertEntity.fromJson(
await resolveStreamedResponse(request.send()),
);
}