I want to use media recorder to record a video. Meanwhile, I need process the preview frame in real time.
I read many articles about this. It seems that while recording, no preview frame is possible.
Is this true? Does anyone know how to get the preview frame to show up while recording?
You may use onPreviewFrame callback function of PreviewCallback. Kindly refer android documentation for details.
Following SO question will also help you:
android-preview-processing-while-video-recording
Related
I am working on a project to read a video file from sdcard then process frames and re diplay as a video in real time. So far I didn't manage to come up with a solution for directly extract frames from the MediaPlayer like MediaPlayer.getCurrentFrame();. MediaMetadataRetriever.getFrameAtTime() is super slow, difficult to get a descent frame rate.
The only thing I have right now is using a TextureView surface with MediaPlayer. Here I start the MediaPlayer and in real time read the bitmap form TextureView asTextureView.getBitMap(), then process BitMap and display it on another ImageView. Here this gives me a a descent frame rate.
The problem here is TextureView has to be in the xml layout and should visible, Which I do not want.
Can some one please shed some light here? Is it possible to somehow hide the TextureView which is attaching to the MediaPlayer, without fake hiding like using RelativeLayouts :). iOS has a solution for this which is AVPLAyerItemVideoOutput, I need something like that with android.
Or any other work around to extract frames from video file?
Thank you
For video processing ...... you can use the FFMPEG Library for getting frames of videos but for that you have the knowledge of android native integration.
I hope this will help you.enter link description here
I'm building my own camera application and I'm looking for a way to take a picture while recording a video. (android 15+)
Is this possible in CWAC-camera or should I cut a frame out of the video.
Thanks
Is this possible in CWAC-camera
Not that I am aware of.
should I cut a frame out of the video
It is possible that a PreviewCallback is invoked while MediaRecorder is recording. I have not experimented with that. If it is, my guess is that will give you better results than will grabbing a frame.
I want to show filtered camera preview while recording a video using media recorder. To filter the preview i need frames normally which i can get that from onPreviewFrame() function but while recording video with media recorder, onPreviewFrame() function does not get called. So what i want to know , is there any other ways to get these frames for filtering and then show them after modification ? I checked some apps from Google Play for example, Videocam Illusion. Its showing preview with effects during recording videos. I want to do something like that but have no hint how to do so. So i will appreciate any help/hints/code/sample regarding the issue. Thanks.
I haven't done it myself, but searched for it not so long ago. There's an answer on StackOverflow to show modified buffer of PreviewFrame:
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/yF6CmrIJzuo
And here, a google groups link on the same topic.
How can I manipulate the camera preview?
Hope this helps, I'm planning on an application that modifies the preview frames, but is not going to record anything.
Best Regars.
Is it possible to record video with overlay view? While recording the video I have displayed one small image on the overlay view. What I want to do is I want those overlay image along with the video recorded. So when I will open that recorded video, I will be able to see that overlapped image that recorded with video also.
Friends, I need this solution ASAP. Please suggest proper solution :)
Unfortunately, there is no way in the current Android API to get between the camera input and the encoder. Any solution would either involve capturing frames from the video source, overlaying the additional image, and then including an encoder for the captured frames. Even in native code with NEON optimizations on a fast system, this is going to be a slow process. Alternatively, the whole stream could be post-processed in a similar fashion, but this would also require a decoder.
For future reference: This is possible using the CameraView library, at least in "snapshot video" mode.
I am building a camera app, where videos are continuously being captured and saved to the SD card. The videos are short (few minutes), and their length are preset with setMaxDuration().
The whole process works fine, while the main activity is in the foreground. But, when I go to another activity (e.g. settings), the video recording works in the background only until max duration is reached. The file is saved, but a new sequence can not be started
because prepare() fails, apparently because setPreviewDisplay() doesn't like not having a proper surface to attach to.
I tried to use a dummy Surface, a dummy SurfaceHolder, lockCanvas(), and various other tricks, but nothing works. Is there a way to initialize MediaRecorder without a valid surface?
Unfortunately it is still a requirement for you to preview onto a valid surface in order to record video (Android SDK 1.6 thru 2.2). There is an enhancement request logged to remove this restriction http://code.google.com/p/android/issues/detail?id=9570
You just have to create a surface with MediaCodec by adding the following line:
Surface mySurface = MediaCodec.createPersistentInputSurface();
mMediaRecorder.setPreviewDisplay(mySurface);
...
mMediaRecorder.prepare();
I think the IP Webcam app can do this, though I don't know how. Maybe it only works on >=2.3. I'm not sure what version I saw it running on. I asked a question to find how how it's working.
Are you implementing Surface callbacks?
Why do you need to initialize MediaRecorder without a valid surface?
Are you supposed to be recording even when you leave the main activity? or does recording stop before the other acitivty is spawned?