Giter Site home page Giter Site logo

Comments (16)

celikmustafa89 avatar celikmustafa89 commented on August 30, 2024 6

The following command generates a video that scale-up the video for the background image. It may help in some cases. At least work for me. I spent some time writing this command, just want to share it to save your time if you need it.

ffmpeg -i test_fightclub.mp4 -i fight_matte_image.mov -i green.png -filter_complex '[1][0]scale2ref[mask][main];[main][mask]alphamerge[vid];[vid][2:v]scale2ref[fg][bg];[bg][fg]overlay[out]' -map [out] fight_image_complete_scale2ref.mp4

my output was like this:
image

now I can generate following output with the code:
image

from backgroundremover.

j2l avatar j2l commented on August 30, 2024 2

Hey,it also works with a PNG image: ffmpeg -i stress.mp4 -i matte.mp4 -i vert.png -filter_complex '[1][0]scale2ref[mask][main];[main][mask]alphamerge[vid];[2:v][vid]overlay[out]' -map [out] complete2.mp4
("vert" is green in French)

from backgroundremover.

nadermx avatar nadermx commented on August 30, 2024 2

I had this open on superuser as I had gotten stuck. I'll fix the '-tov' ffmpeg command and close this issue.

from backgroundremover.

celikmustafa89 avatar celikmustafa89 commented on August 30, 2024 1

hey @j2l,

I have used following command to combine the mate, video and the background video.

ffmpeg -i video.mp4 -i matte.mp4 -i background.mp4 -filter_complex '[1][0]scale2ref[mask][main];[main][mask]alphamerge[vid];[2:v][vid]overlay[out]' -map [out] complete.mp4

It works but has some rescaling issues. But the main point the code should give a proper output. it is working for image but now working for the video. any idea @nadermx ?

by the way here is the output:
image

from backgroundremover.

celikmustafa89 avatar celikmustafa89 commented on August 30, 2024

same issue:

backgroundremover -i 15_terminator.mp4 -tov green.mp4 -o g_out.mov usage: backgroundremover [-h] [-m {u2net,u2net_human_seg,u2netp}] [-a [ALPHA_MATTING]] [-af ALPHA_MATTING_FOREGROUND_THRESHOLD] [-ab ALPHA_MATTING_BACKGROUND_THRESHOLD] [-ae ALPHA_MATTING_ERODE_SIZE] [-az ALPHA_MATTING_BASE_SIZE] [-wn WORKERNODES] [-gb GPUBATCHSIZE] [-fr FRAMERATE] [-fl FRAMELIMIT] [-mk [MATTEKEY]] [-tv [TRANSPARENTVIDEO]] [-tov [TRANSPARENTVIDEOOVERVIDEO]] [-toi [TRANSPARENTVIDEOOVERIMAGE]] [-tg [TRANSPARENTGIF]] [-tgwb [TRANSPARENTGIFWITHBACKGROUND]] [-i [INPUT]] [-bi [BACKGROUNDIMAGE]] [-bv [BACKGROUNDVIDEO]] [-o [OUTPUT]] backgroundremover: error: argument -tov/--transparentvideoovervideo: invalid <lambda> value: 'green.mp4'

from backgroundremover.

j2l avatar j2l commented on August 30, 2024

So far, I didn't find a way to make it work and python code looks the same as -tv so I don't see why the file is not loaded as overlay.
Let me know @celikmustafa89 if you find some way 😉

from backgroundremover.

celikmustafa89 avatar celikmustafa89 commented on August 30, 2024

So far, I didn't find a way to make it work and python code looks the same as -tv so I don't see why the file is not loaded as overlay.
Let me know @celikmustafa89 if you find some way 😉

Hi,

I found the way of running it.

backgroundremover -i terminator.mp4 -toi -bv green.mp4 -o out_vid.mov

however the output is not good. I was expecting the original video with the green background but it is a grayscale output. :S :S

image

from backgroundremover.

celikmustafa89 avatar celikmustafa89 commented on August 30, 2024

may be it is because of the version of FFmpeg ?? I do not know.

from backgroundremover.

j2l avatar j2l commented on August 30, 2024

I had the same, its the alpha matte (mask for the alpha channel).
For an image with the same size as the video it shrinks the video and only keep the matte:
image

from backgroundremover.

celikmustafa89 avatar celikmustafa89 commented on August 30, 2024

I had the same, its the alpha matte (mask for the alpha channel).
For an image with the same size as the video it shrinks the video and only keep the matte:
image

how should we run the code to get a proper output? any idea?

from backgroundremover.

j2l avatar j2l commented on August 30, 2024

I had the same, its the alpha matte (mask for the alpha channel).
For an image with the same size as the video it shrinks the video and only keep the matte:
image

how should we run the code to get a proper output? any idea?

No idea 😕

from backgroundremover.

j2l avatar j2l commented on August 30, 2024

Your exact command worked for me!

vlcsnap-2022-03-29-15h37m59s453

from backgroundremover.

celikmustafa89 avatar celikmustafa89 commented on August 30, 2024

actually i have some rescale problem with original and background video. by the way my green background is not an image. it is a green backgorund video which shows only green. could you do the merge of original video, matte and a green.png (image)? please share the code?

from backgroundremover.

j2l avatar j2l commented on August 30, 2024

I also used a green background video and applied your code with my videos: ffmpeg -i stress.mp4 -i matte.mp4 -i vert.mp4 -filter_complex '[1][0]scale2ref[mask][main];[main][mask]alphamerge[vid];[2:v][vid]overlay[out]' -map [out] complete.mp4

It doesn't fix the backgroundremove issue so I keep the issue open for @nadermx or someone who finds the bug. It's way above my skills 😄

If I can help you more, let me know.

from backgroundremover.

j2l avatar j2l commented on August 30, 2024

Cool!
Thank you!

from backgroundremover.

j2l avatar j2l commented on August 30, 2024

Thank you!

from backgroundremover.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.