Removing the background from a video takes a long time to finish
Ali-cryptoo opened this issue · comments
Hi, I hope you're doing well, I'm trying to remove the background from a video, right now I'm following those steps :
1 - Extract all frames from video using FFMPEG
2 - Remove the background from each frame using Huawei ML Image Segmentation and save the bitmap as file to use it later :
public void analyzer(List<File> files, MLCallBack mlCallBack) {
for (File file : files) {
Bitmap frame = ImageUtils.getBitmap(file);
MLFrame mlFrame = MLFrame.fromBitmap(frame);
SparseArray<MLImageSegmentation> task = this.analyzer.analyseFrame(mlFrame);
String noBgFramePath = FileHelper.createImageInNoBackgroundFramesFolder(counter);
ImageUtils.save(task.get(0).getForeground(), noBgFramePath, Bitmap.CompressFormat.PNG, 60, true);
mlCallBack.onMLProgress(counter);
BitmapUtil.recycle(frame);
FileUtils.delete(file);
counter++;
}
if (counter == files.size())
mlCallBack.onMLCompleted(true);
}
3 - Combine all frames (no background) into one video file.
THE ISSUE :
The step 2 (Removing background) takes a long time e.g. video with 26sec takes almost 5min to process, is there any better and faster way to do this, such as using LensEngine or something like that?