All Projects → Ahmedbadereldin → Video-Trimmer-Android

Ahmedbadereldin / Video-Trimmer-Android

Licence: other
Trim the video by adjusting starting point and ending point in Android

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to Video-Trimmer-Android

VIDEOconvertor
A stable and Fast telegram video convertor bot which can encode into different libs and resolution, compress videos, convert video into audio and other video formats, rename with thumbnail support, generate screenshot and trim videos.
Stars: ✭ 180 (+267.35%)
Mutual labels:  video-trimmer
Open-PDF-File-Android-Example
An example project to demonstrate how to open a PDF file in Android programmatically
Stars: ✭ 57 (+16.33%)
Mutual labels:  android-example
Tinypinyin
适用于Java和Android的快速、低内存占用的汉字转拼音库。
Stars: ✭ 3,348 (+6732.65%)
Mutual labels:  java-android
HideDroid
HideDroid is an Android app that allows the per-app anonymization of collected personal data according to a privacy level chosen by the user.
Stars: ✭ 85 (+73.47%)
Mutual labels:  java-android
FFmpegPlayer
Simple FFmpeg video player
Stars: ✭ 72 (+46.94%)
Mutual labels:  video-cutter

Video-Trimmer-Android

Trim the video by adjusting starting point and ending point in Android.

license : MIT license : MIT

Screen Shots

  

Core Features

  • Video can be trimmed/shortened and played on the same screen
  • Video can be trimmed by selecting the starting point and ending point, and it will display the video size and video duration based on the selected position
  • Seekbar moves as per selected video for trimming
  • You can specify the length of the video before cut.

How it works

  • User can record video from camera or select video from gallery
  • Set the selected video in the trimming screen
  • Trim the video by dragging starting point and end point
  • View trimmed video on the trimming screen
  • Save video, it will show image from video in next screen.
  • You can use the video after that as you like, like upload to server.

Purpose of this code

  • Whenever it is required to crop thr video, this code can help you
  • Whenever you are having a limiation of video recording such as allow users to record video for 1 min, this code can help you

Gradle

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
dependencies {
    ...
	implementation 'com.github.Ahmedbadereldin:Video-Trimmer-Android:1.0.3'
}

Setup your code

  • In order to use the library without problems, add these codes.
  • AndroidManifest.xml
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />

    <application
       ...
        android:requestLegacyExternalStorage="true"
       ...
    >

   ...

   <activity
           android:name=".YourActivity"
           android:configChanges="orientation|screenSize"
           android:launchMode="singleTask"
           android:screenOrientation="portrait"
           android:windowSoftInputMode="adjustPan">
           <intent-filter android:label="@string/app_name">
               <action android:name="android.intent.action.SEND" />
               <category android:name="android.intent.category.DEFAULT" />
               <!-- <data android:mimeType="*/*" /> -->
               <data android:mimeType="video/*" />
               <data android:mimeType="image/*" />
               <data android:mimeType="text/*" />
           </intent-filter>
       </activity>

       <activity
           android:name=".VideoTrimmerActivity"
           android:configChanges="orientation|screenSize"
           android:launchMode="singleTask"
           android:screenOrientation="portrait"
           android:theme="@style/AppTheme.SlidrActivityTheme"
           android:windowSoftInputMode="adjustPan" />
   ...

  • In YourActivity
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);

      //  Open VideoTrimmerActivity
      if (requestCode == REQUEST_TAKE_GALLERY_VIDEO) { //recive 
          if (resultCode == RESULT_OK) {
              Uri selectedImageUri = data.getData();
              // MEDIA GALLERY
              String path = getPath(selectedImageUri);
              Uri uriFile = Uri.fromFile(new File(path));
              String fileExtension = MimeTypeMap.getFileExtensionFromUrl(uriFile.toString());
              Log.d(TAG, "onActivityResult: " + fileExtension);

              if (fileExtension.equalsIgnoreCase("MP4")) {
                  File file = new File(path);
                  if (file.exists()) {
                      startActivityForResult(new Intent(YourActivity.this, VideoTrimmerActivity.class).putExtra("EXTRA_PATH", path), VIDEO_TRIM);
                      overridePendingTransition(0, 0);
                  } else {
                      Toast.makeText(NewPostActivity.this, "Please select proper video", Toast.LENGTH_LONG).show();
                  }
              } else {
                  Toast.makeText(this, getString(R.string.file_format) + " ," + fileExtension, Toast.LENGTH_SHORT).show();
              }
          }
      }

      //  ForResult from VideoTrimmerActivity
      if (requestCode == VIDEO_TRIM) {
          if (resultCode == RESULT_OK) {
              if (data != null) {
                  String videoPath = data.getExtras().getString("INTENT_VIDEO_FILE");
                  File file = new File(videoPath);
                  Log.d(TAG, "onActivityResult: " + file.length());

                  pathPostImg = videoPath;

                  Glide.with(this)
                          .load(pathPostImg)
                          .into(postImg);
                  postImgLY.setVisibility(View.VISIBLE);

              }
          }
      }

  }

Proguard

  ### RxJava, RxAndroid for media-picker-android library
  -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
      long producerIndex;
      long consumerIndex;
  }
  
  ### mp4parser 
  -keep class * implements com.coremedia.iso.boxes.Box {* ; }
  -dontwarn com.coremedia.iso.boxes.*
  -dontwarn com.googlecode.mp4parser.authoring.tracks.mjpeg.**
  -dontwarn com.googlecode.mp4parser.authoring.tracks.ttml.**

Requirements

  • Android 4.1+

Contact me via e-mail

For any inquiries or clarifications, you can contact me via e-mail. Just send an email to [email protected].

Contact me via social media

Facebook | Twitter | Linkedin

Libraries

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].