nadermx / backgroundremover

Background Remover lets you Remove Background from images and video using AI with a simple command line interface that is free and open source.
https://www.backgroundremoverai.com
MIT License
6.43k stars 534 forks source link

Conversion stuck at 99% #117

Open 1ncoQAQ opened 6 months ago

1ncoQAQ commented 6 months ago

Hello, Johnathan. Thank you very much for sharing this amazing project! I'm running into issue when converting the video

Input #0, rawvideo, from 'fd:':
  Duration: N/A, start: 0.000000, bitrate: 43622 kb/s
  Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 568x320, 43622 kb/s, 30 tbr, 30 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Output #0, mp4, to 'C:\Users\11446\AppData\Local\Temp\tmparc941ei\matte.mp4':
  Metadata:
    encoder         : Lavf60.18.100
  Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p(tv, progressive), 568x320, q=2-31, 2000 kb/s, 30 fps, 15360 tbn
    Metadata:
      encoder         : Lavc60.35.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 0 vbv_delay: N/A
frame= 9706 fps= 11 q=2.0 size=   22016kB time=00:05:23.50 bitrate= 557.5kbits/s speed=0.359x

My video has 9723 frame, the progress stop at 9706 and not process, I'm not sure what cause that, if you could lend a hand I'd be very grateful!

OS: windows10 python: 3.10.9 torch: 2.1.2 cuda: 11.8 ffmpeg: 2023-12-14-git-5256b2fbe6-full_build

LiveNL commented 6 months ago

Hi,

I'm having the same issue.

It appears that for me the while-statement below does not evaluate to False anymore at the very end and thus it keeps sleeping:

https://github.com/nadermx/backgroundremover/blob/4f389f4652303475224080f3b37cfea488e77586/backgroundremover/utilities.py#L120-L130

nadermx commented 6 months ago

Are both of you trying to convert to mp4? Can I see the full command?

LiveNL commented 6 months ago

I am. For example with:

python -m backgroundremover.cmd.cli -i "short.mp4" -tv -o "output.mov"

I've tried .mov files as input as well, by coverting .mp4's first:

ffmpeg -i short.mp4 -f mov short.mov

In this case the script runs more smoothly, but in the delivers a video that isn't openable by quicktime (I'm on macOS, m1). It does open in DaVinci Resolve, but just shows a sort of distored/damaged input video. This is another issue, but just FYI.

nadermx commented 6 months ago

It won't work if you are doing a video to MP4. MP4 doesn't have transparent background. When trying video try the human algorithm. Too

On Fri, Dec 22, 2023, 1:27 AM Jordi Wippert @.***> wrote:

I am. For example with:

python -m backgroundremover.cmd.cli -i "short.mp4" -tv -o "output.mov"

I've tried .mov files as input as well, by coverting .mp4's first:

ffmpeg -i short.mp4 -f mov short.mov

In this case the script runs more smoothly, but in the delivers a video that isn't openable by quicktime (I'm on macOS, m1). It does open in DaVinci Resolve, but just shows a sort of distored/damaged input video. This is another issue, but just FYI.

— Reply to this email directly, view it on GitHub https://github.com/nadermx/backgroundremover/issues/117#issuecomment-1867334678, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYACXDTGDVLI2D5CMOKKCDYKUY5RAVCNFSM6AAAAABAZK7K3WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRXGMZTINRXHA . You are receiving this because you commented.Message ID: @.***>

1ncoQAQ commented 6 months ago

I think I figured it out. The input video is shot with my smartphone. Maybe my phone uses a different encoding standard, which causes some frames can not be recognized by backgroundremover, so the process stuck. To fix this, I simply convert my video using ffmpeg once: ffmpeg -i originalVideo.mp4 fixedVideo.mp4 Then use backgroundremover to deal with the fixed video, this time the program works. Thank you for the reply Jordi! you inspired me to preprocess the video first before throwing it into backgroundremover. Maybe we can add this preprocessing to the workflow to make sure backgroundremover can handle the video correctly?

nadermx commented 6 months ago

That's actually not a bad idea although maybe more as an exception, there has to be a way to figure out if it's compatible or not and hten use preprocessing or not.

On Fri, Dec 22, 2023 at 2:26 PM 1nco @.***> wrote:

I think I figured it out. The input video is shot with my smartphone. Maybe my phone uses a different encoding standard, which causes some frames can not be recognized by backgroundremover, so the process stuck. To fix this, I simply convert my video using ffmpeg once: ffmpeg -i originalVideo.mp4 fixedVideo.mp4 Then use backgroundremover to deal with the fixed video, this time the program works. Thank you for the reply Jordi! you inspired me to preprocess the video first before throwing it into backgroundremover. Maybe we can add this preprocessing to the workflow to make sure backgroundremover can handle the video correctly?

— Reply to this email directly, view it on GitHub https://github.com/nadermx/backgroundremover/issues/117#issuecomment-1868047992, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYACXBHWDNVBF6TWS6LOTLYKXUHNAVCNFSM6AAAAABAZK7K3WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRYGA2DOOJZGI . You are receiving this because you commented.Message ID: @.***>