Skip to content
프로젝트

a914-gowtham/android-video-trimmer

GitHub에서 보기

소개

Helps to trim local videos with compress option on Android applications using Exoplayer and media3 libraries

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Starting from 1.8.0 this library is using media3 for media transcoding. Previously it was using ffmpeg which is deprecated now.

Android-video-trimmer

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

How to use

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
// replace x.y.z with latest available jitpack version
dependencies {
   implementation 'com.github.a914-gowtham:android-video-trimmer:x.y.z'
}
  • Add to project's root build.gradle file:
allprojects {
	repositories {
		maven { url 'https://jitpack.io' }
	}
}
  1. Create a global variable for ActivityResultLauncher
    //Java
    ActivityResultLauncher<Intent> startForResult = registerForActivityResult(
            new ActivityResultContracts.StartActivityForResult(),
            result -> {
                if (result.getResultCode() == Activity.RESULT_OK &&
                        result.getData() != null) {
                    Uri uri = Uri.parse(TrimVideo.getTrimmedVideoPath(result.getData()));
                    Log.d(TAG, "Trimmed path:: " + uri);
                   
                } else
                    LogMessage.v("videoTrimResultLauncher data is null");
            });
    //Kotlin
    val startForResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { 
    result: ActivityResult ->
        if (result.resultCode == Activity.RESULT_OK &&
                        result.getData() != null) {
                Uri uri = Uri.parse(TrimVideo.getTrimmedVideoPath(result.getData()))
                Log.d(TAG, "Trimmed path:: " + uri)
         }else 
          	LogMessage.v("videoTrimResultLauncher data is null");
    }   
  1. Add the code for opening Trim Activity.
TrimVideo.activity(String.valueOf(videoUri))
          .setHideSeekBar(true)
          .disableCompression()   // to disable compression ui. enabled by default
          .start(this,startForResult);

Custom TrimTypes

TrimType Default:

TrimVideo.activity(videoUri)
          .start(this,startForResult);

TrimType Fixed Duration:

TrimVideo.activity(videoUri)
          .setTrimType(TrimType.FIXED_DURATION)
          .setFixedDuration(30) //seconds
          .start(this,startForResult);

TrimType Minimum Duration:

TrimVideo.activity(videoUri)
          .setTrimType(TrimType.MIN_DURATION)
          .setMinDuration(30) //seconds
          .start(this,startForResult);

TrimType Min-Max Duration:

TrimVideo.activity(videoUri)
          .setTrimType(TrimType.MIN_MAX_DURATION)
          .setMinToMax(10, 30)  //seconds
          .start(this,startForResult);

Proguard Rules

-dontwarn com.gowtham.library**
-keep class com.gowtham.library** { *; }
-keep interface com.gowtham.library** { *; }

Development roadmap:

  1. Currently, compression only reduces the bitRate to reduce the file size. converting video to the selected resolution is in under development - DONE
  2. Showing file size estimation in toolbar subtitle - to be worked

Compatibility

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

License

This library is licensed under the MIT License.

Support

Show your support by giving a star to this repository.

Collaboration

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

관련 프로젝트 살펴보기

불러오는 중…