user2458434
user2458434

Reputation: 23

Image overlay on video using ffmpeg android

I am trying to add image overlay on video using ffmpeg library but didn't succeed.

I tried sample using ffmpeg , https://drive.google.com/file/d/0B2aT0QoEmtuaN0VJZ2Z4ODY3T2s/view

and referred this link as well to overlay image on video, http://ksloan.net/watermarking-videos-from-the-command-line-using-ffmpeg-filters/#comment-9793 but getting error.

Below is my logcat error for reference:

07-31 10:23:43.406 29517-29517/com.examples.ffmpeg4android_demo D/ffmpeg4android: /storage/emulated/0/videokit/in.mp4 length in bytes: 840896 07-31 10:23:43.432 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: doInBackground started... 07-31 10:23:43.432 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: vk deleted: false 07-31 10:23:43.434 29517-30185/com.examples.ffmpeg4android_demo D/ffmpeg4android: Acquire wake lock 07-31 10:23:43.479 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: =======running first command========= 07-31 10:23:43.479 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: running ffmpeg4android_lib: 322.00.02_LM322 07-31 10:23:43.479 29517-30185/com.examples.ffmpeg4android_demo D/ffmpeg4android: {"ffmpeg","-y","-loop","1","-i","/sdcard/videokit/logo.png","-i","/sdcard/videokit/in.mp4","-y","-filter_complex","overlay=0:0:shortest=1","/sdcard/videokit/out.m4v"} 07-31 10:23:43.485 29517-30185/com.examples.ffmpeg4android_demo D/ffmpeg4android: /sdcard/videokit/logo.png length in bytes: 6047 07-31 10:23:43.486 29517-30185/com.examples.ffmpeg4android_demo D/ffmpeg4android: /sdcard/videokit/in.mp4 length in bytes: 840896 07-31 10:23:43.486 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: videokitLibPath exits 07-31 10:23:43.486 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: /data/user/0/com.examples.ffmpeg4android_demo/lib/libvideokit.so 07-31 10:23:43.493 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: libvideokit.so loaded 07-31 10:23:43.493 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: args is not NULL 07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: more then one arg 07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: function symbol found 07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo D/Videokit: Calling videokit run via loader 07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo D/Videokit: call licenseCheckComplex 07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: isLicExistsComplex... 07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: You used 1 of your 15 trial days. 07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo D/Videokit: license check rc: 0 07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo D/Videokit: ffmpeg4android base 2.5

                                                                        --------- beginning of crash

07-31 10:23:43.584 29517-30185/com.examples.ffmpeg4android_demo A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 30185 (AsyncTask #1) 07-31 10:23:44.432 29517-29517/com.examples.ffmpeg4android_demo I/Choreographer: Skipped 44 frames! The application may be doing too much work on its main thread.

Upvotes: 0

Views: 2959

Answers (1)

Mick
Mick

Reputation: 25481

You can use an ffmpeg Android wrapper and the regular ffmpeg command line syntax, which is very well supported and documented, to achieve this - bearing in mind that video processing on a mobile device is a heavy CPU user so may be slower than you would like and may also impact battery usage.

The following is a well supported ffmpeg wrapper:

You can add the image with ffmpeg using a command like this:

ffmpeg -i inputVideo.mp4 -i yourImage.png -filter_complex "overlay=5:5" -codec:a copy outputVideo.mp4

See this answer for more examples of placing the image - i.e. top left, bottom right etc: https://stackoverflow.com/a/10920872/334402

Upvotes: 0

Related Questions