flutter_gpu_video_filters 0.0.20

SDKflutter
Platformandroid

Image filters based on OpenGL fragment shaders with useful video preview widgets

Flutter

Pub codecov build Star on Github License: MIT

A flutter package for Android for applying OpenGL filters to video.

Usage

How to generate and use a bunch of filters

How to add custom filters

Export & save video

import 'package:flutter_gpu_video_filters/flutter_gpu_video_filters.dart';

final inputSource = AssetInputSource('demo.mp4');
final output = File('result.mp4');
final configuration = GPUGrayScaleConfiguration();
final processStream =  configuration.exportVideoFile(VideoExportConfig(AssetInputSource(asset), output));
await for (final progress in processStream) {
  debugPrint('Exporting file ${(progress * 100).toInt()}%');
}

GPUVideoNativePreview example

import 'package:flutter_gpu_video_filters/flutter_gpu_video_filters.dart';

class PreviewPage extends StatefulWidget {
  const PreviewPage({Key? key}) : super(key: key);

  @override
  State<PreviewPage> createState() => _PreviewPageState();
}

class _PreviewPageState extends State<PreviewPage> {
  late GPUVideoPreviewController configuration;
  late final GPUGrayScaleConfiguration controller;
  late final GPUVideoPreviewParams previewParams;
  bool paramsReady = false;

  @override
  void initState() {
    super.initState();
    _prepare().whenComplete(() {
      setState(() {});
    });
  }

  Future<void> _prepare() async {
    configuration = GPUGrayScaleConfiguration();
    previewParams = await GPUVideoPreviewParams.create(configuration);
    paramsReady = true;
  }

  @override
  void dispose() {
    controller.dispose();
    configuration.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return paramsReady
        ? GPUVideoNativePreview(
      params: previewParams,
      configuration: configuration,
      onViewCreated: (controller, outputSizeStream) async {
        this.controller = controller;
        await this.controller.setVideoAsset(_assetPath);
        await for (final size in outputSizeStream) {
          setState(() {});
        }
      },
    )
        : const Offstage();
  }
}

Additional information

Support status of GPUImage for Android shaders

StatusNameDisplay Name
:white_check_mark:GPU3x3ConvolutionConfiguration3x3 Convolution
:white_check_mark:GPUAddBlendConfigurationAdd Blend
:white_check_mark:GPUAlphaBlendConfigurationAlpha Blend
:x:GPUBilateralConfigurationBilateral
:x:GPUBoxBlurConfigurationBox Blur
:white_check_mark:GPUBrightnessConfigurationBrightness
:white_check_mark:GPUBulgeDistortionConfigurationBulge Distortion Configuration
:white_check_mark:GPUCGAColorspaceConfigurationCGA Colorspace
:white_check_mark:GPUChromaKeyBlendConfigurationChroma Key Blend
:white_check_mark:GPUColorBalanceConfigurationColor Balance
:white_check_mark:GPUColorBlendConfigurationColor Blend
:white_check_mark:GPUColorBurnBlendConfigurationColor Burn Blend
:white_check_mark:GPUColorDodgeBlendConfigurationColor Dodge Blend
:white_check_mark:GPUColorInvertConfigurationColor Invert
:white_check_mark:GPUColorMatrixConfigurationColor Matrix
:white_check_mark:GPUContrastConfigurationContrast
:white_check_mark:GPUCrosshatchConfigurationCrosshatch
:white_check_mark:GPUDarkenBlendConfigurationDarken Blend
:white_check_mark:GPUDifferenceBlendConfigurationDifference Blend
:white_check_mark:GPUDirectionalSobelEdgeDetectionConfigurationDirectional Sobel Edge Detection
:white_check_mark:GPUDissolveBlendConfigurationDissolve Blend
:white_check_mark:GPUDivideBlendConfigurationDivide Blend
:white_check_mark:GPUEmbossConfigurationEmboss
:white_check_mark:GPUExposureConfigurationExposure
:white_check_mark:GPUFalseColorConfigurationFalse Color
:white_check_mark:GPUGammaConfigurationGamma
:x:GPUGaussianBlurConfigurationGaussian Blur
:white_check_mark:GPUGlassSphereConfigurationGlass Sphere
:white_check_mark:GPUGrayScaleConfigurationGray Scale
:white_check_mark:GPUHALDLookupTableConfigurationHALD Lookup Table
:white_check_mark:GPUHalftoneConfigurationHalftone
:white_check_mark:GPUHardLightBlendConfigurationHard Light Blend
:white_check_mark:GPUHazeConfigurationHaze
:white_check_mark:GPUHighlightShadowConfigurationHighlight Shadow
:white_check_mark:GPUHueBlendConfigurationHue Blend
:white_check_mark:GPUHueConfigurationHue
:white_check_mark:GPUInvertConfigurationInvert
:white_check_mark:GPUKuwaharaConfigurationKuwahara
:white_check_mark:GPULaplacianConfigurationLaplacian
:white_check_mark:GPULevelsConfigurationLevels
:white_check_mark:GPULightenBlendConfigurationLighten Blend
:white_check_mark:GPULinearBurnBlendConfigurationLinear Burn Blend
:white_check_mark:GPULuminanceThresholdConfigurationLuminance Threshold
:white_check_mark:GPULuminanceConfigurationLuminance
:white_check_mark:GPULuminosityBlendConfigurationLuminosity Blend
:white_check_mark:GPUMonochromeConfigurationMonochrome
:white_check_mark:GPUMultiplyBlendConfigurationMultiply Blend
:white_check_mark:GPUNonMaximumSuppressionConfigurationNon Maximum Suppression
:white_check_mark:GPUNormalBlendConfigurationNormal Blend
:interrobang:GPUOpacityConfigurationOpacity
:white_check_mark:GPUOverlayBlendConfigurationOverlay Blend
:white_check_mark:GPUOverlayConfigurationOverlay
:white_check_mark:GPUPixelationConfigurationPixelation
:white_check_mark:GPUPosterizeConfigurationPosterize
:white_check_mark:GPURGBConfigurationRGB
:white_check_mark:GPUSaturationBlendConfigurationSaturation Blend
:white_check_mark:GPUSaturationConfigurationSaturation
:white_check_mark:GPUScreenBlendConfigurationScreen Blend
:white_check_mark:GPUSepiaToneConfigurationSepia Tone
:white_check_mark:GPUSepiaConfigurationSepia
:white_check_mark:GPUSharpenConfigurationSharpen
:white_check_mark:GPUSobelThresholdConfigurationSobel Threshold
:white_check_mark:GPUSoftLightBlendConfigurationSoft Light Blend
:white_check_mark:GPUSolarizeConfigurationSolarize
:white_check_mark:GPUSourceOverBlendConfigurationSource Over Blend
:white_check_mark:GPUSphereRefractionConfigurationSphere Refraction
:white_check_mark:GPUSquareLookupTableConfigurationSquare Lookup Table
:white_check_mark:GPUSubtractBlendConfigurationSubtract Blend
:white_check_mark:GPUSwirlConfigurationSwirl
:white_check_mark:GPUToneCurveConfigurationTone Curve
:white_check_mark:GPUToonConfigurationToon
:white_check_mark:GPUVibranceConfigurationVibrance
:white_check_mark:GPUVignetteConfigurationVignette
:white_check_mark:GPUWatermarkConfigurationWatermark
:white_check_mark:GPUWeakPixelInclusionConfigurationWeak Pixel Inclusion
:white_check_mark:GPUWhiteBalanceConfigurationWhiteBalance
:white_check_mark:GPUZoomBlurConfigurationZoom Blur

Examples

Maintainers