想在单挑游戏中添加类似的单词

问题描述 投票:0回答:1

当视频分享给某人时,我想在视频中添加诸如单挑游戏之类的单词,这些单词也会添加到视频中,我为此目的编写了这些方法,但这些对我不起作用。我正在使用 flutter_ffmpeg: ^0.4.2 包,用于视频编辑,任何人都可以帮助我构建可以成功实现我想要的结果的方法吗???我为此目的编写了这些方法,但这些方法对我不起作用。我正在使用 flutter_ffmpeg: ^0.4.2 包,用于视频编辑,任何人都可以帮助我构建可以成功实现我想要的结果的方法吗???我为此目的编写了这些方法,但这些方法对我不起作用。我正在使用 flutter_ffmpeg: ^0.4.2 包,用于视频编辑,任何人都可以帮助我构建可以成功实现我想要的结果的方法吗??????

flutter dart
1个回答
0
投票
Future<void> processRecordedVideo(String recordingPath) async {
    final overlayTextOptions = {
      'enable': '1',
      'fontfile': 'OpenSans-Bold.ttf', // Replace with your font file path
      'fontsize': '36',
      'text': 'Your Overlay Text Here', // Replace with the text to be 
  displayed
      'x': '10',
      'y': '10', // Adjust x and y coordinates for text position
      'fontcolor': 'white',
      'shadowcolor': 'black',
      'shadowx': '2',
      'shadowy': '2',
    };

    final overlayFilter =
        'drawtext=${overlayTextOptions.entries.map((e) => 
  '${e.key}=${e.value}').join(':')}';

    // Specify the destination directory where you want to save the processed 
   video
    const destinationDirectory = "/storage/emulated/0/desi_charades/";
    final outputVideoPath =
        '$destinationDirectory${DateTime.now().millisecondsSinceEpoch}.mp4';

    final arguments = [
      '-i', recordingPath,
      '-vf', overlayFilter,
      '-c:v', 'libx264', // Video codec
      '-preset', 'ultrafast', // Encoding preset
      '-c:a', 'copy', // Keep original audio
      '-y', // Overwrite existing output file
      outputVideoPath, // Output video path
    ];

    await flutterFFmpeg.executeWithArguments(arguments);

    // Save the processed video to the destination directory
    await saveVideoToGallery(outputVideoPath);
  }
Future<void> saveVideoToGallery(String p) async {
    try {
      final originalVideoFile = File(p);
      if (!originalVideoFile.existsSync()) {
        throw const FileSystemException('Source file does not exist.');
      }

      const absoluteFolderPath = "/storage/emulated/0/desi_charades/";
      await Directory(absoluteFolderPath).create(recursive: true);

      final filename =
          "${deck!.title}_${DateTime.now().millisecondsSinceEpoch}.mp4";
      final destinationPath = "$absoluteFolderPath$filename";

      await originalVideoFile.copy(destinationPath);
      savedPathOfVideo.value = destinationPath;

      Logger().e(savedPathOfVideo.value);
    } catch (e) {
      print('Error saving enter code here video: $e');
    }
  }

这些方法都写好了

© www.soinside.com 2019 - 2024. All rights reserved.