Skip to content

bhavin-qfonapp/Android-video-trimmer-bhavin

Repository files navigation

MIT licensed

Android-video-trimmer

Helps to trim local videos with many customizations on Android applications using exoplayer2 and FFmpeg.

Usage

For a working implementation, please have a look at the Sample Project

  1. Include the library as local library project.
  • Add the dependency to your app build.gradle file
dependencies {
   implementation 'com.github.a914-gowtham:Android-video-trimmer:1.0.9'
}
  • Add to project's root build.gradle file:
allprojects {
	repositories {
		maven { url 'https://jitpack.io' }
	}
}
  1. Add the code for opening Trim Activity.
Intent intent=new Intent(this,ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI,String.valueOf(videoUri));
intent.putExtra(TrimmerConstants.DESTINATION,"/storage/emulated/0/DCIM/MYFOLDER"); //optional default output path /storage/emulated/0/DOWNLOADS
startActivityForResult(intent,TrimmerConstants.REQ_CODE_VIDEO_TRIMMER);
  1. Override onActivityResult method in your activity to get trim result
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == TrimmerConstants.REQ_CODE_VIDEO_TRIMMER && data != null) {
            Uri uri = Uri.parse(data.getStringExtra(TrimmerConstants.TRIMMED_VIDEO_PATH));
            Log.d(TAG,"Trimmed path:: "+uri);
        }
}

Customization

  • Hide Player seekbar
intent.putExtra(TrimmerConstants.HIDE_PLAYER_SEEKBAR,true);

Custom TrimTypes

  • TrimType Default
Intent intent=new Intent(this,ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI,String.valueOf(videoUri));
intent.putExtra(TrimmerConstants.TRIM_TYPE,0); //optional: it will take by default
startActivityForResult(intent,TrimmerConstants.REQ_CODE_VIDEO_TRIMMER);
  • TrimType FixedGap(fixed duration trim)
Intent intent=new Intent(this,ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI,String.valueOf(videoUri));
intent.putExtra(TrimmerConstants.TRIM_TYPE,1);
intent.putExtra(TrimmerConstants.FIXED_GAP_DURATION,30L); //in secs
startActivityForResult(intent,TrimmerConstants.REQ_CODE_VIDEO_TRIMMER);
  • TrimType MinDuration
Intent intent=new Intent(this,ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI,String.valueOf(videoUri));
intent.putExtra(TrimmerConstants.TRIM_TYPE,2);
intent.putExtra(TrimmerConstants.MIN_GAP_DURATION,30L); //in secs
startActivityForResult(intent,TrimmerConstants.REQ_CODE_VIDEO_TRIMMER);
  • TrimType Min-Max Duration
Intent intent=new Intent(this,ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI,String.valueOf(videoUri));
intent.putExtra(TrimmerConstants.TRIM_TYPE,3);
intent.putExtra(TrimmerConstants.MIN_FROM_DURATION,30L); //in secs
intent.putExtra(TrimmerConstants.MAX_TO_DURATION,30L); //in secs
startActivityForResult(intent,TrimmerConstants.REQ_CODE_VIDEO_TRIMMER);

Compatibility

  • Library - Android Kitkat 4.4+ (API 19)
  • Sample - Android Kitkat 4.4+ (API 19)

Collaboration

There are many ways of improving and adding more features, so feel free to collaborate with ideas, issues and/or pull requests.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages