使用ffmpeg android连接2个或更多gif文件

时间:2017-12-24 06:01:08

标签: java android ffmpeg

好吧,我花了很多时间找到一种使用ffmpeg库组合gif文件的方法。但是它们似乎都不适合我。

我尝试了什么(我使用过ffmpeg android java library):

    String gif1=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+"/gif1.gif";
    String gif2=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+"/gif2.gif";

    String commandStr="-i concat:"+gif1+"|"+gif2+" -c copy "+file.getAbsolutePath()+"/output.gif";

    String[]command=commandStr.split(" ");
        ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {

            @Override
            public void onStart() {}

            @Override
            public void onProgress(String message) {
             //   Toast.makeText(Main.this,"Progress: "+message,Toast.LENGTH_SHORT).show();
                Log.e("Progress TAG: ",message);
            }

            @Override
            public void onFailure(String message) {
                Toast.makeText(Main.this,"Failed: "+message,Toast.LENGTH_SHORT).show();
                Log.e("Failure TAG: ",message);
            }

            @Override
            public void onSuccess(String message)
            {
                Toast.makeText(Main.this,"Success: "+message,Toast.LENGTH_SHORT).show();
                Log.e("Success TAG: ",message);
            }

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

但是上面的命令给出了这样的错误。

ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
                                                                          built with gcc 4.8 (GCC)
                                                                          configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
                                                                          libavutil      55. 17.103 / 55. 17.103
                                                                          libavcodec     57. 24.102 / 57. 24.102
                                                                          libavformat    57. 25.100 / 57. 25.100
                                                                          libavdevice    57.  0.101 / 57.  0.101
                                                                          libavfilter     6. 31.100 /  6. 31.100
                                                                          libswscale      4.  0.100 /  4.  0.100
                                                                          libswresample   2.  0.101 /  2.  0.101
                                                                          libpostproc    54.  0.100 / 54.  0.100
                                                                        Input #0, gif, from 'concat:/storage/emulated/0/Pictures/gif1.gif|/storage/emulated/0/Pictures/gif2.gif':
                                                                          Duration: N/A, bitrate: N/A
                                                                            Stream #0:0: Video: gif, bgra, 500x500, 1.70 fps, 10 tbr, 100 tbn, 100 tbc
                                                                        Assertion video_enc->pix_fmt == AV_PIX_FMT_PAL8 failed at libavformat/gif.c:130

任何人都可以建议我这样做的有效命令。

P.S:我有一个动态文件列表,因此无法使用使用文本文件的demuxing方法。

0 个答案:

没有答案