小编nol*_*nic的帖子

FFmpeg 在 android 10 上不起作用,使用空消息进入 onFailure(String message) 海峡

我在我的一个视频压缩项目中使用 FFmpeg。在 Android 10 (Google Pixel 3a) 上,它会直接转到 onFailure(String message) 并为发送执行的任何命令提供空消息。

所以我在我的应用程序 gradle 文件中指定了 (api 'com.writingminds:FFmpegAndroid:0.3.2'),

指定清单中的权限(android.permission.WRITE_EXTERNAL_STORAGE)

所以我这样做:

InitializationCallback initializationCallback = new InitializationCallback();
    try {
        FFmpeg.getInstance(context).loadBinary(initializationCallback);
    } catch (FFmpegNotSupportedException e) {
        initializationCallback.onFailure();
        initializationCallback.onFinish();
    }
Run Code Online (Sandbox Code Playgroud)

初始化很好,这里没有问题。

之后:

void getData(File inputFile) {
//inputFile points to: /storage/emulated/0/Android/data/{package_name}/files/temp_files/temp_1.mp4
        String[] cmd = ("-i " + inputFile.getAbsolutePath()).split(" ");
        try {
            FFmpeg.getInstance(App.instance).execute(cmd, this);
        } catch (FFmpegCommandAlreadyRunningException e) {
            throw new Error(e);
        }
    }

    @Override
    public void onStart() {
         //This method is called
    }

    @Override
    public void onSuccess(String …
Run Code Online (Sandbox Code Playgroud)

java android ffmpeg

6
推荐指数
1
解决办法
3539
查看次数

使用DownloadManager将文件下载到真正的SD卡,而不是模拟存储

我有一个星系S4,我的问题是我无法使用DownloadManager将文件下载到SD卡,在模拟存储上它工作正常,对于真正的SD卡它给了我这个错误:

java.lang.SecurityException: Destination must be on external storage: file:///mnt/extSdCard/Android/data/net.myApp/files/exercises/exec.mp4
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

DownloadManager dwlManager=(DownloadManager)context.getSystemService(Context.DOWNLOAD_SERVICE);

DownloadManager.Request dwlmRequest=new DownloadManager.Request(Uri.parse("http://cdn..."));
File destination = new File("/mnt/extSdCard/Android/data/net.myApp/files/exercises/exec.mp4");              

dwlmRequest.setDestinationUri(Uri.fromFile(destination));
dwlManager.enqueue(dwlmRequest); //<--- Here comes the error.
Run Code Online (Sandbox Code Playgroud)

如果我将目的地设置为:

File destination = new File(getExternalFilesDir(null), "exec.mp4");
Run Code Online (Sandbox Code Playgroud)

代码工作得很好,因为目标来到模拟存储.我也可以创建文件到SD卡,如:

File f = new File("/mnt/extSdCard/Android/data/net.myApp/files/exercises/exec.mp4");
f.createNewFile();
Run Code Online (Sandbox Code Playgroud)

它工作,但我不能使用该路径的下载管理器.

请帮忙.我需要能够将文件下载到该路径.

java eclipse android

5
推荐指数
1
解决办法
4056
查看次数

标签 统计

android ×2

java ×2

eclipse ×1

ffmpeg ×1