public static EncoderDebugger debug(ISharedPreferences prefs, int width, int height)
        {
            EncoderDebugger debugger = new EncoderDebugger(prefs, width, height);

            debugger.debug();
            return(debugger);
        }
Example #2
0
 private MP4Config testMediaCodecAPI()
 {
     createCamera();
     updateCamera();
     try {
         if (mQuality.resX >= 640)
         {
             // Using the MediaCodec API with the buffer method for high resolutions is too slow
             mMode = MODE_MEDIARECORDER_API;
         }
         EncoderDebugger debugger = EncoderDebugger.debug(mSettings, mQuality.resX, mQuality.resY);
         return(new MP4Config(debugger.getB64SPS(), debugger.getB64PPS()));
     } catch (Java.Lang.Exception e) {
         // Fallback on the old streaming method using the MediaRecorder API
         Log.e(TAG, "Resolution not supported with the MediaCodec API, we fallback on the old streamign method.");
         mMode = MODE_MEDIARECORDER_API;
         return(testH264());
     }
 }
Example #3
0
    /**
     * Video encoding is done by a MediaCodec.
     */

    protected void encodeWithMediaCodecMethod1() {

		    Log.Debug(TAG,"Video encoded using the MediaCodec API with a buffer");

		    // Updates the parameters of the camera if needed
		    createCamera();
		    updateCamera();

		    // Estimates the frame rate of the camera
		    measureFramerate();

		    // Starts the preview if needed
		    if (!mPreviewStarted) {
			    try {
				    mCamera.startPreview();
				    mPreviewStarted = true;
			    } catch (RuntimeException e) {
				    destroyCamera();
				    throw e;
			    }
		    }

		    EncoderDebugger debugger = EncoderDebugger.debug(mSettings, mQuality.resX, mQuality.resY);
		    const NV21Convertor convertor = debugger.getNV21Convertor();

		    mMediaCodec = MediaCodec.CreateByCodecName(debugger.getEncoderName());
		    MediaFormat mediaFormat = MediaFormat.CreateVideoFormat("video/avc", mQuality.resX, mQuality.resY);
		    mediaFormat.SetInteger(MediaFormat.KeyBitRate, mQuality.bitrate);
		    mediaFormat.SetInteger(MediaFormat.KeyFrameRate, mQuality.framerate);	
		    mediaFormat.SetInteger(MediaFormat.KeyColorFormat,debugger.getEncoderColorFormat());
		    mediaFormat.SetInteger(MediaFormat.KeyIFrameInterval, 1);
		    mMediaCodec.Configure(mediaFormat, null, null, MediaCodecConfigFlags.Encode);
		    mMediaCodec.Start();

		    Camera.PreviewCallback callback = new Camera.PreviewCallback() Action InnerMethod = () =>{
			    long now = System.nanoTime()/1000, oldnow = now, i=0;
			    ByteBuffer[] inputBuffers = mMediaCodec.getInputBuffers();
			    @Override