overlaying .png without loosing transparency of .mov using FFMPEG
I am trying to overlay .png(transparent image) over .mov (transparent video) using this blog. I am using basic command like,
ffmpeg -i inputVideo.mov -i overlay.png -filter_complex "overlay=100:254" output.mov
while looking for solution, I found similar issue here , but it uses C#. I am looking for simple ffmpeg command.
I also found this . and there is no solution :( . Thank you.
EDIT 1 : Added output of the command as per request.
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-gpl --enable-chromaprint --enable-ffplay --enable-frei0r --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopus --enable-librtmp --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzmq --enable-opencl --enable-videotoolbox --enable-openssl --enable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.3.0/include/openjpeg-2.3 --enable-nonfree
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'inputVideo.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.12.100
Duration: 00:00:04.02, start: 0.000000, bitrate: 35096 kb/s
Stream #0:0(eng): Video: prores (ap4h / 0x68347061), yuva444p10le, 540x640, 35241 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc (default)
Metadata:
handler_name : DataHandler
encoder : Apple ProRes 4444
timecode : 00:00:00:00
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
Metadata:
handler_name : DataHandler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
Metadata:
handler_name : DataHandler
timecode : 00:00:00:00
Input #1, png_pipe, from 'overlay.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 320x250 [SAR 2835:2835 DAR 32:25], 25 tbr, 25 tbn, 25 tbc
The default format for MOV is H.264 (if an encoder is available) which does not support an alpha channel so you have to manually specify ProRes if you want to keep that format.
Example
ffmpeg -i inputVideo.mov -i overlay.png -filter_complex "overlay=100:-1:format=auto" -c:v prores -c:a copy output.mov
You will need FFmpeg 4.2 or newer.
Checking for alpha
Use ffprobe
:
ffprobe -v error -show_entries stream=pix_fmt -of default=nk=1:nw=1 input.mov
Output should contain "a
" in the pixel format name, such as yuva444p12le
.