export method
Implementation
Future<bool> export(
String input,
int? fps,
String output,
int height,
int width,
) async {
var h = '0';
var w = '0';
if (y == null || y == height) {
h = 'H-h';
} else {
final _h = height / 2;
if (y == _h) {
h = '(H-h)/2';
} else if (y! < _h) {
h = '(H-h)/2-${_h - y!}';
} else if (y! > _h) {
h = '(H-h)/2+${y! - _h}';
}
}
if (x == null || x == width) {
w = 'W-w';
} else {
final _w = width / 2;
if (x == _w) {
w = '(W-w)/2';
} else if (x! < _w) {
w = '(W-w)/2-${_w - x!}';
} else if (x! > _w) {
w = '(W-w)/2+${x! - _w}';
}
}
final overlay = 'overlay=$w:$h';
final buffer = StringBuffer();
if (opacity != null) {
buffer.write('"$overlay:alpha=$opacity"');
} else {
buffer.write('"$overlay,"');
}
if (scale != null) {
buffer.write('"scale=iw*$scale:ih*$scale;"');
}
return ffmpeg.execute([
'-i',
input,
if (fps != null) ...['-r', '$fps'],
'-i',
await _getPath(),
'-filter_complex',
buffer.toString(),
output,
'-y'
]);
}