I am working on an app that needs to capture square videos just like Instagram
. I used many libraries for the purpose but none helped to capture the video itself in square size. I can make the preview look like square but not the recorded video. For that I have to use FFMPEG
library for cropping the video after it has been captured. But this process takes too long for 1 minute videos even with 480p video
capture quality. Someone please guide me to achieve this task.
Libraries that I have used are: https://github.com/natario1/CameraView for cameraView and http://writingminds.github.io/ffmpeg-android-java/ for using ffmpeg.
Commands that I have tried for ffmpeg cropping operation are:
command = new String[]{"-y",
"-f",
"concat",
"-safe",
"0",
"-i",
"" + sdCardPathFile,
"-c:v",
"libx264",
"-vf",
"crop=" + getVideoResolution(),
"-preset",
"ultrafast",
"-qscale",
"0",
"-crf",
"28",
"-c:a",
"copy",
"-flags",
"+global_header",
"" + joinedVideoFile.getAbsolutePath()
};
String[] joinCommand = new String[]{
"-y",
"-f",
"concat",
"-safe",
"0",
"-i",
"" + sdCardPathFile,
"-filter:v",
"crop=480:480",
"-preset",
"superfast",
"-c:a",
"copy",
"" + joinedVideoFile.getAbsolutePath()
};