9

I want to merge a view with an already existing video and get a video out of it. An example would be, adding a text with a Textview on a video. This functionality can be seen by many social media apps like tik tok and instagram.

How are they doing that, someone got an idea? Currently I just have a Textview and a ScalableVideoView overlayed, but Idk how to merge them into an video.

Peter Jacobsen
  • 618
  • 2
  • 6
  • 18
Ahmet K
  • 713
  • 18
  • 42

2 Answers2

6

I think that you can achieve that using "ffmpeg" to generate a new video using an image/video overlay.

Check this post talking about this tool:ffmpeg

If you want to use ffmpeg on Android follow this link to build and call it from Android with JNI: ffmpeg on Android

source of ffmpeg: source

Hope it helps.

Ariel Carrera
  • 5,113
  • 25
  • 36
0

I would like to add, that you can use ffmpeg to create the image file, too (see end of posting):

create text video/image with ffmpeg

Conclusion: As far as i know, you need to do it in two steps (Example under windows):

ffmpeg.exe -f lavfi -i color=c=black@0.0:s=640x480,format=rgba -vf "drawtext=fontfile="C\\:/Windows/fonts/arialbd.ttf":fontsize=72:fontcolor='white':x=(w-text_w)/2:y=(h-text_h)/2:text='Stack Overflow'" -frames:v 1 overlay.png
ffmpeg.exe -i inputvideo.mp4 -i overlay.png -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" -pix_fmt yuv420p -c:a copy output.mp4
olir
  • 66
  • 5