Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement Video trimming on android like instagram or Whatsapp?

Tags:

android

video

I need to trim the video in my android apps like Instagram or Whatsapp. I searched a lot but did not find much stuff. Is there any library for this like aviary SDK for video trimming? At the time of trimming in Instagram or Whatsapp video is split or cut into multiple frames like given screenshot and after that user select specific frames from it for trimming video between these frames or specific time. enter image description hereenter image description here

like image 542
Maroti Avatar asked May 20 '15 10:05

Maroti


2 Answers

FFmpeg can be used to extract frames from video and cut video.

For integrating FFmpeg in android we can use precompiled libraries like ffmpeg-android.

For extracting image frames from video use below command-

String[] complexCommand = {"-y", "-i", inputFileAbsolutePath, "-an", "-r", "1/2", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, outputFileAbsolutePath()};

For cutting video use below command-

String[] complexCommand = {"-ss", "" + startMs / 1000, "-y", "-i", inputFileAbsolutePath, "-t", "" + (endMs - startMs) / 1000, "-s", "320x240", "-r", "15", "-vcodec", "mpeg4", "-b:v", "2097152", "-b:a", "48000", "-ac", "2", "-ar", "22050", outputFileAbsolutePath};

You can use RangeSeekBar to allow user to select the time range for cutting video from original video. For complete tutorial check out below post on my blog-

https://androidlearnersite.wordpress.com/2017/03/17/ffmpeg-video-editor/

like image 153
Android Developer Avatar answered Nov 15 '22 22:11

Android Developer


Use this Library for video trimming like whats app and insta. see this library

like image 32
Milan Pansuriya Avatar answered Nov 15 '22 22:11

Milan Pansuriya