Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

how to add text to the video in android?

In my app I record a video and I wanna overlay the url of my company on the right bottom of that video. I record video with MediaRecorder and there is no problem with the recording, but for adding text to the video I haven't been successful. I searched and found some library like FFmpeg and JavaCV which let user overlay a text on the video but I don't know if there is any way for using them in Android. after that found OnPreviewFrame which returns each frame of the camerapreivew. I want to get all frames after user touch record button and draw text using canvas to each frame and then save all those frame together until recording video stops, and videos duration are fix and 15 seconds. Is it a good solution? if it is, how should I implement OnPreviewFrame function? I know how to draw canvas but I don't know how to convert data[] to the bitmap.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using that method will be pretty heavy performance wise. I would definitely suggest you to take a deeper look into ffmeg. I believe that it is not that hard to use, and there are simple libs for ffmeg without hustle with NDK. Take a look at this library and check if there is function that you need available.

ffmpeg -i movie.mp4 -i logo.png -filter_complex overlay output.mp4

This command would be something that you are looking for.

If you still want to use something else than ffmeg I would suggest you to take a look at MediaMetadataRetriever

public Bitmap getFrameAtTime (long timeUs)

This method would be something that you could use. It gives you bitmap to draw on. But still it is going to be slow as hell. I tried do create gifs using this method, and after some time went back to ffmeg.

Hope it helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...