0

我只是尝试使用下面的这个命令分割视频,我面临的问题是

由于我是初学者我不知道为什么在这里使用应用程序文档目录?是否将输出视频永久存储在该文件夹中???

我在网上找到了这段代码

ffmpeg -i input.mp3 -f segment -segment_time 10 -c copy output%0d.mp3

如何在此处使用此代码创建多个输出文件并将它们存储在库中?你能帮我编码吗?

       final result = await FilePicker.platform.pickFiles();
       if(result==null) return;
       final file = result.files.first;
       MediaInformation mediaInformation = await flutterFFprobe.getMediaInformation(file.path!);
       Map<dynamic, dynamic> mp = mediaInformation.getMediaProperties()!;

       final outputFile = await getApplicationDocumentsDirectory();

       double timeInterval = double.parse(mp["duration"]);
       int loop = timeInterval~/30;



     for(int i=0;i<loop;i++){
     print("i is $i");
     final outputPath = "${outputFile.path}/video${i+1}.mp4";

     String commandToExecute = "-y -i ${file
         .path} -ss 00:00:${i*30} -t 30 $outputPath";
     await _flutterFFmpeg.execute(commandToExecute).then((value) =>
         print("FFmpeg return with $value"));
     await GallerySaver.saveVideo(outputPath);

   }

   final outputPath = "${outputFile.path}/video${loop+1}.mp4";
   print("loop is ${timeInterval-loop*30}");
   print("path is $outputPath");
   String commandToExecute = "-y -i ${file
       .path} -ss 00:00:${loop*30} -t ${timeInterval-loop*30} $outputPath";
   await _flutterFFmpeg.execute(commandToExecute).then((value) =>
       print("FFmpeg return with $value"));
   await GallerySaver.saveVideo(outputPath);


   print(outputFile.listSync());
4

0 回答 0