Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java FFMPEG命令在Android 10上不起作用_Java_Android_Ffmpeg_Android Ffmpeg - Fatal编程技术网

Java FFMPEG命令在Android 10上不起作用

Java FFMPEG命令在Android 10上不起作用,java,android,ffmpeg,android-ffmpeg,Java,Android,Ffmpeg,Android Ffmpeg,我正在开发一款android应用程序,应用慢动作和快动作等视频效果。我的应用程序在安卓10下运行良好,但在安卓10上没有,FFMPEG没有显示任何错误,只是onFailure回调方法上显示空白错误消息 我做了一些研究,发现android引入了作用域权限,您可以通过在清单android:requestLegacyExternalStorage=“true”上添加这一行暂时绕过这一点,然后获得存储权限。 添加这一行后,应用程序的rest移植可以很好地抓取用户视频等,但FFMPEG不起作用 如果有人对

我正在开发一款android应用程序,应用慢动作和快动作等视频效果。我的应用程序在安卓10下运行良好,但在安卓10上没有,FFMPEG没有显示任何错误,只是onFailure回调方法上显示空白错误消息

我做了一些研究,发现android引入了作用域权限,您可以通过在清单android:requestLegacyExternalStorage=“true”上添加这一行暂时绕过这一点,然后获得存储权限。 添加这一行后,应用程序的rest移植可以很好地抓取用户视频等,但FFMPEG不起作用


如果有人对这个问题有任何想法或线索,请帮助我

这是适用于兼容设备的工作版本,从API 16开始。支持android API 29(Q)

MobileFFmpeg v4.4的长期支持包

支持以下设备规范

安卓

Android 4.1(API级别16)或更高版本

x86和x86-64体系结构arm-v7a、arm-v7a-neon、arm64-v8a、

您可以在

上找到更多信息,请尝试以下操作

依赖关系{ 实现'com.arthenica:mobile-ffmpeg-full:4.4.LTS' }

你也看到了。。

使用此支持targetSdkVersion 29的库

实现'com.arthenica:mobile ffmpeg视频:4.4'

用于视频压缩的命令:

val complexCommand=arrayOf( “-y”, “-我”, 输入路径!!, “-s”, “640x480”, “-r”, "25", “-vcodec”, “mpeg4”, “-b:v”, “1000k”, “-b:a”, "48000", “-ac”, "2", “-ar”, "22050", outputFilePath )

压缩方法:

  private fun execFFmpegBinary(command: Array<String>, inputPath: String?, listener: CompressionListener?, outputFilePath: String) {
    Config.enableLogCallback { message -> Log.e(Config.TAG, message.text) }
    Config.enableStatisticsCallback { newStatistics ->
        Log.e(
            Config.TAG,
            String.format(
                "frame: %d, time: %d",
                newStatistics.videoFrameNumber,
                newStatistics.time
            )
        )
        Log.d(
            TAG,
            "Started command : ffmpeg " + Arrays.toString(command)
        )
        
        val videoLength = inputPath?.let { VideoUtils.getVideoDuration(it) }
        Log.d(TAG, "execFFmpegBinary: Video Length : $videoLength")
        val progress: Float =
            java.lang.String.valueOf(newStatistics.time).toFloat() / videoLength!!
        val progressFinal = progress * 100
        Log.d(TAG, "Video Length: $progressFinal")
        Log.d(
            Config.TAG,
            java.lang.String.format(
                "frame: %d, time: %d",
                newStatistics.videoFrameNumber,
                newStatistics.time
            )
        )
        Log.d(
            Config.TAG,
            java.lang.String.format(
                "Quality: %f, time: %f",
                newStatistics.videoQuality,
                newStatistics.videoFps
            )
        )
        //progressDialog.setProgress(progressFinal.toInt())
        //val adjustProgress = progressFinal/1.5f
        Log.d(TAG, "execFFmpegBinary: Progress: ${progressFinal.toInt()}")
        listener?.onProgress(progressFinal.toInt())
        Log.d(TAG, "progress : $newStatistics")
    }
    Log.d(
        TAG,
        "Started command : ffmpeg " + Arrays.toString(command)
    )
   /* progressDialog.setMessage("Processing...")
    progressDialog.show()*/
    val executionId = com.arthenica.mobileffmpeg.FFmpeg.executeAsync(
        command
    ) { executionId1: Long, returnCode: Int ->
        if (returnCode == RETURN_CODE_SUCCESS) {
            Log.d(
                TAG,
                "Finished command : ffmpeg " + Arrays.toString(command)
            )

            listener?.compressionFinished(SUCCESS, true, fileOutputPath = outputFilePath)
        } else if (returnCode == Config.RETURN_CODE_CANCEL) {
            Log.e(
                TAG,
                "Async command execution cancelled by user."
            )
            listener?.onFailure(String.format(
                "Async command execution cancelled by user."
            ))
            //if (progressDialog != null) progressDialog.dismiss()
        } else {
            Log.e(
                TAG,
                String.format(
                    "Async command execution failed with returnCode=%d.",
                    returnCode
                )
            )
            listener?.onFailure(String.format(
                "Async command execution failed with returnCode=%d.",
                returnCode
            ))
           // if (progressDialog != null) progressDialog.dismiss()
        }
    }
    Log.e(TAG, "execFFmpegMergeVideo executionId-$executionId")
}
电话使用:

execFFmpegBinary(complexCommand, inputPath, listener, outputFilePath)

也许会有帮助。实际上它是说FFmpeg正在主目录上执行,android 10删除了应用程序主目录的执行权限。到目前为止,这似乎是一条死胡同。谢谢你的链接,这些库回调以不同的方式工作,但我将尝试解决同样的问题。在Manifests中为min API 24编写的库此库将apk大小增加到64 MB。在中为min API 24编写的库Manifest@MortezaKhodaie请查看LTS版本的文档。此库将apk大小增加到64 MB。您可以像这样在build.gradle中使用拆分apk来减小大小。检查此项:它会降低视频质量。你检查了吗?你可以使用我开发的这个库。为了保持视频质量,我们需要根据视频分辨率计算crf。看看回购协议。
 interface CompressionListener {
    fun compressionFinished(
        status: Int,
        isVideo: Boolean,
        fileOutputPath: String?
    )

    fun onFailure(message: String?)
    fun onProgress(progress: Int)
}
execFFmpegBinary(complexCommand, inputPath, listener, outputFilePath)