Node-fluent-ffmpeg: How to add an image watermark

Created on 12 Nov 2017  路  2Comments  路  Source: fluent-ffmpeg/node-fluent-ffmpeg

Version information

  • fluent-ffmpeg version: 2.1.2
  • ffmpeg version: 3.3
  • OS: macOS 10.12.6

Code to reproduce

ffmpeg()
    .input("video-file.mov")
    .input("watermark.png")
    .complexFilter([
        "overlay=10:10"
    ])
    .videoCodec('libx264')
    .outputOptions('-pix_fmt yuv420p')

Expected results

The video should render with the watermark png onto it. There might be another way to do this. I am basically trying to do the same command聽from from this gist https://gist.github.com/bennylope/d5d6029fb63648582fed2367ae23cfd6.

Observed results

I get this error:

ffmpeg exited with code 1: Filtergraph 'scale=w=trunc(iw0.5/2)2:h=trunc(ih0.5/2)2' was specified through the -vf/-af/-filter option for output stream 0:0, which is fed from a complex filtergraph.
-vf/-af/-filter and -filter_complex cannot be used together for the same stream.

Stderr

ffmpeg version 3.3.1 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.42)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --disable-lzma --enable-nonfree --enable-vda
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/sebastienlavoie/Code/dovi-render-machine-app/storage/renders/particles.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2015-07-26T17:38:04.000000Z
Duration: 00:00:26.83, start: 0.000000, bitrate: 14433 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 14429 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 30k tbn, 60k tbc (default)
Metadata:
creation_time : 2015-07-26T17:38:04.000000Z
handler_name : Apple Alias Data Handler
encoder : H.264
timecode : 00:00:00;00
Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
Metadata:
creation_time : 2015-07-26T17:47:45.000000Z
handler_name : Apple Alias Data Handler
timecode : 00:00:00;00
Input #1, png_pipe, from '/Users/sebastienlavoie/Code/dovi-render-machine-app/public/images/dovi_logo.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 200x66, 25 tbr, 25 tbn, 25 tbc
Filtergraph 'scale=w=trunc(iw0.5/2)2:h=trunc(ih0.5/2)2' was specified through the -vf/-af/-filter option for output stream 0:0, which is fed from a complex filtergraph.
-vf/-af/-filter and -filter_complex cannot be used together for the same stream.

Most helpful comment

For those ending up here, I found the solution from this Stack Overflow answer: https://stackoverflow.com/questions/10934420/ffmpeg-how-to-scale-a-video-then-apply-a-watermark

ffmpeg()
   .input(videofile.mp4)
    .input(watermark.png)
    .videoCodec('libx264')
    .outputOptions('-pix_fmt yuv420p')
    .complexFilter([
        "[0:v]scale=640:-1[bg];[bg][1:v]overlay=W-w-10:H-h-10"
    ])

All 2 comments

For those ending up here, I found the solution from this Stack Overflow answer: https://stackoverflow.com/questions/10934420/ffmpeg-how-to-scale-a-video-then-apply-a-watermark

ffmpeg()
   .input(videofile.mp4)
    .input(watermark.png)
    .videoCodec('libx264')
    .outputOptions('-pix_fmt yuv420p')
    .complexFilter([
        "[0:v]scale=640:-1[bg];[bg][1:v]overlay=W-w-10:H-h-10"
    ])

thanks

Was this page helpful?
0 / 5 - 0 ratings