Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cSpell.words": [
"bbox",
"Bezier",
"bitrate",
"Cooldown",
"diegotori",
"dismissibility",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 51 additions & 26 deletions example/lib/features/video_examples/mixins/video_editor_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:path_provider/path_provider.dart';
import 'package:pro_image_editor/core/platform/io/io_helper.dart';
import 'package:pro_image_editor/pro_image_editor.dart';
import 'package:pro_video_editor/pro_video_editor.dart';
import 'package:pro_video_editor/pro_video_editor.dart' as pve;

import '../constants/example_audio_tracks_constant.dart';

Expand Down Expand Up @@ -361,37 +362,63 @@ mixin VideoEditorMixin<T extends StatefulWidget> on State<T> {
final stopwatch = Stopwatch()..start();
final directory = await getTemporaryDirectory();

// Convert video clips to video segments
final videoSegments = parameters.videoClips.map((clip) {
return VideoSegment(
video: EditorVideo.autoSource(
assetPath: clip.clip.assetPath,
byteArray: clip.clip.bytes,
file: clip.clip.file,
networkUrl: clip.clip.networkUrl,
),
startTime: clip.trimSpan?.start,
endTime: clip.trimSpan?.end,
);
}).toList();

// Extract custom audio path and volume settings
// Extract custom audio path and volume settings.
final customAudioPath =
await _safeCustomAudioPath(parameters.customAudioTrack, directory.path);
final audioVolumes = _calculateAudioVolumes(parameters.customAudioTrack);

// Use videoSegments when multiple clips exist, otherwise use single video
final useSegments = videoSegments.length > 1;
final hasSingleClip = parameters.videoClips.length == 1;
final videoSegments = parameters.videoClips.isNotEmpty
? parameters.videoClips.map((clip) {
return VideoSegment(
video: EditorVideo.autoSource(
assetPath: clip.clip.assetPath,
byteArray: clip.clip.bytes,
file: clip.clip.file,
networkUrl: clip.clip.networkUrl,
),
startTime:
hasSingleClip ? parameters.startTime : clip.trimSpan?.start,
endTime: hasSingleClip ? parameters.endTime : clip.trimSpan?.end,
volume: audioVolumes.originalVolume,
);
}).toList()
: <VideoSegment>[
VideoSegment(
video: video,
startTime: parameters.startTime,
endTime: parameters.endTime,
volume: audioVolumes.originalVolume,
),
];

final imageLayers = parameters.layers.isNotEmpty
? <pve.ImageLayer>[
pve.ImageLayer(
image: pve.EditorLayerImage.memory(parameters.image),
),
]
: const <pve.ImageLayer>[];

final audioTracks = customAudioPath != null
? <pve.VideoAudioTrack>[
pve.VideoAudioTrack(
path: customAudioPath,
volume: audioVolumes.customVolume,
loop: true,
startTime: parameters.customAudioTrack?.startTime,
),
]
: const <pve.VideoAudioTrack>[];

var exportModel = VideoRenderData(
id: taskId,
video: useSegments ? null : video,
videoSegments: useSegments ? videoSegments : null,
imageBytes: parameters.layers.isNotEmpty ? parameters.image : null,
videoSegments: videoSegments,
imageLayers: imageLayers,
blur: parameters.blur,
colorMatrixList: [parameters.colorFiltersCombined],
startTime: useSegments ? null : parameters.startTime,
endTime: useSegments ? null : parameters.endTime,
colorFilters: <pve.ColorFilter>[
pve.ColorFilter(matrix: parameters.colorFiltersCombined),
],
transform: parameters.isTransformed
? ExportTransform(
width: parameters.cropWidth,
Expand All @@ -406,9 +433,7 @@ mixin VideoEditorMixin<T extends StatefulWidget> on State<T> {
enableAudio: proVideoController?.isAudioEnabled ?? true,
outputFormat: outputFormat,
bitrate: videoMetadata.bitrate,
customAudioPath: customAudioPath,
originalAudioVolume: audioVolumes.originalVolume,
customAudioVolume: audioVolumes.customVolume,
audioTracks: audioTracks,
);

final now = DateTime.now().millisecondsSinceEpoch;
Expand Down
2 changes: 0 additions & 2 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import gal
import media_kit_libs_macos_video
import media_kit_video
import package_info_plus
import path_provider_foundation
import pro_image_editor
import pro_video_editor
import shared_preferences_foundation
Expand All @@ -39,7 +38,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
MediaKitLibsMacosVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosVideoPlugin"))
MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ProImageEditorPlugin.register(with: registry.registrar(forPlugin: "ProImageEditorPlugin"))
ProVideoEditorPlugin.register(with: registry.registrar(forPlugin: "ProVideoEditorPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies:
vibration: ^3.1.1

# Video-Editing
pro_video_editor: ^1.6.0
pro_video_editor: ^1.11.0
audioplayers: ^6.5.1
### Choose one player below
video_player: ^2.10.0
Expand Down
Loading