[mob] video editor fixes (#5091)

## Description

Previously video editor was giving subpar quality videos, this fixes it
and also re-encodes videos using libx264 mp4 format.

This will also increase the time to process the edited video.

## Tests
This commit is contained in:
Neeraj 2025-02-18 14:17:15 +05:30 committed by GitHub
commit d09613a946
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -209,15 +209,14 @@ class _VideoEditorPageState extends State<VideoEditorPage> {
final config = VideoFFmpegVideoEditorConfig(
_controller!,
format: VideoExportFormat(
path.extension(widget.ioFile.path).substring(1),
),
// commandBuilder: (config, videoPath, outputPath) {
// final List<String> filters = config.getExportFilters();
// filters.add('hflip'); // add horizontal flip
format: VideoExportFormat.mp4,
commandBuilder: (config, videoPath, outputPath) {
final List<String> filters = config.getExportFilters();
// return '-i $videoPath ${config.filtersCmd(filters)} -preset ultrafast $outputPath';
// },
final String startTrimCmd = "-ss ${_controller!.startTrim}";
final String toTrimCmd = "-t ${_controller!.trimmedDuration}";
return '$startTrimCmd -i $videoPath $toTrimCmd ${config.filtersCmd(filters)} -c:v libx264 -c:a aac $outputPath';
},
);
try {
@ -241,12 +240,12 @@ class _VideoEditorPageState extends State<VideoEditorPage> {
await PhotoManager.stopChangeNotify();
try {
final AssetEntity? newAsset =
final AssetEntity newAsset =
await (PhotoManager.editor.saveVideo(result, title: fileName));
result.deleteSync();
final newFile = await EnteFile.fromAsset(
widget.file.deviceFolder ?? '',
newAsset!,
newAsset,
);
newFile.creationTime = widget.file.creationTime;