getExportFilters method
String
getExportFilters({
- VideoExportFormat? videoFormat,
- double scale = 1.0,
- bool isFiltersEnabled = true,
Returns the -filter:v
command to use in ffmpeg execution
Implementation
String getExportFilters({
VideoExportFormat? videoFormat,
double scale = 1.0,
bool isFiltersEnabled = true,
}) {
if (!isFiltersEnabled) return "";
// CALCULATE FILTERS
final bool isGif =
videoFormat?.extension == VideoExportFormat.gif.extension;
final String scaleInstruction =
scale == 1.0 ? "" : "scale=iw*$scale:ih*$scale";
// VALIDATE FILTERS
final filters = [
crop,
scaleInstruction,
rotation,
isGif
? "fps=${videoFormat is GifExportFormat ? videoFormat.fps : VideoExportFormat.gif.fps}"
: "",
]..removeWhere((item) => item.isEmpty);
return filters.isNotEmpty
? "-vf ${filters.join(",")}${isGif ? " -loop 0" : ""}"
: "";
}