ffmpeg - 位置总是发生变化

ffmpeg - 位置总是发生变化

我的应用程序想法是用手机拍摄视频,在视频上叠加图像或 gif,然后将它们全部组合在一起。

问题是,叠加的图像/gif 的位置总是偏离我在屏幕上选择的位置。我认为这与纵横比有关,但我不知道如何修复它。

当我同时添加两个或更多图像/gif 时,问题变得更加严重。

这是我的一个覆盖的代码:

[-i, mobileVideo.mp4, -ignore_loop, 0, -i, cheaf.gif, -b:v, 1M, -filter_complex, [1:v]scale=60.0:60.0[ovrl1]; [0:v][ovrl1]overlay=overlay=54.71990411931819:225.6267755681818:shortest=1:format=auto[out] , -map, [out], -qscale:v, 2, /data/user/0/com.q8intouch.hareem/cache/JFkhb.mp4].

这些覆盖值是屏幕上的值。

以下是日志:

/flutter-ffmpeg(24748): Running FFmpeg with arguments: [-i, /data/user/0/com.q8intouch.hareem/cache/REC9127166347200678375.mp4, -ignore_loop, 0, -i, /data/user/0/com.q8intouch.hareem/cache/1622464370-cheaf.gif, -b:v, 1M, -filter_complex, [1:v]scale=60.0:60.0[ovrl1]; [0:v][ovrl1]overlay=54.71990411931819:225.6267755681818:shortest=1:format=auto[out] , -map, [out], -qscale:v, 2, /data/user/0/com.q8intouch.hareem/cache/z3Xt0.mp4].
I/mobile-ffmpeg(24748): ffmpeg version v4.4-dev-416
I/mobile-ffmpeg(24748):  Copyright (c) 2000-2020 the FFmpeg developers
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):   built with Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn)
I/mobile-ffmpeg(24748):   configuration: --cross-prefix=i686-linux-android- --sysroot=/files/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-x86/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=i686 --cpu=i686 --cc=i686-linux-android24-clang --cxx=i686-linux-android24-clang++ --extra-libs='-L/home/taner/Projects/mobile-ffmpeg/prebuilt/android-x86/cpu-features/lib -lndk_compat' --target-os=android --disable-neon --disable-asm --disable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-mediacodec
I/mobile-ffmpeg(24748):   libavutil      56. 55.100 / 56. 55.100
I/mobile-ffmpeg(24748):   libavcodec     58. 96.100 / 58. 96.100
I/mobile-ffmpeg(24748):   libavformat    58. 48.100 / 58. 48.100
I/mobile-ffmpeg(24748):   libavdevice    58. 11.101 / 58. 11.101
I/mobile-ffmpeg(24748):   libavfilter     7. 87.100 /  7. 87.100
I/mobile-ffmpeg(24748):   libswscale      5.  8.100 /  5.  8.100
I/mobile-ffmpeg(24748):   libswresample   3.  8.100 /  3.  8.100
I/mobile-ffmpeg(24748): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/com.q8intouch.hareem/cache/REC9127166347200678375.mp4':
I/mobile-ffmpeg(24748):   Metadata:
I/mobile-ffmpeg(24748):     major_brand     :
I/mobile-ffmpeg(24748): mp42
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     minor_version   :
I/mobile-ffmpeg(24748): 0
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     compatible_brands:
I/mobile-ffmpeg(24748): isommp42
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     creation_time   :
I/mobile-ffmpeg(24748): 2021-07-02T13:02:18.000000Z
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     com.android.version:
I/mobile-ffmpeg(24748): 8.1.0
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):   Duration:
I/mobile-ffmpeg(24748): 00:00:03.05
I/mobile-ffmpeg(24748): , start:
I/mobile-ffmpeg(24748): 0.000000
I/mobile-ffmpeg(24748): , bitrate:
I/mobile-ffmpeg(24748): 104 kb/s
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     Stream #0:0
I/mobile-ffmpeg(24748): (eng)
I/mobile-ffmpeg(24748): : Video: h264 (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 320x240, 88 kb/s
I/mobile-ffmpeg(24748): , SAR 1:1 DAR 4:3
I/mobile-ffmpeg(24748): ,
I/mobile-ffmpeg(24748): 15.10 fps,
I/mobile-ffmpeg(24748): 28.92 tbr,
I/mobile-ffmpeg(24748): 90k tbn,
I/mobile-ffmpeg(24748): 180k tbc
I/mobile-ffmpeg(24748):  (default)
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     Metadata:
I/mobile-ffmpeg(24748):       rotate          :
I/mobile-ffmpeg(24748): 90
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):       creation_time   :
I/mobile-ffmpeg(24748): 2021-07-02T13:02:18.000000Z
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):       handler_name    :
I/mobile-ffmpeg(24748): VideoHandle
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     Side data:
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748): displaymatrix: rotation of -90.00 degrees
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     Stream #0:1
I/mobile-ffmpeg(24748): (eng)
I/mobile-ffmpeg(24748): : Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s
I/mobile-ffmpeg(24748):  (default)
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     Metadata:
I/mobile-ffmpeg(24748):       creation_time   :
I/mobile-ffmpeg(24748): 2021-07-02T13:02:18.000000Z
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):       handler_name    :
I/mobile-ffmpeg(24748): SoundHandle
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748): Input #1, gif, from '/data/user/0/com.q8intouch.hareem/cache/1622464370-cheaf.gif':
I/mobile-ffmpeg(24748):   Metadata:
I/mobile-ffmpeg(24748):     comment         :
I/mobile-ffmpeg(24748): Resized on https://ezgif.com/resize
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):   Duration:
I/mobile-ffmpeg(24748): 00:00:03.56
I/mobile-ffmpeg(24748): , start:
I/mobile-ffmpeg(24748): 0.000000
I/mobile-ffmpeg(24748): , bitrate:
I/mobile-ffmpeg(24748): 748 kb/s
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     Stream #1:0
I/mobile-ffmpeg(24748): : Video: gif, bgra, 250x250
I/mobile-ffmpeg(24748): ,
I/mobile-ffmpeg(24748): 25 fps,
I/mobile-ffmpeg(24748): 25 tbr,
I/mobile-ffmpeg(24748): 100 tbn,
I/mobile-ffmpeg(24748): 100 tbc
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748): Stream mapping:
I/mobile-ffmpeg(24748):   Stream #0:0 (h264) -> overlay:main
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):   Stream #1:0 (gif) -> scale
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):   overlay
I/mobile-ffmpeg(24748):  -> Stream #0:0 (mpeg4)
I/mobile-ffmpeg(24748): Press [q] to stop, [?] for help
I/mobile-ffmpeg(24748): frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A
W/mobile-ffmpeg(24748): [graph 0 input from stream 1:0 @ 0x6ae849e0] sws_param option is deprecated and ignored
W/mobile-ffmpeg(24748): [graph 0 input from stream 0:0 @ 0x6ae85ca0] sws_param option is deprecated and ignored
W/mobile-ffmpeg(24748): [swscaler @ 0x4994e000] No accelerated colorspace conversion found from yuv420p to bgra.
I/mobile-ffmpeg(24748): Output #0, mp4, to '/data/user/0/com.q8intouch.hareem/cache/z3Xt0.mp4':
I/mobile-ffmpeg(24748):   Metadata:
I/mobile-ffmpeg(24748):     major_brand     :
I/mobile-ffmpeg(24748): mp42
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     minor_version   :
I/mobile-ffmpeg(24748): 0
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     compatible_brands:
I/mobile-ffmpeg(24748): isommp42
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     com.android.version:
I/mobile-ffmpeg(24748): 8.1.0
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     encoder         :
I/mobile-ffmpeg(24748): Lavf58.48.100
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     Stream #0:0
I/mobile-ffmpeg(24748): : Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 240x320 [SAR 1:1 DAR 3:4], q=2-31, 1000 kb/s
I/mobile-ffmpeg(24748): ,
I/mobile-ffmpeg(24748): 28.92 fps,
I/mobile-ffmpeg(24748): 11104 tbn,
I/mobile-ffmpeg(24748): 28.92 tbc
I/mobile-ffmpeg(24748):  (default)
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     Metadata:
I/mobile-ffmpeg(24748):       encoder         :
I/mobile-ffmpeg(24748): Lavc58.96.100 mpeg4
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748):     Side data:
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748): cpb:
I/mobile-ffmpeg(24748): bitrate max/min/avg: 0/0/1000000 buffer size: 0
I/mobile-ffmpeg(24748): vbv_delay: N/A
I/mobile-ffmpeg(24748):
I/mobile-ffmpeg(24748): frame=    1 fps=0.0 q=2.0 size=       0kB time=00:00:00.00 bitrate=3911.1kbits/s speed=0.000168x
E/AudioTrack(24748): Discontinuity detected [expected 2533046000, got 2534272000]
I/mobile-ffmpeg(24748): frame=    1 fps=0.9 q=2.0 size=       0kB time=00:00:00.00 bitrate=3911.1kbits/s speed=8.5e-05x
I/mobile-ffmpeg(24748): frame=   37 fps= 23 q=2.0 size=       0kB time=00:00:01.24 bitrate=   0.3kbits/s dup=35 drop=0 speed=0.759x
I/mobile-ffmpeg(24748): frame=   46 fps= 20 q=2.0 size=       0kB time=00:00:01.55 bitrate=   0.2kbits/s dup=38 drop=0 speed=0.693x
I/mobile-ffmpeg(24748): frame=   50 fps= 18 q=2.0 size=       0kB time=00:00:01.69 bitrate=   0.2kbits/s dup=38 drop=0 speed=0.607x
E/AudioTrack(24748): Discontinuity detected [expected 2536092000, got 2537318000]
I/mobile-ffmpeg(24748): frame=   51 fps= 14 q=2.0 size=       0kB time=00:00:01.72 bitrate=   0.2kbits/s dup=38 drop=0 speed=0.481x
I/mobile-ffmpeg(24748): frame=   58 fps= 14 q=2.0 size=       0kB time=00:00:01.97 bitrate=   0.2kbits/s dup=38 drop=0 speed=0.479x
I/mobile-ffmpeg(24748): frame=   67 fps= 14 q=2.0 size=       0kB time=00:00:02.28 bitrate=   0.2kbits/s dup=38 drop=0 speed=0.488x
I/mobile-ffmpeg(24748): frame=   73 fps= 14 q=2.0 size=       0kB time=00:00:02.49 bitrate=   0.1kbits/s dup=39 drop=0 speed=0.47x
E/AudioTrack(24748): Discontinuity detected [expected 2539138000, got 2540364000]
I/mobile-ffmpeg(24748): frame=   78 fps= 13 q=2.0 size=       0kB time=00:00:02.66 bitrate=   0.1kbits/s dup=42 drop=0 speed=0.456x
I/mobile-ffmpeg(24748): frame=   84 fps= 13 q=2.0 size=       0kB time=00:00:02.87 bitrate=   0.1kbits/s dup=42 drop=0 speed=0.452x
I/mobile-ffmpeg(24748): frame=   88 fps= 13 q=2.0 Lsize=     110kB time=00:00:03.00 bitrate= 298.7kbits/s dup=42 drop=0 speed=0.445x
I/mobile-ffmpeg(24748): video:108kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:
I/mobile-ffmpeg(24748): 1.131698%
I/mobile-ffmpeg(24748):
D/flutter-ffmpeg(24748): FFmpeg exited with rc: 0

相关内容