我有已编译的FFMPEG文件。我尝试将图像和音频剪辑组合在一起形成视频剪辑。结合这两者的功能是:ffmpeg -i /mnt/sdcard/KaraokeVideos/allmapeople.mp3 -i /mnt/sdcard/KaraokeVideos/Penguins.jpg /mnt/sdcard/KaraokeVideos/video_finale.mpg。
我在代码中使用了它:
public class MainActivity extends Activity {
private Process process;
String command, text;
// load the library - name matches jni/Android.mk-jj
//static {
//System.loadLibrary("ffmpeg");
//}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
Execute();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void Execute() throws IOException {
// TODO Auto-generated method stub
Process p = Runtime.getRuntime().exec("ffmpeg -i /mnt/sdcard/KaraokeVideos/allmapeople.mp3 -i /mnt/sdcard/KaraokeVideos/Penguins.jpg /mnt/sdcard/KaraokeVideos/video_finale.mpg");
p.getInputStream();
}
但是我在logcat中得到了这个异常:
01-10 18:44:24.209: W/System.err(31790): java.io.IOException: Error running exec(). Command: [ffmpeg, -i, /mnt/sdcard/KaraokeVideos/allmapeople.mp3, -i, /mnt/sdcard/KaraokeVideos/Penguins.jpg, /mnt/sdcard/KaraokeVideos/video_finale.mpg] Working Directory: null Environment: null
01-10 18:44:24.239: W/System.err(31790): at java.lang.ProcessManager.exec(ProcessManager.java:211)
01-10 18:44:24.239: W/System.err(31790): at java.lang.Runtime.exec(Runtime.java:168)
01-10 18:44:24.239: W/System.err(31790): at java.lang.Runtime.exec(Runtime.java:241)
01-10 18:44:24.249: W/System.err(31790): at java.lang.Runtime.exec(Runtime.java:184)
01-10 18:44:24.249: W/System.err(31790): at com.mindtherobot.samples.ndkfoo.MainActivity.Execute(MainActivity.java:47)
01-10 18:44:24.259: W/System.err(31790): at com.mindtherobot.samples.ndkfoo.MainActivity.onCreate(MainActivity.java:35)
01-10 18:44:24.259: W/System.err(31790): at android.app.Activity.performCreate(Activity.java:4465)
01-10 18:44:24.269: W/System.err(31790): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-10 18:44:24.269: W/System.err(31790): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
01-10 18:44:24.269: W/System.err(31790): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
01-10 18:44:24.289: W/System.err(31790): at android.app.ActivityThread.access$600(ActivityThread.java:122)
01-10 18:44:24.289: W/System.err(31790): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
01-10 18:44:24.299: W/System.err(31790): at android.os.Handler.dispatchMessage(Handler.java:99)
01-10 18:44:24.309: W/System.err(31790): at android.os.Looper.loop(Looper.java:137)
01-10 18:44:24.309: W/System.err(31790): at android.app.ActivityThread.main(ActivityThread.java:4340)
01-10 18:44:24.319: W/System.err(31790): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 18:44:24.319: W/System.err(31790): at java.lang.reflect.Method.invoke(Method.java:511)
01-10 18:44:24.329: W/System.err(31790): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-10 18:44:24.339: W/System.err(31790): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-10 18:44:24.339: W/System.err(31790): at dalvik.system.NativeStart.main(Native Method)
01-10 18:44:24.359: W/System.err(31790): Caused by: java.io.IOException: Permission denied
01-10 18:44:24.359: W/System.err(31790): at java.lang.ProcessManager.exec(Native Method)
01-10 18:44:24.369: W/System.err(31790): at java.lang.ProcessManager.exec(ProcessManager.java:209)
01-10 18:44:24.379: W/System.err(31790): ... 19 more
01-10 18:44:24.699: D/gralloc_goldfish(31790): Emulator without GPU emulation detected.
这里有什么问题,任何帮助都会很棒!