Skip to content

run get_reader sequentially for thousands time, get IOError: Could not load meta information #273

Closed

Description

@xforceco

In situation where video_files contains full valid paths to 1500 .avi files, I run this simple script

for j,i in enumerate(self.video_files):
	imageio.get_reader(i,'ffmpeg');
	print(j, " done");
print("all done");

I run four times,
first crashes at 362 done
second crashes at 1073 done
third succeeds at all done
fourth crashes at 473 done

Error message:

Traceback (most recent call last):
File "test.py", line 69, in init
imageio.get_reader(i,'ffmpeg');
File "/mydir/anaconda3/envs/cntk-py27/lib/python2.7/site-packages/imageio/core/functions.py", line 129, in get_reader
return format.get_reader(request)
File "/mydir/anaconda3/envs/cntk-py27/lib/python2.7/site-packages/imageio/core/format.py", line 169, in get_reader
return self.Reader(self, request)
File "/mydir/anaconda3/envs/cntk-py27/lib/python2.7/site-packages/imageio/core/format.py", line 218, in init
self._open(**self.request.kwargs.copy())
File "/mydir/anaconda3/envs/cntk-py27/lib/python2.7/site-packages/imageio/plugins/ffmpeg.py", line 327, in _open
self._load_infos()
File "/mydir/anaconda3/envs/cntk-py27/lib/python2.7/site-packages/imageio/plugins/ffmpeg.py", line 480, in _load_infos
raise IOError(fmt % err2)
IOError: Could not load meta information
=== stderr ===
ffmpeg version 3.3.3-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.4.0 (Debian 6.4.0-2) 20170724
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libxvid
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100

Activity

  1. almarklein commented on Sep 5, 2017

    @almarklein
    Member

    Bah, yet another issue with ffmpeg. I think we really need that pyav plugin (#115)...

  2. added a commit that references this issue on Nov 13, 2017
  3. added a commit that references this issue on Nov 14, 2017
  4. added a commit that references this issue on Dec 9, 2017
  5. ranieuwe commented on Feb 19, 2018

    @ranieuwe

    Ran into this as well, dug a little deeper. It looks like the ffmpeg plugin is not properly cleaning up the processes it spawns. Issuing a hard imageio._proc.kill() after you are done with your logic will kill the process spawned by Popen effectively solving your problem. I've tried to figure out how to patch the ffmpeg plugin, but didn't see a quick fix, issuing a self.proc.kill() in the terminate did not work for some reason.

  6. almarklein commented on Feb 19, 2018

    @almarklein
    Member

    It looks like the ffmpeg plugin is not properly cleaning up the processes it spawns

    A recurring issue :(

  7. ranieuwe commented on Feb 20, 2018

    @ranieuwe

    I messed with this yesterday in the interactive shell, there is a second problem (potentially): somehow the Popen spawned ffmpeg twice - I could not yet reliably reproduce, but it seems to happen every once in a while. Could it be that it does clean up one process but not the second one? Doesn't explain why _proc.kill() works though 😕

  8. almarklein commented on Mar 12, 2018

    @almarklein
    Member

    The problem does not seem to occur on Windows. The fact that manually issuing _proc.kill() works is interesting. Have you verified (e.g. with a print call) that the _terminate() method is indeed being called?

  9. yelantf commented on Aug 15, 2018

    @yelantf

    so, how to avoid this? I tried that (reader)._proc.kill() but it would easily cause OSError: [Errno 3] No such process.

  10. almarklein commented on Sep 3, 2018

    @almarklein
    Member

    @yelantingfeng put a try-except around that. Sight ... its ugly, but if it works ... until we get a better video plugin.

  11. yelantf commented on Sep 4, 2018

    @yelantf

    ok, then, thank you.

  12. yelantf commented on Feb 3, 2019

    @yelantf

    still not fixed?

  13. almarklein commented on Feb 3, 2019

    @almarklein
    Member

    Since I'm not being payed to work on this, there is no guarantees on fixing this in any set period of time.

    That said, I happen to be working on a new ffmpeg plugin, which I expect to be much more robust.

  14. almarklein commented on Feb 4, 2019

    @almarklein
    Member

    The basis for the new ffmpeg plugin is https://github.com/imageio/imageio-ffmpeg, which I just made a first release for. That small library can also be used by itself (allthough its rather low-level). It should also be much more robust against daemon processes, by how its implemented, but also because it has extensive tests for this, which I ran on Win/OSX/Linux.

    It would be really helpful if you could try it on your data and confirm that it does not suffer from the same problem.

  15. almarklein commented on Feb 5, 2019

    @almarklein
    Member

    I am going to assume that #425 (making use of the above mentioned library) will fix this. Feel free to reopen if the error persists after this change!

  16. Eldrants commented on Sep 16, 2019

    @Eldrants

    just recently I got this problem but at first, it works but I don't know what made it like this, I did updates the python and imageio if that's relevant. I also uninstalled and reinstalled all. I was trying to use imageio in python to convert an mp4 to gif. the error starts when it trying to read the file

    Video path: C:\Python3\Projects\vid2gif\alita.mp4
    C:\Python3\Projects\vid2gif\output\alita.gif
    Reading C:\Python3\Projects\vid2gif\alita.mp4
    Traceback (most recent call last):
      File "C:\Python3\Projects\vid2gif\converter.py", line 36, in <module>
        gifMaker(clip, '.gif') #alita.gif
      File "C:\Python3\Projects\vid2gif\converter.py", line 22, in gifMaker
        reader = imageio.get_reader(inputPath) #imageio read the clip
      File "C:\Python\Python37\lib\site-packages\imageio\core\functions.py", line 143, in get_reader
        return format.get_reader(request)
      File "C:\Python\Python37\lib\site-packages\imageio\core\format.py", line 164, in get_reader
        return self.Reader(self, request)
      File "C:\Python\Python37\lib\site-packages\imageio\core\format.py", line 214, in __init__
        self._open(**self.request.kwargs.copy())
      File "C:\Python\Python37\lib\site-packages\imageio\plugins\ffmpeg.py", line 322, in _open
        self._initialize()
      File "C:\Python\Python37\lib\site-packages\imageio\plugins\ffmpeg.py", line 465, in _initialize
        self._meta.update(self._read_gen.__next__())
      File "C:\Python\Python37\lib\site-packages\imageio_ffmpeg\_io.py", line 150, in read_frames
        raise IOError(fmt.format(err2))
    OSError: Could not load meta information
    === stderr ===
    
    ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
      built with gcc 8.2.1 (GCC) 20181017
      configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
      libavutil      56. 22.100 / 56. 22.100
      libavcodec     58. 35.100 / 58. 35.100
      libavformat    58. 20.100 / 58. 20.100
      libavdevice    58.  5.100 / 58.  5.100
      libavfilter     7. 40.101 /  7. 40.101
      libswscale      5.  3.100 /  5.  3.100
      libswresample   3.  3.100 /  3.  3.100
      libpostproc    55.  3.100 / 55.  3.100
    C:\Python3\Projects\vid2gif\alita.mp4: Permission denied
    
  17. almarklein commented on Sep 16, 2019

    @almarklein
    Member

    Permission denied

    That looks like a permission problem. Perhaps the video was written with elevated permissions, causing it inaccessible by a normal process?

  18. Eldrants commented on Sep 16, 2019

    @Eldrants

    I don't think so... before this, it worked fine. I've also tried other video.

  19. Eldrants commented on Sep 16, 2019

    @Eldrants

    lol nevermind fixed it. recently I installed an antivirus called Iobit Malware Fighter it blocked or will try to ask your first to allow the process but even after you allowed it, it still blocked you. so I uninstalled it. anyway thanks for the quick reply :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions