Closed nadermx closed 1 year ago
So that leaves me to believe that the file might be right, but now perhaps since it is faster it is not reading the mov correctly during the ffmpeg, since that is where it is erroring out
python -m backgroundremover.cmd.cli -i "examplefiles/shave.mp4" -tg -o "crap.mov"
FRAME RATE DETECTED: 155/6 (if this looks wrong, override the frame rate)
FRAME RATE: 26 TOTAL FRAMES: 161
WORKER 0 ONLINE
WORKER FRAMERIPPER ONLINE
ffmpeg version 4.4.3-0ubuntu1~20.04.sav5 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
configuration: --prefix=/usr --extra-version='0ubuntu1~20.04.sav5' --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-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-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libzimg --enable-libdc1394 --enable-libdrm --enable-libiec61883 --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
Input #0, rawvideo, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: 37872 kb/s
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 569x320, 37872 kb/s, 26 tbr, 26 tbn, 26 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
[swscaler @ 0x5599304047c0] Warning: data is not aligned! This can lead to a speed loss
Output #0, mp4, to '/tmp/tmprn_fgv05/matte.mp4':
Metadata:
encoder : Lavf58.76.100
Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p(tv, progressive), 569x320, q=2-31, 2000 kb/s, 26 fps, 13312 tbn
Metadata:
encoder : Lavc58.134.100 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 0 vbv_delay: N/A
ffmpeg version 4.4.3-0ubuntu1~20.04.sav5 Copyright (c) 2000-2022 the FFmpeg developers=1.07x
built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
configuration: --prefix=/usr --extra-version='0ubuntu1~20.04.sav5' --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-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-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libzimg --enable-libdc1394 --enable-libdrm --enable-libiec61883 --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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/imageeditor/backgroundremover/examplefiles/shave.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso6iso2avc1mp41
encoder : Lavf59.27.100
Duration: 00:00:06.42, start: 0.000000, bitrate: 474 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709), 854x480 [SAR 1:1 DAR 427:240], 321 kb/s, 25.79 fps, 25.83 tbr, 90k tbn, 51.59 tbc (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 93 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x564677c20f80] moov atom not found
/tmp/tmprn_fgv05/matte.mp4: Invalid data found when processing input
Process finished
frame= 158 fps= 21 q=2.0 Lsize= 357kB time=00:00:06.03 bitrate= 484.2kbits/s speed=0.787x
video:355kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.430353%
Specificially this part
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x564677c20f80] moov atom not found
/tmp/tmprn_fgv05/matte.mp4: Invalid data found when processing input
And this superuser question seems to be among the same issues.
It seems this isn't putting the frames in the correct order, so back toe drawing board
@nadermx How it works?
What do you mean @Sam2003ds? The project works fine. I have had it, perhaps due to this I think, crash on me on occasion after doing a bunch of video's.
After looking at how I had set up the current frame ripping, there is a chance that if it processes frames faster than it can write it, that the while loop could get stuck. What I pasted here, is an updated utilites.py function.
In this I am trying to place the frames in a queue to mitigate the while loops. The one I posted makes a matte_key file, but not sure if it makes it correctly. Since it fails when I input it into ffmpeg and that might be since it seems it may be placing the frames not back in order causing the .mov to be invail since they missing the meta info that is on there in the way the current repo does it.
@nadermx what are the codes for?
The project works fine, this is a bug fix that occurs occasionally. I updated my previous comment to you if you want to read it should explain.
thanks
Going to close this, as I think it was related to the input files with special charectors. Will keep testing and reopen if it occurs.
In trying to kill two birds with one stone, basically this is the issue. If anyone looks at the code, specifically at the utilities function, https://github.com/nadermx/backgroundremover/blob/main/backgroundremover/utilities.py
There are two while loops 1 and 2 .
The while loop with a sleep function to wait for results to be added to the results_dict. This can cause the program to hang indefinitely if a result is never added to the dictionary or if the loop is unable to exit for some other reason.
A better approach would be to use a synchronization primitive, such as a multiprocessing.Queue or a multiprocessing.Event, to signal when a result has been added to the dictionary.
This would probably increase, or give a route to increase the video processing speed and GPU usage.
I have a primitive updated utilities.by below doing this, haven't had much time to debug specifically yet, but the matte_key seems to work, but the transparent video no.