main.dart 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import 'package:flutter/material.dart';
  2. import 'dart:async';
  3. import 'package:flutter/services.dart';
  4. import 'package:fffmpeg/fffmpeg.dart';
  5. void main() {
  6. runApp(MyApp());
  7. }
  8. class MyApp extends StatefulWidget {
  9. @override
  10. _MyAppState createState() => _MyAppState();
  11. }
  12. class _MyAppState extends State<MyApp> {
  13. String _platformVersion = 'Unknown';
  14. @override
  15. void initState() {
  16. super.initState();
  17. initPlatformState();
  18. }
  19. // Platform messages are asynchronous, so we initialize in an async method.
  20. Future<void> initPlatformState() async {
  21. String platformVersion;
  22. // Platform messages may fail, so we use a try/catch PlatformException.
  23. try {
  24. platformVersion = await Fffmpeg.platformVersion;
  25. } on PlatformException {
  26. platformVersion = 'Failed to get platform version.';
  27. }
  28. // If the widget was removed from the tree while the asynchronous platform
  29. // message was in flight, we want to discard the reply rather than calling
  30. // setState to update our non-existent appearance.
  31. if (!mounted) return;
  32. setState(() {
  33. _platformVersion = platformVersion;
  34. });
  35. }
  36. @override
  37. Widget build(BuildContext context) {
  38. return MaterialApp(
  39. home: Scaffold(
  40. floatingActionButton: FloatingActionButton(
  41. onPressed: (){
  42. addWaterMask(input, output).then((value) => print("========"+value.toString()));
  43. },
  44. ),
  45. appBar: AppBar(
  46. title: const Text('Plugin example app'),
  47. ),
  48. body: Center(
  49. child: Text('Running on: $_platformVersion\n'),
  50. ),
  51. ),
  52. );
  53. }
  54. static String logo="/storage/emulated/0/aa_flutter/logo.jpeg";
  55. static String input="/storage/emulated/0/aa_flutter/test.mp4";
  56. static String output="/storage/emulated/0/aa_flutter/test_water.mp4";
  57. static Future addWaterMask(String inputPath,String outputPath)async{
  58. // await _addLogoTodisk();
  59. // String s = await _getWaterMaskPath();
  60. // await File(outputPath).create();
  61. String command="-i "+input+" -i "+logo+" -filter_complex 'overlay=main_w-overlay_w-10:main_h-overlay_h-10' "+output;
  62. //处理完返回路径吧
  63. return await Fffmpeg.exeCommand(command);
  64. }
  65. }