在使用ffmpeg的时候,有这样命令行为:c://ffmpeg/ffmpeg.exe -i C:/ffmpeg/input/test123/Test.avi -y -f image2 -ss 8 -t 0.001 -s 210x120 D:/Program Files/Tomcat/apache-tomcat-7.0.41/webapps/usr/local/data/video/test123/SC95210820141223IMG.png
“D:/Program Files/Tomcat/apache-tomcat-7.0.41/webapps/usr/local/data/video/test123/SC95210820141223IMG.png” Program Files中间有一个空格,解决办法是:
String cut = "c://ffmpeg/ffmpeg.exe -i "+ oldfilepath.replaceAll(" ","\" \"") + " -y -f image2 -ss 8 -t 0.001 -s 210x120 "+imgPath.replaceAll(" ","\" \"");
使用replaceAll函数进行替换,将空格替换成如下:
c://ffmpeg/ffmpeg.exe -i C:/ffmpeg/input/test123/Test.avi -y -f image2 -ss 8 -t 0.001 -s 210x120 D:/Program" "Files/Tomcat/apache-tomcat-7.0.41/webapps/usr/local/data/video/test123/SC95210820141223IMG.png
OK~~~