Closed Mombin closed 2 years ago
same for me also with 0KB video output.
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"
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 :
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.
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
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
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.
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?
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
Just the desire is a bit on the low side at the moment
I understand that all too well! great project here btw
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 : High@L6.1
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
I made it work!
You just needed to take care of a few things:
ffmpeg -i test.mkv input.mp4
or elseHere'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 : High@L3.2
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:
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.
thank you for share this code and model.
I tested with a single image and it worked. but when i tested in video, it failed. (use -tv option). output video have 0kb.
I try to upgrade ffmpeg version to 4.4.1 but it isn't work...
ubuntu 18.04 python3.6 torch 1.10.1 cuda 11.3