首页 > 解决方案 > 从这些 jcodec 示例代码生成的 output.mp4 的绝对路径是什么?

问题描述

我在 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 资源管理器中查看生成的输出文件。我是新手。我应该怎么办。请帮我。

标签: androidjcodec

解决方案


推荐阅读