我在MainActivity中使用JCodec中的以下代码,这些代码扩展了AppCompatActivity,使用android中的内存制作了一组图像,但对实际路径感到困惑:
Bitmap[] bitmaps = new Bitmap[3];
bitmaps[0] = BitmapFactory.decodeResource(getResources(), R.raw.raw1);
bitmaps[1] = BitmapFactory.decodeResource(getResources(), R.raw.raw2);
bitmaps[2] = BitmapFactory.decodeResource(getResources(), R.raw.raw3);
SeekableByteChannel out = null;
try {
out = NIOUtils.writableFileChannel("/tmp/output.mp4");
// for Android use: AndroidSequenceEncoder
AndroidSequenceEncoder encoder = new AndroidSequenceEncoder(out, Rational.R(25, 1));
for (int i = 0; i < bitmaps.length; i++) {
// Generate the image, for Android use Bitmap
// Encode the image
encoder.encodeImage(bitmaps[i]);
}
// Finalize the encoding, i.e. clear the buffers, write the header, etc.
encoder.finish();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
NIOUtils.closeQuietly(out);
}
我收到以下例外:
java.io.FileNotFoundException: /tmp/output.mp4: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
at java.io.FileOutputStream.<init>(FileOutputStream.java:127)
at java.io.FileOutputStream.<init>(FileOutputStream.java:116)
at org.jcodec.common.io.NIOUtils.writableFileChannel(NIOUtils.java:365)
at com.riseup.aamsharif.jcodectest.MainActivity.onCreate(MainActivity.java:37)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:438)
我想从Windows资源管理器中看到生成的输出文件。我是新手。我该怎么办。求你帮帮我。