Recherche avancée

Médias (1)

Mot : - Tags -/bug

Autres articles (87)

Sur d’autres sites (16256)

  • Fatal Python error : could not acquire lock for at interpreter shutdown, possibly due to daemon threads

    3 octobre 2019, par JavNoor

    Running the following :

    import imageio

    class vidrdf:
       def __init__(self, vidfile):
           self.vid = imageio.get_reader(vidfile,  'ffmpeg')

    vidfile = 'movie.mov'
    rdfobj = vidrdf(vidfile)

    I get :

    Fatal Python error: could not acquire lock for <_io.BufferedReader name=8> at interpreter shutdown, possibly due to daemon threads

    Thread 0x00007fd2dc2a8700 (most recent call first):
     File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio_ffmpeg/_parsing.py", line 61 in run
     File "miniconda3/envs/flower/lib/python3.7/threading.py", line 926 in _bootstrap_inner
     File “/path/miniconda3/envs/flower/lib/python3.7/threading.py", line 890 in _bootstrap

    Current thread 0x00007fd2f0bb9700 (most recent call first):
     File “/path/miniconda3/envs/flower/lib/python3.7/subprocess.py", line 1704 in _communicate
     File “/path/miniconda3/envs/flower/lib/python3.7/subprocess.py", line 939 in communicate
     File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio_ffmpeg/_io.py", line 193 in read_frames
     File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio/plugins/ffmpeg.py", line 342 in _close
     File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio/core/format.py", line 252 in close
     File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio/core/format.py", line 241 in __del__
    Aborted (core dumped)

    It doesn’t happen if I try :

    import imageio

    class vidrdf:
       def __init__(self, vidfile):
           self.vid = imageio.get_reader(vidfile,  'ffmpeg')

    vidfile = 'movie.mov'
    vidrdf(vidfile)

    or

    import imageio

    class vidrdf:
       def __init__(self, vidfile):
           vid = imageio.get_reader(vidfile,  'ffmpeg')

    vidfile = 'movie.mov'
    rdfobj = vidrdf(vidfile)

    So this is clearly an issue with copying the object. I’ve searched about daemon threads, but since I’m using imageio directly I can’t figure out why and how to resolve it. I would appreciate any recommendations.

  • ffmpeg errors in the daemon

    3 octobre 2020, par smoto_shei

    I created a shell script to compress a video using ffmpeg(4.3.1).

    


    ffmpeg -y -i \
 '/var/www/System/Backend/Outputs/TempSaveMovie/200703_4_short_5fr_p2(100_20)_r(50_20).mp4' \
 -vcodec h264 -an \
 '/var/www/System/Backend/Outputs/MovieOutputs/200703_4_short_5fr_p2(100_20)_r(50_20).mp4'



    


    If you run this code from the console, it will run without problems.
In fact, we're using the python subscript.call() to execute it. It works fine too.

    


    cmd = 'sh /var/www/System/Backend/cv2toffmpeg.sh'
subprocess.call(cmd, shell=True)


    


    Secondly, if I run it from a daemonized python program, I'll get an error. I get the following error.
You'll get an error like this

    


    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './Outputs/TempSaveMovie/200703_4_short_5fr_p2(100_20)_r(50_20).mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.35.100
  Duration: 00:00:06.15, start: 0.000000, bitrate: 10246 kb/s
    Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 10244 kb/s, 13 fps, 13 tbr, 13312 tbn, 13 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (h264_nvenc))
Press [q] to stop, [?] for help
[mpeg4 @ 0x55cec17c5480] header damaged
[mpeg4 @ 0x55cec17c6840] header damaged
[mpeg4 @ 0x55cec1855f80] header damaged
[mpeg4 @ 0x55cec1866e00] header damaged
Output #0, mp4, to './Outputs/MovieOutputs/200703_4_short_5fr_p2(100_20)_r(50_20).mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.45.100
    Stream #0:0(und): Video: h264 (h264_nvenc) (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 13 fps, 13312 tbn, 13 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.91.100 h264_nvenc
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
Error while decoding stream #0:0: Invalid data found when processing input
[mpeg4 @ 0x55cec17c8780] header damaged
Error while decoding stream #0:0: Invalid data found when processing input
[mpeg4 @ 0x55cec17c5480] header damaged


    


    I think the problem is when you run it from a daemonized process. There seems to be a similar problem in the past.
Ffmpeg does not properly convert videos when run as daemon
I would like to ask for your help to solve this problem. Thank you for your help from Japan.

    


  • avcodec/pthread_slice : Don't use static variable, fix race

    28 novembre 2020, par Andreas Rheinhardt
    avcodec/pthread_slice : Don't use static variable, fix race
    

    ff_slice_thread_init() uses a static variable to hold a function
    pointer, although the value of said pointer needn't be saved between
    different runs of this function at all.

    The reason for this being so is probably that said pointer points to
    a static function (if used) ; but storage class specifiers like "static"
    are not part of the type of an object and so including it in the pointer
    declaration is wrong (anyway, "static" means different things in both
    contexts : for the function declaration it affects linkage, for the
    variable storage duration).

    Using a static variable here can lead to races, e.g. when initializing
    VP9 (for which said function pointer was added) and H.264 with slice
    threading. The latter has the FF_CODEC_CAP_INIT_THREADSAFE flag set and
    is therefore unaffected by the lock guarding initializations of
    decoders.

    Reviewed-by : Anton Khirnov <anton@khirnov.net>
    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@gmail.com>

    • [DH] libavcodec/pthread_slice.c