Android,使用FFMPEG拆分GIF不起作用

问题描述 投票:0回答:1

我想用FFmpeg-Android-Java拆分动画的gif文件,所以我引用了这个问题Android, split gif to frames with ffmpeg 并编写了这段代码。

String path = "/storage/emulated/0/Download/mothersday-toaster.gif";
        String cmd[] = {"-i",path,"-vsync","0","/storage/emulated/0/Download/output$03d.png"};

        try {
            // to execute "ffmpeg -version" command you just need to pass "-version"
            ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

                @Override
                public void onStart() {}

                @Override
                public void onProgress(String message) {}

                @Override
                public void onFailure(String message) {Log.d("Q", "failed to convert");}

                @Override
                public void onSuccess(String message) {}

                @Override
                public void onFinish() {}
            });
        } catch (FFmpegCommandAlreadyRunningException e) {
            // Handle if FFmpeg is already running
        }

虽然,它总是给我“未能转换”的日志。 FFMPEG已加载。我的代码有问题吗?

android ffmpeg android-ffmpeg
1个回答
0
投票

好的,所以解决方案非常简单。

我发现onProgress输出说它需要权限所以我注意到我忘了给我的应用程序WRITE_EXTERNAL_STORAGE权限,这是一种耻辱。而且,我将output$03d部分更改为output%03d。感谢Gyan的建议。

© www.soinside.com 2019 - 2024. All rights reserved.