Coder Social home page Coder Social logo

Comments (12)

durgabhavaniv avatar durgabhavaniv commented on August 19, 2024

same for me also with 0KB video output.

from backgroundremover.

nadermx avatar nadermx commented on August 19, 2024

both on ubuntu 18? I haven't tested it on ubuntu 18, only 20. Although I don't see a reason as to why it woudn't work. Can you do just the matte file? (green screen) backgroundremover -i "/path/to/video.mp4" -mk -o "output.matte.mp4"

from backgroundremover.

couclock avatar couclock commented on August 19, 2024

Thanks a lot for your work, I have been looked for such a tool for many weeks !

On my side, I'm working on Ubuntu 21.10 with :

  • Python 3.9.7
  • Torch 1.10.1

Handling of Images works fine.
For video files, it gives me an output file of 0kb.

I tried to generate the matte file and it works as expected, I get a valid video file.

Let me know if I can do other tests to help you fixing this issue.

from backgroundremover.

nadermx avatar nadermx commented on August 19, 2024

Do you have FFMPEG 4.4+? If the Matte key is working, then the removal is working so it's probably something with the ffmpeg version. Either way I have to rewrite that part to make it work on msft

from backgroundremover.

couclock avatar couclock commented on August 19, 2024

Here is my ffmpeg version :

~ > ffmpeg -version
ffmpeg version 4.4-6ubuntu5 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-7ubuntu1)
configuration: --prefix=/usr --extra-version=6ubuntu5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100

from backgroundremover.

315332 avatar 315332 commented on August 19, 2024

I had the same issue as you guys.

The problem for me was that I was using a .webm file. I don't know what this support but I changed the webm to mp4 with ffmpeg and the output to .mov and it worked for me.

from backgroundremover.

ExtremeHobo avatar ExtremeHobo commented on August 19, 2024

I am having the same issue on Windows 11
Python 3.6.8
ffmpeg 4.4.1 and also attempted newest 2022 branch
torch 1.11.0 - no CUDA

I have tried mov, mp4, webm, avi etc for the intial input and mov and mp4 for the output. Anyone ever find a solution?

from backgroundremover.

nadermx avatar nadermx commented on August 19, 2024

I really need to spend time to fix a few of these issues. Just the desire is a bit on the low side at the moment. If anyone wants to pull request... All this need is the file paths to be corrected to work on windows as well

from backgroundremover.

ExtremeHobo avatar ExtremeHobo commented on August 19, 2024

Just the desire is a bit on the low side at the moment

I understand that all too well! great project here btw

from backgroundremover.

j2l avatar j2l commented on August 19, 2024

Hello,
Congrats @nadermx, you have a great project and helpful community!

I also have the same behavior on Ubuntu 21.10, CUDA 11.6 (while only 11.3 for pytorch), stock ffmpeg (4.4-6ubuntu5), python 3.9 (couldn't find 3.6-dev).
Full error is:

backgroundremover -i test.mkv -tv -o removed.mov
removed.mov
Downloading...
From: https://drive.google.com/uc?id=1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ
To: /home/pm/.u2net/u2net.pth
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 176M/176M [00:04<00:00, 36.5MB/s]
Traceback (most recent call last):
  File "/home/pm/.local/bin/backgroundremover", line 8, in <module>
    sys.exit(main())
  File "/home/pm/.local/lib/python3.9/site-packages/backgroundremover/cmd/cli.py", line 241, in main
    remove(
  File "/home/pm/.local/lib/python3.9/site-packages/backgroundremover/bg.py", line 183, in remove
    img = Image.open(io.BytesIO(data)).convert("RGB")
  File "/home/pm/.local/lib/python3.9/site-packages/PIL/Image.py", line 2958, in open
    raise UnidentifiedImageError(
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f02d8825180>

and video is very basic:

Format                                   : Matroska
Format version                           : Version 4
File size                                : 99.3 KiB
Duration                                 : 3 s 757 ms
Overall bit rate                         : 217 kb/s
Writing application                      : Lavf58.76.100
Writing library                          : Lavf58.76.100
ErrorDetectionType                       : Per level 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 3 s 757 ms
Bit rate                                 : 212 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 086 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Stream size                              : 97.3 KiB (98%)
Writing library                          : x264 core 160 r3011 cde9a93
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=18 / lookahead_threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language                                 : English
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Matrix coefficients                      : BT.470 System B/G
ALPHA_MODE                               : 1

result is a 0 bytes removed.mov file

from backgroundremover.

j2l avatar j2l commented on August 19, 2024

I made it work!

You just needed to take care of a few things:

  • no webm or mkv as input, transcode to mp4 first with ffmpeg ffmpeg -i test.mkv input.mp4 or else
  • use quotes "output.mov", and also relative path for input "./...mp4"

Here's a tough example (black hair on black background) https://pixabay.com/videos/stress-woman-face-depression-44637/ :

Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/mp41/isom/avc1)
File size                                : 8.72 MiB
Duration                                 : 28 s 778 ms
Overall bit rate                         : 2 543 kb/s
Encoded date                             : UTC 2020-07-17 22:37:22
Tagged date                              : UTC 2020-07-17 22:37:22
Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : CABAC / 5 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 5 frames
Format settings, GOP                     : M=4, N=76
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 28 s 760 ms
Bit rate                                 : 2 286 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.099
Stream size                              : 7.84 MiB (90%)
Writing library                          : x264 core 160 r10 22fcbe1
Encoding settings                        : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=8 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=22 / lookahead_threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / stitchable=1 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=infinite / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=crf / mbtree=1 / crf=20.0 / qcomp=0.60 / qpmin=5 / qpmax=69 / qpstep=4 / vbv_maxrate=2750 / vbv_bufsize=7500 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Encoded date                             : UTC 2020-07-17 22:37:22
Tagged date                              : UTC 2020-07-17 22:37:22
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Codec configuration box                  : avcC
Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 28 s 778 ms
Bit rate mode                            : Constant
Bit rate                                 : 253 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 890 KiB (10%)
Encoded date                             : UTC 2020-07-17 22:37:22
Tagged date                              : UTC 2020-07-17 22:37:22

I still have issues with colors and frame rate in VLC:
image

from backgroundremover.

nadermx avatar nadermx commented on August 19, 2024

My bad on this one. I dont think th merge request fixes this issue. The issue is that you are trying to output a mp4. Mp4 doesnt have a container. It has to output a mov or gif. Unless I am misunderstanding @j2l commented with the solution.

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.