Search code examples
androidffmpegandroid-mediacodeclottiemediamuxer

Problems in making Video from Lottie JSON File and Overlay it with original video using FFMPEG


there is some unique concept about processing Lottie Animations using FFMPEG video processing library and MediaCodec. In that, I wants to make video from Lottie animation and overlay that video on other original video.

But the problem is i'm unable to make a video with transparent background from Lottie animation. So i made simple video from Lottie animation using MediaCodec and MediaMuxer, it takes one by one frame from Lottie Drawable and attach it to the video(Lottie Video). Here is the link about this concept- https://engineering.21buttons.com/how-to-generate-videos-using-lottie-in-android-2db6ecceb2a

And then i overlay this video to the original video using FFmpeg library. Here FFmpeg does two task, first it makes transparent background in Lottie Video and second it overlays this Lottie Video above the original video.

And here the actual problem is out, FFmpeg takes more than 8 to 9 minutes in processing of video of 25 seconds, So i wants to get solution for this problem, as i have time limit of only 1 to 2 minutes. Any one has a solution for it or new ides for implementation of this concept, then please tell me i'll appreciate it.

Graphical representation of this concept


Solution

  • Here is the solution, Instead of using FFMPEG library, I used OpenGL for overlaying Lottie frames directly to the original video. So, this takes only one step while the use of FFMPEG takes two steps of processing.

    So, this saves a lot of time for video processing. For instance, the video of 30 seconds takes only 35-40 seconds for processing using OpenGL. I have used this link for reference, if anyone wants a solution for this kind of situation,

    Opengl es 2.0 draw bitmap overlay on video