How to overlay a transparent PNG over video and scale to video size in FFmpeg

Daniel Jacob Archer

Right now I overlay a transparent PNG over a video first converting them both to the same size, but would love to just have it scale within the same command. Here’s the command now:

ffmpeg -y -i video.mp4 -i overlay.png -filter_complex 'overlay[out],amix=inputs=1,pan=stereo:c0=c0:c1=c1' -map '[out]' output.mp4

The best command should also permit a video that does not have an audio track and still overlay the PNG.

Gyan

Use

ffmpeg -y -i video.mp4 -i overlay.png
 -filter_complex "[1][0]scale2ref[i][m];[m][i]overlay[v]"
 -map "[v]" -map 0:a? -ac 2 output.mp4

The scale2ref scales the first input (to the filter) to the size of the second. The input pad indexes 0, and 1 refer to the first and 2nd input to FFmpeg, as that count begins from zero.

-map 0:a? - the ? tells FFmpeg to map the audio contingently i.e. if present. I have removed the amix since a) filters within a filter complex can't be contingent and b) there's only one input so there's nothing to 'mix'.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From

ffmpeg overlay timstamp over video

From Dev

ffmpeg: overlay a png image on a video with custom transparency?

From Dev

Update PNG overlay on video with ffmpeg

From Dev

In ffmpeg, how do I scale dvdsub subtitles to match video size, using scale2ref filter?

From Dev

ffmpeg overlay video on another

From Dev

Add image with scale + rotation to video overlay with FFMPEG?

From Dev

How to overlay a video on another video and also fade in a PNG

From Dev

FFMPEG : overlay image on video and retain size

From Dev

ffmpeg overlay transparent animated gif over video and keep gif background transparency

From Dev

ffmpeg delay video in overlay

From Dev

How to add an overlay with opacity to a video in ffmpeg?

From Dev

Semi Transparent overlay over HTML video is always behind video

From Dev

overlay transparent animation over video with ffmpeg

From Dev

Scale watermark overlay by video size with ffmpeg

From Dev

Loop a video overlay with ffmpeg

From Dev

How can I overlay PNGs with transparency over a video? (each PNG should cover one frame)

From Dev

How can I overlay a transparent video over an MP4?

From Dev

How to scale a video over time with ffmpeg

From Dev

Overlay a video over an image using ffmpeg

From Dev

FFmpeg Padding Video is not transparent

From Dev

ffmpeg overlay an gif over video to full scale of video dimension

From Dev

Overlay image on video using ffmpeg with adjustable png image

From Dev

ffmpeg scale logo size according to video size

From Dev

How to overlay a png to piped video source with audio mixed in via ffmpeg?

From Dev

Extract transparent png in .mov video without ffmpeg

From Dev

How to include both audios when overlay video on video with FFMPEG

From Dev

how to define overlay video position and size ffmpeg electronJS?

From Dev

FFMPEG: How to overlay a large size png on jpg

From Dev

How to overlay a box on a transparent video in FFmpeg

Related Related

  1. 1

    ffmpeg overlay timstamp over video

  2. 2

    ffmpeg: overlay a png image on a video with custom transparency?

  3. 3

    Update PNG overlay on video with ffmpeg

  4. 4

    In ffmpeg, how do I scale dvdsub subtitles to match video size, using scale2ref filter?

  5. 5

    ffmpeg overlay video on another

  6. 6

    Add image with scale + rotation to video overlay with FFMPEG?

  7. 7

    How to overlay a video on another video and also fade in a PNG

  8. 8

    FFMPEG : overlay image on video and retain size

  9. 9

    ffmpeg overlay transparent animated gif over video and keep gif background transparency

  10. 10

    ffmpeg delay video in overlay

  11. 11

    How to add an overlay with opacity to a video in ffmpeg?

  12. 12

    Semi Transparent overlay over HTML video is always behind video

  13. 13

    overlay transparent animation over video with ffmpeg

  14. 14

    Scale watermark overlay by video size with ffmpeg

  15. 15

    Loop a video overlay with ffmpeg

  16. 16

    How can I overlay PNGs with transparency over a video? (each PNG should cover one frame)

  17. 17

    How can I overlay a transparent video over an MP4?

  18. 18

    How to scale a video over time with ffmpeg

  19. 19

    Overlay a video over an image using ffmpeg

  20. 20

    FFmpeg Padding Video is not transparent

  21. 21

    ffmpeg overlay an gif over video to full scale of video dimension

  22. 22

    Overlay image on video using ffmpeg with adjustable png image

  23. 23

    ffmpeg scale logo size according to video size

  24. 24

    How to overlay a png to piped video source with audio mixed in via ffmpeg?

  25. 25

    Extract transparent png in .mov video without ffmpeg

  26. 26

    How to include both audios when overlay video on video with FFMPEG

  27. 27

    how to define overlay video position and size ffmpeg electronJS?

  28. 28

    FFMPEG: How to overlay a large size png on jpg

  29. 29

    How to overlay a box on a transparent video in FFmpeg

HotTag

Archive