anharu2394 / tapioca

a Flutter plugin for video editing on Android and iOS.
https://pub.dev/packages/tapioca
MIT License
123 stars 54 forks source link

video_processing_failed when add more than one text. #49

Closed panchalAlpit closed 3 years ago

panchalAlpit commented 3 years ago
final tapiocaBalls = [ 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"); 
   });

If I implement the above code for adding single text so it's working perfectly. So my issue is if use the whole code inside of the loop and add more than one text so that time getting an error.

void videomakerMultipleWidgets() async {

for(int i = 0;i<listDragdrop.length;i++){

  if(listDragdrop[i].llWidget.runtimeType == Text){

    Text textwidget = listDragdrop[i].llWidget;

    TextStyle stylewidget= textwidget.style;

   final tapiocaBalls = [
      TapiocaBall.textOverlay(textwidget.data, listDragdrop[i].left.toInt(), listDragdrop[i].top.toInt(), 100, Color(0xffffc0cb)),
    ];

    var tempDir = await getTemporaryDirectory();
    final path = '${tempDir.path}/result2.mp4';
    final cup = Cup(Content(updatedFile.path), tapiocaBalls);
  await cup.suckUp(path).then((value) => {
      updatedFile = File(path),

    });
  }

}

ll_to(page: LLDummyScreen(mediaFile: updatedFile,isPicture: false,)); }

E/Mp4Composer( 3470): Unable to compose the engine E/Mp4Composer( 3470): java.lang.RuntimeException: setDataSource failed: status = 0xFFFFFFEA E/Mp4Composer( 3470): at android.media.MediaMetadataRetriever.setDataSource(Native Method) E/Mp4Composer( 3470): at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:321) E/Mp4Composer( 3470): at com.daasuu.mp4compose.composer.Mp4ComposerEngine.compose(Mp4ComposerEngine.java:82) E/Mp4Composer( 3470): at com.daasuu.mp4compose.composer.Mp4Composer$2.run(Mp4Composer.java:297) E/Mp4Composer( 3470): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/Mp4Composer( 3470): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/Mp4Composer( 3470): at java.lang.Thread.run(Thread.java:923) I/System.out( 3470): java.lang.RuntimeException: setDataSource failed: status = 0xFFFFFFEA E/flutter ( 3470): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(video_processing_failed, video processing is failed., null, null) E/flutter ( 3470): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581:7) E/flutter ( 3470): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18) E/flutter ( 3470): E/flutter ( 3470): #2 VideoEditor.writeVideofile (package:tapioca/src/video_editor.dart:14:5) E/flutter ( 3470): E/flutter ( 3470): #3 _LLShortVideo_PictureSaveScreenState.videomakerMultipleWidgets. (package:legit/LLScreen/LLShortVideo_PictureSaveScreen.dart) E/flutter ( 3470): E/flutter ( 3470):

anharu2394 commented 3 years ago

@panchalAlpit If you want to overlay multiple texts, try to do in this way.

List<TapiocaBall> tapiocaBalls = [];
for(int i = 0;i<listDragdrop.length;i++){

  if(listDragdrop[i].llWidget.runtimeType == Text){

    Text textwidget = listDragdrop[i].llWidget;

    TextStyle stylewidget= textwidget.style;

   tapiocaBalls.add(TapiocaBall.textOverlay(textwidget.data, listDragdrop[i].left.toInt(), listDragdrop[i].top.toInt(), 100, Color(0xffffc0cb)))
  }

}
var tempDir = await getTemporaryDirectory();
    final path = '${tempDir.path}/result2.mp4';
    final cup = Cup(Content(updatedFile.path), tapiocaBalls);
  await cup.suckUp(path).then((value) => {
      updatedFile = File(path),

    });
Baneeishaque commented 3 years ago

@panchalAlpit If you want to overlay multiple texts, try to do in this way.

List<TapiocaBall> tapiocaBalls = [];
for(int i = 0;i<listDragdrop.length;i++){

  if(listDragdrop[i].llWidget.runtimeType == Text){

    Text textwidget = listDragdrop[i].llWidget;

    TextStyle stylewidget= textwidget.style;

   tapiocaBalls.add(TapiocaBall.textOverlay(textwidget.data, listDragdrop[i].left.toInt(), listDragdrop[i].top.toInt(), 100, Color(0xffffc0cb)))
  }

}
var tempDir = await getTemporaryDirectory();
    final path = '${tempDir.path}/result2.mp4';
    final cup = Cup(Content(updatedFile.path), tapiocaBalls);
  await cup.suckUp(path).then((value) => {
      updatedFile = File(path),

    });

i think this will work.

anharu2394 commented 3 years ago

thanks @Baneeishaque

amalnaami commented 2 years ago

I try this way to add multiple text BUT it doesn't work It just show to me last text .. There is any update plz?