Possible to use Android MediaMuxer to overlay an audio clip? - android

I am trying to add a short audio clip on top of a video clip. I have been able to use Android's MediaMuxer to combine a .mp4 with video only and a .mp4 with audio only, but my current task is to overlay an .mp4 audio clip on top of a video+audio .mp4 clip in the middle. I have tried using the mp4parser library that has been suggested in other threads but have found troubles with that route (SampleDescriptionBoxes never match).
My idea was to use writeSampleData() to the MediaMuxer with data extracted from separate .mp4 clips. I would write the audio from the original video, then at the given point start writing the new audio. Finally, I would return to the audio from the original video again. Does anyone know if this is feasible? I am having troubles mostly because I don't understand how presentationTimeUs is supposed to work and the result is not streamable.
Any suggestions/help are appreciated!

Related

Android mediacodec: Is it possible to encode audio and video at the same time using mediacodec and muxer?

There is some good documentation on this site called big flake about how to use media muxer and mediacodec to encode then decode video as mp4, or extract video then encode it again and more stuff.
But it doesnt seem that there is a way to encode audio with video at the same time, no documentation or code about this. It doesn't seem impossible.
Question
Do you know any stable way of doing it that will work on all devices greater than android 18?
Why no one implemented it, is it hard to implement?
You have to create 2 Mediacodec instances, one for video and one for audio and then use MediaMuxer to mux the video with audio after encoding, you can take a look at ExtractDecodeEditEncodeMuxTest.java and at this project to capture camera/mic and save to mp4 file using Mediamuxer and Mediacodec

get audio from one mp4 and use it in resampled (smaller) mp4 in android

I have found a solution for resampling an .mp4 video taken with the camera on the device to make it smaller (resizing by resolution, bitrate, and framerate). The problem is, it doesn't carry the audio over.
I have looked at several different options for trying to get the audio out of my source (large) mp4 and push it into my smaller mp4 and I can't not seem to get any of these procedures to work correctly.
I've tried the following:
1) extracting the PCM audio from the source using: How do I extractor audio to mp3 from mp4 using java in Android?
2) converting the PCM to M4A and then adding the M4A to the smaller MP4 using: https://github.com/tqnst/MP4ParserMergeAudioVideo/blob/master/Mp4ParserSample-master/src/jp/classmethod/sample/mp4parser/MainActivity.java
that's the method I got closest with but the audio was really slow and didn't match up at all with the video in the smaller mp4.
I also tried a "direct copy" from one mp4 to the other with a variation of this: Concatenate multiple mp4 audio files using android´s MediaMuxer
that made my smaller mp4 actually larger (in file size) than my source mp4 and it didn't actually move the sound over.
The android documentation for MediaMuxer is pretty terrible and I can't make heads or tails of what I need to do to get this to work. It seems like it should be a pretty trivial task....
any suggestions or advice would be greatly appreciated.
TIA
I ended up just using ffmpeg with this solution:
https://github.com/WritingMinds/ffmpeg-android-java

Video Editing For Android

i want to build a app having video editing feature.
These are what I need:
Mix a new sound track(mp3) into a mp4.
Adjust sound volume proportion for original mp4 sound track and the new sound track.
Generate mp4 from images.
Remove some frames from mp4.
I've found FFMEPG but it's quite complicated.
Is there a easier one?
1.Mix a new sound track into a mp4.
2.Adjust sound volume proportion for original mp4 sound track and the new sound track.
--> Use MP4Parser for adding and removing audio tracks.
checkout this link http://code.google.com/p/mp4parser/
3.Generate mp4 from images.
4.Remove some frames from mp4.
--> Use JCodec to get all frames from mp4 or create mp4 from frames,
checkout this link http://jcodec.org/index.html
I think you are looking for JavaCv which wrapps OpenCV, FFmpeg, libdc1394, PGR FlyCapture, OpenKinect, videoInput, ARToolKitPlus, and flandmark. You can easily create video editing application using this.

Creating video from Frames in Android

I am using Android MediaCodec : ExtractMpegFramesTest for grabbing frames from video but now i am not getting any useful information on google for How can i create video from frames.png in android?
You can try INDE Media Pack - https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials
It has transcoding\remuxing functionality as MediaComposer class and several sample effects like JpegSubstituteEffect - it shows how substitute video frame by a picture from jpg file. You can take black video as a refefence and put images on it with a possibility to set duration, add audio track with help of audio effect etc.

Android Video Circular Buffer with Sound

I am using Google's Open Source Example: Grafika. I am using it's ContinuousCaptureActivity.java The CircularBuffer's Implementation is demonstrated in this Activity, but there is no audio included in the resultant Video file.
I want to add the Audio Recording functionality within this Activity and add the recorded Audio into the Video in the same CircularBuffered Fashion.
For achieving this i have explored the MediaCodec Library, which was introduced in 4.3+ versions. I have also used MediaMuxer to capture Video and Audio Streams and Muxed them into a single Video.
But, I am not sure about how to implement the Audio Recording functionality into the ContinuousCaptureActivity.java class. Any Help is highly appreciated.

Categories

Resources