0

I try to compress a video using a library and running a FFmpeg command in my android app written in java (although the library is in Kotlin) I manage to do basic operations but the current one I am going to show you will always fail with the following error code: Unknown encoder 'libx265'

The library expects the input to be a String[] and I assume that there is something going wrong but I cannot find what exactly.

the command line

    val query:Array<String> = arrayOf("-i", videoPath , "-c:v" , "libx265" ,"preset", "fast", "-crf", "30", "-tag:v", "hvc1", "-c:a", "eac3", "-b:a", "224k" ,            "$videoPath.mp4");

the entire code

fun videoCompress(videoPath: String) {
    val query:Array<String> = arrayOf("-i", videoPath , "-c:v" , "libx265" ,"-preset", "fast", "-crf", "30", "-tag:v", "hvc1", "-c:a", "eac3", "-b:a", "224k" , "$videoPath.mp4");

    CallBackOfQuery().callQuery(query, object : FFmpegCallBack {
        override fun statisticsProcess(statistics: Statistics) {
            Log.i("FFMPEG LOG : ", statistics.videoFrameNumber.toString())
        }

        override fun process(logMessage: LogMessage) {
            Log.i("FFMPEG LOG : ", logMessage.text)
        }

        override fun success() {
            Log.d("yyyy", "success: ")
        }

        override fun cancel() {
        }

        override fun failed() {
        }
    })
}

The Log from the code

what I added to my build.gradle file

    implementation 'com.github.SimformSolutionsPvtLtd:SSffmpegVideoOperation:1.0.8'

the result (exact)

Unknown encoder 'libx265'

2
  • Can you please execute with -report argument (after "$videoPath.mp4"), and post the content of the created log file (as text - not as image). I think your FFmpeg in not built with libx265, but I have not experience with JAVA and Android.
    – Rotem
    Oct 22, 2022 at 21:05
  • Hey I found another way to work around this issue and hopefully have solved it. But thanks anyway! Oct 23, 2022 at 19:43

1 Answer 1

0

Use this library

implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.2.2.LTS'

and this command

String cmd = "-y -i " + oldPath + " -c:a copy -r 30 -vcodec libx264 -crf 28 -preset ultrafast " + newFile.getPath();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.