Adding watermark bitmap over video in android: 4.3's MediaMuxer or ffmpeg
I don't know much about the MediaMuxer but ffmpeg does support overlaying functionality. FFMPEG has various filters one of them is overlay filter. What I understand is you want to overlay an image (i.e. png) on the video, ffmpeg surely is a useful framework to do this job. You can set the output format you can set the co-ordinates of the image which is to be overplayed.
E.g.
ffmpeg -i input.avi -i logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' output.avi
Above command adds overlays logo.png on the input.avi video file in bottom left corner.
More information about the filters is available at following website,
https://www.ffmpeg.org/ffmpeg-filters.html#overlay-1
If this is a solution to your problem you need the C code equivalent to the above command. You also need to see the performance of the ffmpeg because it a pure software framework.
Hope I have understood your question correctly and this helps.
Adding a image resource over video file from sd card using ffmpeg or MediaMuxer for android
I've successfully achieved what you need. While the theory is quite simple, implementation details make it very hard to get something running.
Your solution starts here:
Download halfninja's project here: https://github.com/halfninja/android-ffmpeg-x264
and follow the instructions to the letter.
Some notes:
- it won't work with newer versions of ffmpeg, e.g. you must use the ffmpeg version the git submodule points to.
- it won't work with newer ndks. You must install the one he's listing there (r5c).
Once you successfully compile, you'll end up with an .so lib that has a "run" method, which you can call to run ffmpeg with the same parameters it gets on the command line.
Also:
- The code above contains a ffmpeg.c file which runs the "main" method, but uses global variables. this means that your code won't be re-entrant. Calling ffmpeg::main twice won't work. You'll have to add initialization code yourself when done, OR create a second library that dynamically loads this library in C and unloads it when done.
- The resulting library will be big as it includes all ffmpeg component, and will bloat your apk. You'll have to change the build file to include only the ffmpeg components you need. e.g. change
configure_ffmpeg
to work withminimal_featureset
, and--enable
only the codecs you need.
EDIT:
For mp4 w/ aac use the following configure_ffmpeg file:
--enable-muxer=mp4 --enable-encoder=libx264 --enable-libx264 \
--enable-encoder=h264 --enable-decoder=h264 --enable-demuxer=h264 --enable-muxer=h264 --enable-parser=h264 \
--enable-protocol=file \
--enable-hwaccels \
--enable-demuxer=mov --enable-decoder=aac --enable-decoder=aac_latm --enable-encoder=aac --enable-parser=aac --enable-demuxer=aac --enable-bsf=aac_adtstoasc \
--enable-encoder=aac --enable-parser=aac \
--enable-decoder=mpeg4 --enable-encoder=mpeg4 --enable-parser=mpeg4video --enable-demuxer=m4v"
Related Topics
Recycler View Showing Single Item
How to Put the Text on the Left of a Radio Button in Android
Android Studio 3.1 Cannot Resolve Symbol (Themes, Widget, Attr, etc.)
How to Use Recyclerview.Scrolltoposition() to Move the Position to the Top of Current View
Why Ondraw Is Not Called After Invalidate()
The Application Icon Does Not Show on Action Bar
Android Google+ Integration - Repeated Userrecoverableauthexception
Justify Text in an Android App Using a Webview But Presenting a Textview-Like Interface
React Native Adb Reverse Enoent
How to Play Audio File in Android
Mylib.So Has Text Relocations. This Is Wasting Memory and Is a Security Risk. Please Fix
How to Open Private Files Saved to the Internal Storage Using Intent.Action_View
Custom Format Edit Text Input Android to Accept Credit Card Number
Avoiding Content Type Issues When Downloading a File via Browser on Android