首页 > 解决方案 > 输入路径中的Android ffmpeg空白导致“没有这样的文件或目录”

问题描述

我正在使用最新版本的WritingMinds/ffmpeg-android-java库。

我试过单/双引用路径但没有成功。

我在执行后记录了我的命令,请查看子目录包含空格的输入路径,空格之间添加了逗号:

ffmpeg, -i, "storage/emulated/0/Telegram/Telegram, Video/4_5828137322067002802.mp4", -vf...

我像这样拆分并运行我的命令:

String crop = "-ss " + skipTimeForCrop + " -noautorotate -i " + newPath + " -vframes 10 -vf cropdetect=24:16:0 -f null -";
String[] cropCommand = crop.trim().split(" ");
execFFmpegForCrop(cropCommand);

storage/emulated/0/Telegram/Telegram: 没有这样的文件或目录

对此有任何想法吗?

标签: androidffmpeg

解决方案


我相信添加命令 asList然后将其转换为数组将解决这个问题,

这样,逗号应该只添加到每个命令的末尾。我会告诉你如何:

List<String> commandList = new LinkedList<>();
commandList.add("-ss");
commandList.add("00:00:00");
commandList.add("-noautorotate");
commandList.add("-i");
commandList.add("storage/emulated/0/Telegram/Telegram Video/4_5828137322067002802.mp4");
commandList.add("-vframes");
commandList.add("10");
commandList.add("-vf");
commandList.add("-cropdetect=24:16:0");
.
.
.

 String[] cropCommand  = commandList.toArray(new String[commandList.size()]);
 execFFmpegForCrop(cropCommand);

这将是输出:

"[-ss, 00:00:00, -noautorotate, -i, storage/emulated/0/Telegram/Telegram Video/4_5828137322067002802.mp4, -vframes, 10, -vf, -cropdetect=24:16:0, ...]";

推荐阅读