简体   繁体   English

Android上的FFmpeg命令行

[英]FFmpeg command-line on Android

I´m trying to use this ffmpeg command line on Android: 我正在尝试在Android上使用以下ffmpeg命令行:

ffmpeg -i /sdcard/DCIM/video.mp4 -s 480x320 /sdcard/output.mp4

I have the executable file of ffmpeg (on this path: /data/local/tmp/ffmpeg/ with chmod 751), and as I read, I´m trying to invoke it using: 我有ffmpeg的可执行文件(在此路径上:/ data / local / tmp / ffmpeg /,带有chmod 751),正如我读到的,我试图使用以下命令来调用它:

Runtime.getRuntime().exec("/data/local/tmp/ffmpeg -i /sdcard/DCIM/video.mp4 -s 480x320 /sdcard/output.mp4");

But I´m not getting any result after this calling, so I tried the same command but using the android terminal and I´m sure ffmpeg works because I ´m getting many outputs like video data. 但是在调用之后我没有得到任何结果,所以我尝试了相同的命令,但是使用了android终端,并且我确定ffmpeg可以工作,因为我得到了很多输出,例如视频数据。 But it doesn´t do the action I want, I´m getting this message: 但这并没有执行我想要的操作,我收到此消息:

Unable to find a suitable output format for '/sdcard/output.mp4'

I don´t have any idea about what it can be the issue... Thanks for help!! 我不知道这可能是什么问题...谢谢您的帮助!

It probably shouldn't work because ffmpeg will refer to /usr/lib where will look for installed libs. 它可能不应该工作,因为ffmpeg将引用/ usr / lib来查找已安装的库。 But this is android this approach won't work. 但这是android,这种方法行不通。

Probably you should compile ffmpeg into a single library like libffmpeg.so and write c - wrapper, which will load it from your app location like /data/data/com.myapp/lib/libffmpeg.so and pass params to this library. 可能您应该将ffmpeg编译成一个单独的库,例如libffmpeg.so并编写c-包装器,这将从您的应用程序位置(例如/data/data/com.myapp/lib/libffmpeg.so)加载它,并将参数传递给该库。

So: You will load your wrapper through jni and pass ffmpeg params then wrapper will load actual ffmpeg and pass params to it. 因此:您将通过jni加载包装器并传递ffmpeg参数,然后包装器将加载实际的ffmpeg并将参数传递给它。

I have tried this in one project, it works 我已经在一个项目中尝试过了

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

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