4

I want to extract some portion of video when user is playing that video via my application. While playing a video user can give start and end duration to cut the video. so are there any way to cut the video based on duration and save to sd card ?

Ravi Bhojani
  • 1,032
  • 1
  • 13
  • 24

5 Answers5

0

You may try to compile and integrate ffmpeg into your project. I used ffmpeg to cut video and audio, is very fast, no recording needed. I've NO experience on doing it on android, but It should work. Here you have the official wiki page about ffmpeg on android:

https://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20compile%20FFmpeg%20for%20Android

OriolJ
  • 2,762
  • 1
  • 28
  • 22
0

I think that can be done using MP4Parser its purely written in java and can be used with android and also here is an example of doing video shorten in java By Sebastian-annies

Vivek Bajpai
  • 1,617
  • 1
  • 19
  • 35
  • Heyy Vivek can you please change the second [link](https://mp4parser.googlecode.com/svn/trunk/examples/src/main/java/com/googlecode/mp4parser/ShortenExample.java) to [this](https://github.com/sannies/mp4parser/blob/master/examples/src/main/java/com/googlecode/mp4parser/ShortenExample.java) because it has been chaged – MashukKhan Oct 10 '17 at 06:53
0

Android uses Mp4Parser/isoParser for Trimming Videos here is the example to trim the video https://android.googlesource.com/platform/packages/apps/Gallery2/+/android-4.4.2_r2/src/com/android/gallery3d/app/TrimVideo.java and as mentioned he usees isoParser which u can get it from "git clone https://android.googlesource.com/platform/external/mp4parser"

surya
  • 607
  • 5
  • 18
0

Use this Android-video_trimmer library.it supports Android 10 as well

gowtham6672
  • 999
  • 1
  • 10
  • 22
-7

@Ravi --- video can be played in videoview or surfaceview android inbuilt class. In surfaceview you can start a thread to record you video from the position you select to position you want using MediaRecorder

    MediaRecorder recorder = new MediaRecorder();
    recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
        recorder.setOutputFile("/sdcard/recordvideooutput.3gpp");
        recorder.setPreviewDisplay(mHolder.getSurface());
    recorder.prepare();

YOUR mholder is the SurfaceHolder holder for attaching surface view

calling these two method will start and stop recording and the file will be written to /sdcard/recordvideooutput.3gpp

recorder.start();
recorder.stop();

use the developer guide http://developer.android.com/reference/android/media/MediaRecorder.html

Vipin Sahu
  • 1,441
  • 1
  • 18
  • 29