Build Android (FCM) / build-android-fcm (push) Canceled after 0s
Build Android / build-android (push) Canceled after 0s
Build iOS / build-ios (push) Canceled after 0s
Build Linux / build-linux (push) Canceled after 0s
Build macOS / build-macos (push) Canceled after 0s
Build Windows / build-windows (push) Canceled after 0s
Release (main) / android (oneme) (push) Canceled after 0s
Release (main) / android (qlyra) (push) Canceled after 0s
Release (main) / windows (push) Canceled after 0s
Release (main) / linux (push) Canceled after 0s
Release (main) / macos (push) Canceled after 0s
Release (main) / ios (push) Canceled after 0s
Release (main) / release (push) Canceled after 0s
32 lines
1.1 KiB
Dart
32 lines
1.1 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import '../utils/logger.dart';
|
|
|
|
/// Центр-кроп записанного видео в квадрат для видеосообщений-кружков.
|
|
/// Выполняется нативно: на Android — media3 Transformer, на iOS —
|
|
/// AVAssetExportSession. Без искажений: заполняет квадрат и обрезает
|
|
/// лишнее по бокам. На других платформах возвращает `null`.
|
|
class VideoNoteCropper {
|
|
static const _channel = MethodChannel('ru.qlyra.app/video');
|
|
|
|
static Future<String?> cropSquare(String input, {int size = 480}) async {
|
|
if (!Platform.isAndroid && !Platform.isIOS) return null;
|
|
try {
|
|
final dot = input.lastIndexOf('.');
|
|
final base = dot > 0 ? input.substring(0, dot) : input;
|
|
final output = '${base}_sq.mp4';
|
|
final res = await _channel.invokeMethod<String>('cropSquare', {
|
|
'input': input,
|
|
'output': output,
|
|
'size': size,
|
|
});
|
|
return res;
|
|
} catch (e) {
|
|
logger.w('VideoNoteCropper: $e');
|
|
return null;
|
|
}
|
|
}
|
|
}
|