0

I have encountered a strange problem. When using ffmpeg provided in javacpp-presets to perform an overlay operation on two videos, if the video at the bottom is in motion, the video at the top becomes blurry. However, when I use locally compiled ffmpeg to execute the same command, there is no such problem. I have tried presets 5.x and 6.x, and the same problem occurs. Who can help me?

command:

.javacpp/cache/ffmpeg-5.0-1.5.7-macosx-x86_64.jar/org/bytedeco/ffmpeg/macosx-x86_64/ffmpeg -y -f lavfi -i color=c=black:s=1920x1080 -i a.mp4 -i b.mp4 -i c.mp4 -filter_complex "[2:v][3:v]alphamerge[alphamerge0];[1:v]scale=1920x1080[out0];[0:v][out0]overlay=enable='between(t,0.0,40.141)':x=0.0:y=0.0[overlay0];[overlay0][alphamerge0]overlay=enable='between(t,0.0,40.141)':x=0.0:y=0.0[out]" -preset medium -t 00:00:40.141 -crf 20 -vcodec h264 -map "[out]" -profile:v high -force_key_frames "expr:gte(t,n_forced*8)" out.mp4

I have tried to change preset,crf,codec,profile and so on, nothing works.

blurry ffmpeg version:

.javacpp/cache/ffmpeg-5.0-1.5.7-macosx-x86_64.jar/org/bytedeco/ffmpeg/macosx-x86_64/ffmpeg -version
ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --prefix=.. --disable-iconv --disable-opencl --disable-sdl2 --disable-bzlib --disable-lzma --disable-linux-perf --disable-xlib --enable-shared --enable-version3 --enable-runtime-cpudetect --enable-zlib --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-openssl --enable-libopenh264 --enable-libvpx --enable-libfreetype --enable-libopus --enable-libxml2 --enable-libsrt --enable-libwebp --enable-pthreads --enable-indev=avfoundation --disable-libxcb --extra-cflags='-I../include/ -I../include/libxml2' --extra-ldflags=-L../lib/ --extra-libs='-lstdc++ -ldl -lz -lm'
libavutil      57. 17.100 / 57. 17.100
libavcodec     59. 18.100 / 59. 18.100
libavformat    59. 16.100 / 59. 16.100
libavdevice    59.  4.100 / 59.  4.100
libavfilter     8. 24.100 /  8. 24.100
libswscale      6.  4.100 /  6.  4.100
libswresample   4.  3.100 /  4.  3.100

normal local version:

ffmpeg -version
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2.5)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
libavutil      57. 17.100 / 57. 17.100
libavcodec     59. 18.100 / 59. 18.100
libavformat    59. 16.100 / 59. 16.100
libavdevice    59.  4.100 / 59.  4.100
libavfilter     8. 24.100 /  8. 24.100
libswscale      6.  4.100 /  6.  4.100
libswresample   4.  3.100 /  4.  3.100
libpostproc    56.  3.100 / 56.  3.100
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Lance
  • 291
  • 1
  • 3
  • 5
  • please show this. make sure you don't show us mere screenshots but _unresampled_ frames from the output (and the inputs) – Christoph Rackwitz Mar 28 '23 at 09:30
  • 1
    I don't know about `javacpp`, but the issue may be related to `-vcodec h264`. It uses `libopenh264` encoder instead of libx264 (related to the fact that FFmpeg is built with `--enable-libopenh264`). I think `libopenh264` encoder doesn't support the `crf` argument. Try setting high bitrate instead. Check the [options of libopenh264](https://ffmpeg.org/ffmpeg-codecs.html#Options-30). – Rotem Mar 29 '23 at 19:50
  • @Rotem Thank you very much! you are absolutely right, the difference in these two libraries is what causes the problem. – Lance Mar 31 '23 at 02:00
  • If you want to use libx264, please use the libraries from the -gpl builds as mentioned in the README.md file: https://github.com/bytedeco/javacv/ – Samuel Audet Apr 01 '23 at 10:23

0 Answers0