简体   繁体   中英

How to make ffmpeg cmd run if there is space in director path or file name

I am using ffmpeg to cut video via android, all working fine but only issue come when if the source directory contain space the command is not working by saying file not found

-i /storage/emulated/0/ISave Videos/Br0gv9anKKg.mp4 -acodec copy -vcodec copy -ss 00:00:10 -t 00:00:20 /storage/emulated/0/1547813275685ChunkClip.mp4

file not found is Like"File not found -i /storage/emulated/0/ISave"

But for other path no issue and all works fine only if space is there in file path the issue comes

Cool Question

Its very confusing to solve there type of issues even if we get a solution The following Link show some fix for handling issues like this Quoting and escaping

So for the issue you have there is fix Add each word in ffmpeg comments to an LinkedList and then convert to command array so that ffmpeg will execute it

As follows (As per you requirement command)

List<String> cmdList = new LinkedList<>();
                cmdList.add("-i");
                cmdList.add("/storage/emulated/0/ISave Videos/Br0gv9anKKg.mp4");
                cmdList.add("-acodec");
                cmdList.add("copy");
                cmdList.add("-vcodec");
                cmdList.add("copy");
                cmdList.add("-ss");
                cmdList.add("00:00:10");
                cmdList.add("-t");
                cmdList.add("00:00:20");
                cmdList.add("/storage/emulated/0/1547813275685ChunkClip.mp4");

String[] command  = cmdList.toArray(new String[cmdList.size()]);

Hope your issue will be get resolved by this solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM