render static method
Future<String>
render({
- required List<
VideoEditorClip> clips, - required List<
VideoEditorAudioTrack> audioTracks, - required List<
VideoEffectOverlay> effectOverlays, - required VideoAspectRatio aspectRatio,
- required PreviewSegmentCache cache,
- RenderProgressCallback? onProgress,
- bool isStale()?,
Renders the preview and returns the path of a preview_*.mp4 file.
onProgress reports 0..1 over all the work still to do. isStale is
checked between steps; when it returns true the render stops with
RenderCancelledException (finished segments stay cached).
Implementation
static Future<String> render({
required List<VideoEditorClip> clips,
required List<VideoEditorAudioTrack> audioTracks,
required List<VideoEffectOverlay> effectOverlays,
required VideoAspectRatio aspectRatio,
required PreviewSegmentCache cache,
RenderProgressCallback? onProgress,
bool Function()? isStale,
}) async {
if (clips.isEmpty) return '';
final hardware = await VideoRenderService.hardwareEncoderAvailable();
try {
return await _render(
clips: clips,
audioTracks: audioTracks,
effectOverlays: effectOverlays,
aspectRatio: aspectRatio,
cache: cache,
hardware: hardware,
onProgress: onProgress,
isStale: isStale,
);
} on RenderException catch (e) {
if (!hardware) rethrow;
// Segments from two encoders must not be joined: start over with x264.
debugPrint('Hardware preview failed, using x264: ${e.message}');
VideoRenderService.disableHardwareEncoder();
cache.clear();
return _render(
clips: clips,
audioTracks: audioTracks,
effectOverlays: effectOverlays,
aspectRatio: aspectRatio,
cache: cache,
hardware: false,
onProgress: onProgress,
isStale: isStale,
);
}
}