• Stars
    star
    251
  • Rank 156,722 (Top 4 %)
  • Language
    Java
  • License
    MIT License
  • Created about 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Video Recording with Camera2 and apply video filter.

Platform API


Video Recording with Camera2 and apply video filter.

Gradle

Step 1. Add the JitPack repository to your build file

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
	 implementation 'com.github.MasayukiSuda:CameraRecorder-android:v0.1.5'
}

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