overlaying .png without loosing transparency of .mov using FFMPEG

1

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

drexdelta

Posted 2018-10-03T08:02:20.373

Reputation: 13

Show the complete log from your command. – llogan – 2018-10-03T17:42:58.337

@LordNeckbeard , I guess u were looking for the ffmpeg versions and all. I have added it to the question. – drexdelta – 2018-10-04T07:00:59.900

Thanks, but I also wanted to see all of the information and is why I asked for the complete log, but some has been omitted. Anyway, try ffmpeg -i inputVideo.mov -i overlay.png -filter_complex "overlay=100:254:format=auto" -c:v prores_ks output.mov. View the log and check that it outputs yuva444p10le pixel format. – llogan – 2018-10-04T17:37:49.963

Thank you, it worked. Can you write the answer, so that I can green it :) . – drexdelta – 2018-10-05T08:30:52.003

Sure. Added with some minor changes. I wasn't sure if it would work for you when I wrote the answer as I was unable to try it myself. – llogan – 2018-10-05T18:20:22.760

I have slight problem :( . when I run that command on my MACbook pro. it worked pretty fine. Now, I am trying to generate docker image of ubuntu. and trying to run that command on docker. and I am getting an error given in link :( . any idea why I can't find that particular filter ? ... https://www.ideone.com/A8Ffgj .

– drexdelta – 2018-10-05T18:32:18.603

I am simply installing ffmpeg with apt-get with command """apt install -y ffmpeg""" – drexdelta – 2018-10-05T18:33:28.517

FFmpeg 3.2 release branch is from 2016-10-26, but format=auto was added on 2017-06-24. Remove that option or upgrade your ffmpeg. – llogan – 2018-10-05T18:39:06.537

okay. I will see if overlay works without that flag. otherwise I will upgrade my ffmpeg. Thank you for quick reply :) . – drexdelta – 2018-10-05T18:40:26.727

Or change auto to yuv444. – llogan – 2018-10-05T18:41:12.093

Answers

0

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.

There are two ProRes encoders: prores_aw and prores_ks, but only prores_ks supports alpha. See ffmpeg -encoders and ffmpeg -h encoder=prores_ks for more info.

Example command

ffmpeg -i inputVideo.mov -i overlay.png -filter_complex "overlay=100:-1:format=auto" -c:v prores_ks -c:a copy output.mov

Checking the output

View the log during encoding and make sure that it outputs the yuva444p10le pixel format such as:

Stream #0:0: Video: prores (prores_ks) (ap4h / 0x68347061), yuva444p10le, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc

llogan

Posted 2018-10-03T08:02:20.373

Reputation: 31 929