简体   繁体   English

使用ffmpeg的Android视频压缩

[英]Android video compression using ffmpeg

I am compressing video using ffmpeg library. 我正在使用ffmpeg库压缩视频。 user can browse for any video and compress it. 用户可以浏览并压缩任何视频。 It is working fine for videos with video name don't have white spaces.But if video name have white spaces compression is not working.we try to double quote for video path but still it is not working. 对于视频名称中没有空格的视频来说效果很好。但是,如果视频名称中包含空格,则压缩无法正常工作。我们尝试对视频路径加双引号,但仍无法正常工作。 for eg. 例如 our video path is like this - /storage/sdcard1/Video/teri jhuki nazar.mp4 我们的视频路径是这样的- /storage/sdcard1/Video/teri jhuki nazar.mp4

how to fix this issue? 如何解决这个问题?

Replace white space with "\\ " like 用“ \\”代替空格,例如

String filePath = "/storage/sdcard1/Video/teri jhuki nazar.mp4";
        filePath = filePath.replace(" ", "\\ ");

OR 要么

ffmpeg -i /storage/sdcard1/Video/teri%20jhuki%20nazar.mp4

use following sample code to avoid blank spaces in your video file. 使用以下示例代码避免视频文件中出现空格。

String temp = URLDecoder.decode("Your file path");

String videopath = temp;

then send videopath to ffmpeg. 然后将视频路径发送到ffmpeg。 It's goona work. 这是goona工作。

In ffmpeg each commands are separately identified using white spaces. ffmpeg中,每个命令使用空格单独标识。 When you specify a path having white spaces, the path will splits according to white spaces and will be considered as different commands and hence the error arises. 当您指定具有空格的路径时,该路径将根据空格分割,并且将被视为不同的命令,因此会出现错误。

Here you can see how each commands are differentiated. 在这里,您可以看到每个命令的区别。

I suggest you to make your own changes in command styling and differentiating. 我建议您在命令样式和区分方面进行自己的更改。


Refer : 参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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