Pause the software recorder. Camera.apk from samsung galaxy has `this.mMediaRecorder.pause ();` does not work in my code

Now I have created a library to combine 2 videos using mp4parser library. And with this, I can pause and resume video recording (after he records the second video, he adds it to the first). Now my boss told me to make a wrapper and use it for phones that do not have hardware support to pause the video. For phones that have this (Samsung Galaxy S2 and Samsung Galaxy S1 can pause the video using the camera app), I need to do this without libraries, so it will be fast. How can I implement this native if, as you can see in the status diagram of the media recorder, http://developer.android.com/reference/android/media/MediaRecorder.html , there is no pause state?

I decompiled the Samsung Galaxe Ace Camera.apk application, and the code in CamcorderEngine.class has a method similar to this:

public void doPauseVideoRecordingSync() { Log.v("CamcorderEngine", "doPauseVideoRecordingSync"); if (this.mMediaRecorder == null) { Log.e("CamcorderEngine", "MediaRecorder is not initialized."); return; } if (!this.mMediaRecorderRecording) { Log.e("CamcorderEngine", "Recording is not started yet."); return; } try { this.mMediaRecorder.pause(); enableAlertSound(); return; } catch (RuntimeException localRuntimeException) { Log.e("CamcorderEngine", "Could not pause media recorder. ", localRuntimeException); enableAlertSound(); } 

}

If I try this.mMediaRecorder.pause(); in my code, this will not work as possible, they use the same import (android.media.MediaRecorder). Did they rewrite all the code at the system level?

Is it possible to take the input stream of the second video (during recording) and directly add this data to my first video? for my concatenate method I use 2 parameters (2 videos, which are both FileInputStream), is it possible to take an InputStream from a recording function and pass it as a second parameter?

+4
source share
1 answer

If I try this.mMediaRecorder.pause ();

The MediaRecorder class MediaRecorder not have a pause() function, so it’s obvious that this MediaRecorder class has its own class. This is not unusual, since the only thing OEMs need is to pass “compatibility tests for Android” on the device; There are no restrictions on adding functionality.

Is it possible to take the input stream of the second video (while recording it) and directly add this data to my first video?

I’m not sure that you can do this, because the video stream is encoded data (codec header, key frames, etc.), and just combining the two streams into 1 file will not lead to the creation of a valid video file in my opinion.

Basically what you can do:

  • receive raw images of data from the camera preview surface (see Camera.setPreviewCallback ())
  • use android.media.MediaCodec to encode the video.
  • and then use OutputFilStream to write to the file.

This will give you the flexibility you want, since in this case you decide in your application which frames fall into the encoder and which do not. However, this may be overkill for your specific project, and some performance issues may increase.

PS. By the way, try taking a look at MediaMuxer - perhaps this will help you too. developer.android.com/reference/android/media/MediaMuxer.html

+2
source

All Articles