cropsly / ffmpeg-android-java

Android java library for FFmpeg binary compiled using https://github.com/writingminds/ffmpeg-android
http://writingminds.github.io/ffmpeg-android-java
GNU General Public License v3.0
3.32k stars 831 forks source link

Error initializing complex filters #340

Closed darrinps closed 4 years ago

darrinps commented 4 years ago

This is similar to a closed issue, but the person never shared their code. I was having the same problem.

Here is what I was doing:

`

         val cmd = "-y -i $inputFileUrl -i $transparencyFullUrl -filter_complex \"[1]format=bgra,colorchannelmixer=aa=1,rotate=0:c=black@0:ow=rotw(0):oh=roth(0) 
         [overlayImage];[0][overlayImage]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2\" 
        $outputPathAndName"
    val command = cmd.split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()

    Timber.i("*** About to try FFmpeg with the following lines. ***")

    for(line in command) {
        Timber.i(line)
    }

    try {
        FFmpeg.getInstance(context).execute(command, object : ExecuteBinaryResponseHandler() {

            override fun onSuccess(s: String) {
                callback.onFinishOverlay(outputPathAndName, start, end)
            }
   ...

`

The actual text gets spit out by Timber is as follows: 2019-08-19 12:34:24.484 11669-11669/com.android.app I/VideoEditorUtil: -y 2019-08-19 12:34:24.484 11669-11669/com.android.app I/VideoEditorUtil: -i 2019-08-19 12:34:24.484 11669-11669/com.android.app I/VideoEditorUtil: /storage/emulated/0/Android/data/com.android.app/cache/trimmedVideo_20190819_123424.mp4 2019-08-19 12:34:24.485 11669-11669/com.android.app I/VideoEditorUtil: -i 2019-08-19 12:34:24.485 11669-11669/com.android.app I/VideoEditorUtil: /storage/emulated/0/Android/data/com.android.app/cache/transparency.png 2019-08-19 12:34:24.485 11669-11669/com.android.app I/VideoEditorUtil: -filter_complex 2019-08-19 12:34:24.485 11669-11669/com.android.app I/VideoEditorUtil: "[1]format=bgra,colorchannelmixer=aa=1,rotate=0:c=black@0:ow=rotw(0):oh=roth(0)[overlayImage];[0][overlayImage]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" 2019-08-19 12:34:24.485 11669-11669/com.android.app I/VideoEditorUtil: /storage/emulated/0/Android/data/com.android.app/cache/baked_trimmedVideo_20190819_123424.mp4

The exact error is showing as:

[AVFilterGraph @ 0xf6496080] No such filter: '"' Error initializing complex filters. Invalid argument

darrinps commented 4 years ago

Here is the solution for others seeing this in the future.

Just remove the \" before and after the parameters.

So the val cmd line goes to this:

                 val cmd = "-y -i $inputFileUrl -i $transparencyFullUrl -filter_complex [1]format=bgra,colorchannelmixer=aa=1,rotate=0:c=black@0:ow=rotw(0):oh=roth(0)[overlayImage];[0][overlayImage]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2 $outputPathAndName"
devt23 commented 3 years ago

I have same problem for reverse video command.Please help me out.

ffmpeg-y-i/storage/emulated/0/Editor/VideoTrim/VideoTrim_134850.mp4-filter_complex[0:v]reverse[v];[0:a]areverse[a]-map[v]-map[a],[0:v]reverse[v];[0:a]areverse[a]-map[v]-map[a]-presetsuperfast/storage/emulated/0/Editor/VideoEdit/1613031543160.mp4

AVLOG: [AVFilterGraph @ 0x7e1f17efe0] Unable to parse graph description substring: "-map[v]-map[a],[0:v]reverse[v];[0:a]areverse[a]-map[v]-map[a]" AVLOG: Error initializing complex filters. AVLOG: Invalid argument