Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing the background from a video takes a long time to finish #79

Open
Ali-cryptoo opened this issue Jun 20, 2021 · 0 comments
Open

Comments

@Ali-cryptoo
Copy link

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?

@Ali-cryptoo Ali-cryptoo changed the title Removing the background from a video Removing the background from a video takes a long time to finish Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant