tapioca 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

Tapioca - a Flutter plugin for video editing #

Tapioca is a Flutter plugin for video editing on Android and iOS.

Note: Feedback welcome and Pull Requests are most welcome!

Features #

  • Develop for iOS and Android from a single codebase
  • Edit videos(Apply filter, Overlay text and images)

Installation #

First, add tapioca as a dependency in your pubspec.yaml file.

iOS #

Add the following entry to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • NSPhotoLibraryUsageDescription - Specifies the reason for your app to access the user’s photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
  • NSPhotoLibraryAddUsageDescription - Specifies the reason for your app to get write-only access to the user’s photo library. This is called Privacy - Photo Library Additions Usage Description in the visual editor.

Android #

Ensure the following permission is present in your Android Manifest file, located in <project root>/android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Usage #

import 'package:tapioca/tapioca.dart';
import 'package:path_provider/path_provider.dart';

final tapiocaBalls = [
    TapiocaBall.filter(Filters.pink),
    TapiocaBall.imageOverlay(imageBitmap, 300, 300),
    TapiocaBall.textOverlay("text",100,10,100,Color(0xffffc0cb)),
];
var tempDir = await getTemporaryDirectory();
final path = '${tempDir.path}/result.mp4';
final cup = Cup(Content(videoPath), tapiocaBalls);
cup.suckUp(path).then((_) {
  print("finish processing");
});

TapiocaBall #

TapiocaBall is a effect to apply to the video.

TapiocaBallEffect
TapiocaBall.filter(Filters filter)Apply color filter
TapiocaBall.textOverlay(String text, int x, int y, int size, Color color)Overlay text
TapiocaBall.imageOverlay(Uint8List bitmap, int x, int y)Overlay images

Content #

Content is a class to wrap a video file.

Cup #

Cup is a class to wrap a Content object and List<TapiocaBall> object.

You can edit the video by executing .suckUp().

Supported Formats #

  • On iOS, the backing video editor is AVFoundation. please refer here for list of supported video formats.
  • On Android, the backing video editor is Mp4Composer-android, The supported format is only MP4.

1.0.0 #

  • Initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:tapioca/src/video_editor.dart';
import 'package:tapioca/tapioca.dart';
import 'package:image_picker/image_picker.dart';
import 'package:path_provider/path_provider.dart';
import 'package:gallery_saver/gallery_saver.dart';
import 'package:video_player/video_player.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  final navigatorKey = GlobalKey<NavigatorState>();
  File _video;
  bool isLoading = false;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await VideoEditor.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  _pickVideo() async {

    try {
      File video = await ImagePicker.pickVideo(source: ImageSource.gallery);
      print(video.path);
      setState(() {
        _video = video;
        isLoading = true;
      });
    } catch (error) {
      print(error);
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: isLoading ? CircularProgressIndicator() : RaisedButton(
          child: Text("Pick a video and Edit it"),
          color: Colors.orange,
          textColor: Colors.white,
          onPressed: () async {
            print("clicked!");
            await _pickVideo();
            var tempDir = await getTemporaryDirectory();
            final path = '${tempDir.path}/result.mp4';
            print(tempDir);
            final imageBitmap =
                (await rootBundle.load("assets/tapioca_drink.png"))
                    .buffer
                    .asUint8List();
            try {
              final tapiocaBalls = [
                TapiocaBall.filter(Filters.pink),
                TapiocaBall.imageOverlay(imageBitmap, 300, 300),
                TapiocaBall.textOverlay(
                    "text", 100, 10, 100, Color(0xffffc0cb)),
              ];
              if (_video != null) {
                final cup = Cup(Content(_video.path), tapiocaBalls);
                cup.suckUp(path).then((_) async {
                  print("finished");
                  GallerySaver.saveVideo(path).then((bool success) {
                    print(success.toString());
                  });
                  navigatorKey.currentState.push(
                    MaterialPageRoute(builder: (context) => VideoScreen(path)),
                  );
                  setState(() {
                    isLoading = false;
                  });
                });
              } else {
                print("video is null");
              }
            } on PlatformException {
              print("error!!!!");
            }
          },
        )),
      ),
    );
  }
}

class VideoScreen extends StatefulWidget {
  final String path;

  VideoScreen(this.path);

  @override
  _VideoAppState createState() => _VideoAppState(path);
}

class _VideoAppState extends State<VideoScreen> {
  final String path;

  _VideoAppState(this.path);

  VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.file(File(path))
      ..initialize().then((_) {
        // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
        setState(() {});
      });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: _controller.value.initialized
            ? AspectRatio(
                aspectRatio: _controller.value.aspectRatio,
                child: VideoPlayer(_controller),
              )
            : Container(),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            _controller.value.isPlaying
                ? _controller.pause()
                : _controller.play();
          });
        },
        child: Icon(
          _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
        ),
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  tapioca: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:tapioca/tapioca.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
39
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:tapioca/tapioca.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:tapioca/tapioca.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:tapioca/tapioca.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:tapioca/tapioca.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [tapioca] that is in a package requiring null.

Health suggestions

Format lib/src/content.dart.

Run flutter format to format lib/src/content.dart.

Format lib/src/cup.dart.

Run flutter format to format lib/src/cup.dart.

Format lib/src/tapioca_ball.dart.

Run flutter format to format lib/src/tapioca_ball.dart.

Format lib/src/video_editor.dart.

Run flutter format to format lib/src/video_editor.dart.

Format lib/tapioca.dart.

Run flutter format to format lib/tapioca.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test