Add animated overlay to video from camera

Oleg Filimonov

I need to overlay multiple images with animated position, alpha and rotation on recorded video. What's the best way to accomplish this?

Currently I'm looking at ffmpeg, is it possible to add position animation to overlays using ffmpeg?

Oleg Filimonov

Solution example:

ffmpeg -y -i video.mp4 -i overlay.png -filter_complex "[0][1]overlay=x=mod((1080/4 + sin(t)*1080/4)\,1920):y=mod(t*300\,1080)[res];" -map "[res]" -preset ultrafast out.mp4

Explanation:

Overlay input [1] (overlay.png) over input [0] (video.mp4) and position overlay using evaluation x=mod((1080/4 + sin(t)*1080/4)\,1920):y=mod(t*300\,1080), where t = time in milliseconds. Then map overlay result to stream [res], and output to out.mp4.

A more complex example with multiple overlays and using gif as overlay:

ffmpeg -y -i video.mp4 -ignore_loop 0 -i overlay.gif -filter_complex `
>> "[0][1]overlay=x=mod((1080/4 + sin(t)*1080/4)\,1920):y=mod(t*300\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*1 + 1080/4 - sin(2*t)*1080/4)\,1920):y=mod(100 + t*300\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*2 + 1080/4 - sin(-90 + t/2)*1080/4)\,1920):y=mod(150 + t*250\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*3 + 1080/4 - sin(90 + 3*t)*1080/4)\,1920):y=mod(200 + t*100\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*4 + 1080/4 - sin(180 + t)*1080/4)\,1920):y=mod(t*250\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*5 + 1080/4 - sin(-180 + t)*1080/4)\,1920):y=mod(t*100\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*6 + 1080/4 - sin(2*t)*1080/4)\,1920):y=100 + mod(100 + t*300\,1080):shortest=1[res]`
>> " -map "[res]" -preset ultrafast out.mp4

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to save a video from AVAssetExportSession to Camera Roll?

From Dev

How to open photo gallery by clicking a button from a camera overlay?

From Dev

data from camera video returning zero

From Dev

Add slash to fa-video-camera

From Dev

How to add overlay on the Camera using ZBAR in Android

From Dev

How to add button overLay in Video Tag

From Dev

Objective-C How To Add Overlay To Video Using AVFoundation?

From Dev

Add image overlay on video FFmpeg

From Dev

Add animated overlay image to video

From Dev

Add a moving overlay of rectangular shape to html5 video

From Dev

Rendering a UIView in which something gets animated and export a video from it

From Dev

Add an overlay to web view or camera in Android

From Dev

Camera Lense overlay - WindowsRT

From Dev

add UIView overlay to UIIMagePickerController video recording

From Dev

data from camera video returning zero

From Dev

How to add sticker overlay to camera photo

From Dev

Is there a way to generate left and right camera views from one camera video

From Dev

How to add overlay on the Camera using ZBAR in Android

From Dev

How to add button overLay in Video Tag

From Dev

How to add web cam(video) recording as overlay using ffmpeg

From Dev

Cordova android app with image overlay over video camera

From Dev

FFMpeg: How to add an overlay to a video; then add 5 seconds a still image + 5 seconds silence

From Dev

Rendering a UIView in which something gets animated and export a video from it

From Dev

Add an overlay to web view or camera in Android

From Dev

QML overlay on the camera video

From Dev

Twilio video: How can I overlay the local camera video over the remote video feed?

From Dev

how to add a image to camera overlay view (swift4)

From Dev

Animated overlay not transitioning properly on iPad

From Dev

How to overlay multiple animated images on a video using ffmpeg

Related Related

  1. 1

    How to save a video from AVAssetExportSession to Camera Roll?

  2. 2

    How to open photo gallery by clicking a button from a camera overlay?

  3. 3

    data from camera video returning zero

  4. 4

    Add slash to fa-video-camera

  5. 5

    How to add overlay on the Camera using ZBAR in Android

  6. 6

    How to add button overLay in Video Tag

  7. 7

    Objective-C How To Add Overlay To Video Using AVFoundation?

  8. 8

    Add image overlay on video FFmpeg

  9. 9

    Add animated overlay image to video

  10. 10

    Add a moving overlay of rectangular shape to html5 video

  11. 11

    Rendering a UIView in which something gets animated and export a video from it

  12. 12

    Add an overlay to web view or camera in Android

  13. 13

    Camera Lense overlay - WindowsRT

  14. 14

    add UIView overlay to UIIMagePickerController video recording

  15. 15

    data from camera video returning zero

  16. 16

    How to add sticker overlay to camera photo

  17. 17

    Is there a way to generate left and right camera views from one camera video

  18. 18

    How to add overlay on the Camera using ZBAR in Android

  19. 19

    How to add button overLay in Video Tag

  20. 20

    How to add web cam(video) recording as overlay using ffmpeg

  21. 21

    Cordova android app with image overlay over video camera

  22. 22

    FFMpeg: How to add an overlay to a video; then add 5 seconds a still image + 5 seconds silence

  23. 23

    Rendering a UIView in which something gets animated and export a video from it

  24. 24

    Add an overlay to web view or camera in Android

  25. 25

    QML overlay on the camera video

  26. 26

    Twilio video: How can I overlay the local camera video over the remote video feed?

  27. 27

    how to add a image to camera overlay view (swift4)

  28. 28

    Animated overlay not transitioning properly on iPad

  29. 29

    How to overlay multiple animated images on a video using ffmpeg

HotTag

Archive