在Android中使用ffmpeg在图片上叠加gif

时间:2019-06-17 12:45:09

标签: ffmpeg

我正在尝试在图像上叠加gif并将其另存为视频。并使用ffmpeg做到这一点,但出现此错误:

命令

String strFilter = "[1:v]scale=h="+ 150 +":w=" + 150 + "[overlay_scaled],"
                        + "[0:v][overlay_scaled]overlay=eval=init:x=W*" + 0
                        + ":y=H*" + 0;

String[] bb = new String[]{ "-i", inputFile,"-itsoffset", "0", "-i", inputGif, "-filter_complex", strFilter, "-preset", "ultrafast", "-g", "120", outputFile };

这里

  • inputFile是png图片
  • inputGif是gif图片
  • outputFile是mp4视频

日志

06-17 18:09:38.201 989-989/com.photo.editor E/FFmpeg ERROR::::::: 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, png_pipe, from '/storage/emulated/0/Pictures/MyCameraApp/IMG_20190617_180929.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgb24(pc), 1357x1485, 25 tbr, 25 tbn, 25 tbc
Input #1, gif, from '/storage/emulated/0/Pictures/MyCameraApp/t.gif':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: gif, bgra, 400x400, 6.67 fps, 6.67 tbr, 100 tbn, 100 tbc
[libx264 @ 0xb76dff30] width not divisible by 2 (1357x1485)
Output #0, mp4, to '/storage/emulated/0/Pictures/MyCameraApp/VID_20190617_180935.mp4':
    Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, 25 fps (default)
    Metadata:
      encoder         : Lavc57.24.102 libx264
Stream mapping:
  Stream #0:0 (png) -> overlay:main
  Stream #1:0 (gif) -> scale
  overlay -> Stream #0:0 (libx264)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

0 个答案:

没有答案