Need to encode and decode android - android

MY GOALS
1. Decode an MP4 Video.
2. Decode camera frames, edit with renderscript (apply effects)
3. Display the camera data inside an oval on top on the background video in Goal 1.
4. Encode the frames and use the MediaMuxer to save the video.
MY PROBLEM
I can successfully do goals 1-3 but I am stuck on goal 4. When I am using the second MediaCodec for encoding frames (1st MediaCodec is used in Goal 1), my whole app freezes and needs to be forced closed.
Can android actually handle two MediaCodecs simultaneously?
Can anyone offer any help on this please?
Thanks

Related

MP4 Muxed on Android Skips Final Frame but only in Some Applications

I am using the media muxer on Android to create an mp4. Basically I am feeding bitmaps to the muxer and encoding each bitmap as 1 second of video. Everything is working fine except that the last frame of video (the last bitmap) flashes at the very end of the video but doesn't also hold for 1 full second. This occurs when sharing to instagram, hangouts etc but if I pull the mp4 up on my mac it plays the full final second. Does anyone know what may be causing this? I am using this implementation:
How to encode Bitmaps into a video using MediaCodec?

Android record square video and concat

Is there a way to record square (640x640) videos and concat them in Android? I looked up in the Internet and found some solutions. The solution seems to be "ffmpeg". However, to use ffmpeg I need to dive into NDK and build ffmpeg from its sources. Is there a solution by only using the Android SDK?
My basic needs are:
Record multiple videos (square format)
Resize captured videos (i.e. 480x480 to 640x640)
Concat captured videos
Rotate final video (clockwise 90)
Final output will be in mp4 or mpg format
Is there a solution by only using the Android SDK?
Not really.
Your primary video recording option is MediaRecorder, and it supports exactly nothing of what you list. For example, there is no requirement for any Android device to support taking square videos.
You are also welcome to use the camera preview stuff to assemble your own videos from individual frames. Vine does this, AFAIK. There, you could perhaps use existing Bitmap facilities to handle the cropping, resizing, and rotating. However, this will be slow, and doing this work in a way that can keep up with a reasonable frame rate will be difficult. Also, I do not know if there is a library that can stitch those frames together into a video, or blend in any sort of audio (camera previews are pure images).

Converting images to video android

I am using external camera with my application. The camera takes 9 pictures every second (9fps). The pictures are bitmaps 384x288. I need to create from this pictures a video file.
What I have tried:
Using Jcodec
The problem: jcodec is relatively slow, and for it to work properly i add the bitmaps to ArrayList and when the record stopped i convert the array to video. I takes to much time. For 30 sec video there is about 1 min rendering time.
Using native mediaCodec
The problem: I could only generate AVI files (video/avc) that not readable in the original android player. I can not use what is written here: http://bigflake.com/mediacodec/ because I developing for API 16. I have tried using (video/mp4v-es) but the video is corrupted and not playable in any player.
Using FFmpeg
The problem: Very complicated to implement in android, and I am not sure it will give me the result I needed after spending time to implement this. The result I need is to record video streaming as I get the bitmap without any delay.
What can you suggest me?

FFMPEG output video from stream of images

I know how to use ffmpeg to covert image sequence to a video.
What I want to do is start converting images to video, before I have all the images ready, i.e. as soon as I start to output images, ffmpeg starts conversion, and stops when the images stop coming. Is there any way to achieve this?
Edit : I'm trying this in Android.
If you want to store video on sdcard, you should start with FFMpegFrameRecorder class from OpenCV for Android. You can google it easily. It will allow you to add single frames and create a video bit-by-bit.
If you need to keep your video in memory, you will have to write your own frame recorder, which is not that trivial, but doable and I can help you a bit.

Recording text/image overlay on Android

How can I put text or transparent image into a video? I can display text overlayed camera output but how can I record it? Using opencv is an alternative but I don't really want to use opencv manager(or 25+ mb binary).
Is there a way to record overlayed video with Android SDK or 3rd party library. What are my options?
Update: I'm not looking for a "record to disc then load recorded video and process every frame" solution. I'm trying to find a way to process every camera frames before recording. Something like opencv.
You can get help from here to get video byes array of each frame from camera and then save them using some third party encoder. Now you can create bitmap from byte array, and using bitmap you can write a overlay text on it. Example code here and here is the link for the third party encoder AndroidFFmpeg

Categories

Resources