/CameraRecorder-android

Video Recording with Camera2 and apply video filter.

Primary LanguageJavaMIT LicenseMIT

Platform API


Video Recording with Camera2 and apply video filter.

Gradle

  dependencies {
    // jCenter
    implementation 'com.daasuu:CameraRecorder-android:0.1.0'
  }

Usage

SetUp on onResume method.

  sampleGLView = new GLSurfaceView(getApplicationContext());
  FrameLayout frameLayout = findViewById(R.id.wrap_view);
  frameLayout.addView(sampleGLView);
  
  cameraRecorder = new CameraRecorderBuilder(activity, sampleGLView)
    .lensFacing(LensFacing.BACK)
    .build();

Release on onPause method.

  sampleGLView.onPause();      

  cameraRecorder.stop();
  cameraRecorder.release();
  cameraRecorder = null;

  ((FrameLayout) findViewById(R.id.wrap_view)).removeView(sampleGLView);
  sampleGLView = null;

Start and Stop Video record.

  // record start.
  cameraRecorder.start(filepath);
  // record stop.
  cameraRecorder.stop();

This filter is OpenGL Shaders to apply effects on camera preview. Custom filters can be created by inheriting GlFilter.java. , default GlFilter(No filter). Filters is here.

  cameraRecorder.setFilter(GlFilter);

Other methods.

  // if flash enable, turn on or off camera flash. 
  cameraRecorder.switchFlashMode();
  // autofocus change.
  cameraRecorder.changeAutoFocus();
  // set focus point at manual.
  cameraRecorder.changeManualFocusPoint(float eventX, float eventY, int viewWidth, int viewHeight); 
  // scale camera preview
  cameraRecorder.setGestureScale(float scale);

Builder Method

method description
cameraRecordListener onGetFlashSupport, onRecordComplete, onError, and onCameraThreadFinish. Detail is here.
filter This filter is OpenGL Shaders to apply effects on camera preview. Custom filters can be created by inheriting GlFilter.java. , default GlFilter(No filter). Filters is here.
videoSize Resolution of the movie, default width=720, height=1280.
cameraSize Preview size.
lensFacing Select back or front camera. Default LensFacing.FRONT.
flipHorizontal Flip Horizontal on recorded video. Default flipHorizontal = false.
flipVertical Flip Vertical on recorded video. Default flipVertical = false.
mute Mute audio track on recorded video. Default mute = false.
recordNoFilter No Filter on recorded video although preview apply a filter. Default recordNoFilter = false.

References And Special Thanks to

License

MIT License