如何运行从Android的命令行的ffmpeg [英] How to run ffmpeg from command line in android
问题描述
我想用命令line.I使用的ffmpeg已经在project.But保存ffmpeg.so在文件目录中我得到异常而做so.This是code:
I want to use ffmpeg using command line.I have saved ffmpeg.so in files directory in the project.But i am getting exception while doing so.This is the code:
public class MainActivity extends Activity {
Process p;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Process p = Runtime.getRuntime().exec("/data/data/com.example.ffmpegnew/files/ffmpeg",null, new File("/data/data/com.example.ffmpegnew/files"));
}
catch(Exception e)
{
System.out.println("exception"+e);
}
}
}
这是个例外:
09-16 16:21:24.992: I/System.out(2103): exceptionjava.io.IOException: Error running exec(). Commands: [/data/data/com.example.ffmpegnew/files/ffmpeg] Working Directory: /data/data/com.example.ffmpegnew/files Environment: null
请告诉我什么样的错误我是doing.Thanks。
Please tell me what kind of mistake i am doing.Thanks.
推荐答案
所以,首先,你不能直接执行共享对象
文件。你需要建立一个可使用运行一个可执行的ffmpeg /系统/斌
So firstly, you cannot directly execute a shared object
file. You need to build a ffmpeg executable that can be run using /system/bin
请以此为Android上
Kindly take this as reference FFMPEG on Android
在你能够把它编译,你可以,但可执行文件中的APK你的资产文件夹,然后将其解压缩到 /数据/数据/<您的包和GT; /
(确保行chmod 755呢!)
After you are able to get it compiled, you can but the executable in your assets folder of the APK and extract it to /data/data/<your package>/
(ensure a chmod 755 too!)
一旦这样做了,你可以通过建立一个命令行字符串,并将它传递给的ProcessBuilder
,而不是使用的Runtime.exec()运行可执行
Once that's done, you can run the executable by using building a command line string and passing it to ProcessBuilder
instead of using the Runtime.exec()
这篇关于如何运行从Android的命令行的ffmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!