bhuvnesh123 / FFmpeg-Video-Editor-Android

Sample android project using ffmpeg for cutting and compressing video,reversing video,extracting image frames from video,extracting audio from video,add fade in fade out effect,create fast and slow motion video
540 stars 165 forks source link

Video Cutting Procces #4

Closed eraldhaka closed 7 years ago

eraldhaka commented 7 years ago

I have a 10 seconds video, I want to cut from second 5 to second 8, after cutting the video is saved from second 5 to second 10.. can you please take a look to this problem?

bhuvnesh123 commented 7 years ago

-ss seeks to position(time from where we want to start cutting video) -t limit the duration of data read from the input file(duration from cutting start position time upto which we want to cut video)

So if you want to cut video from 5 to 8 seconds ,value of -ss should be 5 and value of -t should be 3. Are you using that?

eraldhaka commented 7 years ago

I am using this code: String[] complexCommand = {"-i", yourRealPath, "-ss", "" + startMs / 1000,"-acodec", "copy","-vcodec","copy", "-t", "" + endMs / 1000, dest.getAbsolutePath()};

Where "yourRealPath" is original path (in my case 10 sec video) startMs = 5000 (5000/1000= 5sek) endMs = 8000 (8000/1000= 8sek) "-acodec", "copy","-vcodec","copy" is the code that you said for copy dest.getAbsolutePath() is new path that should be 3sec

Can you please tell me where is my mistake in this code? If there is can you please write an simple code example? Thank you

bhuvnesh123 commented 7 years ago

As you can see in my project and tutorial, -t should be (endMs - startMs) . So,it should be- String[] complexCommand = {"-i", yourRealPath, "-ss", "" + startMs / 1000,"-acodec", "copy","-vcodec","copy", "-t", "" + (endMs - startMs)/ 1000, dest.getAbsolutePath()};

eraldhaka commented 7 years ago

Thank you for your explanation and your patience.