how to create video using mediaCodec? - android

Is it possible to create video of series of Images present on SdCard using MediaCodec? if yes, can anyone share me the link?
I want to import images from sdCard and create video from those images, any suggestions???
I want to do this programmatically. I've tried using jcodec library but the process is very slow and I want to fasten up a little bit more.
Is there any chances that MediaCodec can do that in my ADT and in much faster way.
Importing images from SdCard --> making a good quality .mp4 video (faster than jcodec way).

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.

Related

Set cover image while record audio in android

Hello I am recording audio using MediaRecorder and save it in MP4 format. and upload to the server. as well record video as MP4 using camera and upload to server.
So while I am receive my uploaded item from server as uploaded url list. and I am playing all it in VideoView. video and audio play good. now here is the thing while I am playing video it's display video frame on video view but while playing audio it's black. basically audio and video file extension are MP4 so I can't make different while adding it in to VideoView other wise I'll add imageview and display some default image and hide VideoView.
so is there any way to record audio with cover image so while I am playing it in Video view so it display that cover image...
I know that using ffmpeg we can do this but I got lots of error while compiling it in my windows pc. so is there any way to add cover image while record audio with pure android api? sorry for bad english.
I google everything but I can't find any solution for convert audio file to video file with using image. So I have to go with FFMPEG.
So I add WritingMinds java FFMPEG in my project using gradle dependency. Then convert MP4 audio with cover image into the MP4 video.
There are some limitation in this precompile library. like it not work in android 24 and some commands like -speed, cpu-used, -deadline which are most important for all the operation(But still we can perform other operation). there are some disadvantage also like slow speed, and some features which required for specific operation are not include in the compile library. (So I gave advice to compile your own ffmpeg library for android project in linux or mac pc(windowns have lots of issues)).
I hope this will help someone who's this type of scenario :)

Export video from android application to SD card

I am using below demo for creating slow and fast motion video in android application.
https://github.com/google/grafika
I am able to play slow and fast motion video in application but now i want to export this video to SD card.
I use TextureView to show video in app.
I use this java file to control speed of video.
https://github.com/google/grafika/blob/master/src/com/android/grafika/SpeedControlCallback.java
How can i do this?
any help will be appreciated.
Hi you have to use a MediaMuxer, call AddTrack for the video track and write the data to this track to the muxer after encoding each frame. You can see some examples in grafika page, one of them could be this: https://github.com/google/grafika/blob/master/src/com/android/grafika/ContinuousCaptureActivity.java (here you canhow to do both displaying on screen and recording on SD)
and another one: https://github.com/google/grafika/blob/master/src/com/android/grafika/CameraCaptureActivity.java
Also you can find more examples here:
http://www.bigflake.com/mediacodec/
Thanks

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).

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.

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.

Categories

Resources