Video Clip Crashes MPF MC After Multiple Triggers

69 views
Skip to first unread message

atum

unread,
Apr 14, 2020, 11:50:09 PM4/14/20
to MPF Users
All,

I have something that is confusing the heck out of me!  I am just starting to get some video assets tied in to my game, and I have a video that plays when a mode starts.  It works 100% as expected...3 or 4 times.  It will work whether in the same game or across games about 3 or 4 times.  However, then on 4 or 5, it will just crash MPF MC, which then shuts down MPF.  I am not sure if it is related to the size of the file, way I am using it or what.  I just trimmed the video to a few second clip to test, and plugged it in.  So if there is something else I need to do with video composition, that would be good to know as well.

I have attached the video, and you should be able to plug it into the IMC tool.  Then just click and just copy and paste the IMC snippet in, and click Send.  After about 4 or 5 times, it will crash out the video portion of the screen.

If anyone can replicate, and tell me why it breaks, or confirm it works over and over for them without issue, that would help me figure out how to tackle this issue.  Thanks!


Config (Display and Window are set to 1280w x 720h):
videos:
    dekutreestart
:
        height
: 720
        width
: 1280
        file
: dekutreestart.mp4

Show (in separate show file):
- duration: 5
  slides
:
    dekutree_start_slide
:
      widgets
:
     
- type: video
        video
: dekutreestart

MPF IMC snippet (based on the file name of the config shown above):
my_test_slide:
    widgets
:
     
- type: video
        video
: dekutreestart

mike wiz

unread,
Apr 15, 2020, 8:24:31 AM4/15/20
to MPF Users
Are you running Windows 10?

What version of MPF and MPC are you running?

Can you post your pip list?

atum

unread,
Apr 15, 2020, 9:40:51 AM4/15/20
to MPF Users
I am on Windows 10.  I have never updated my packages, just downloaded and went with it.  If I need to update them, what is the command to do so?

Package                          Version
-----------------------             ----------
asciimatics                       1.11.0
certifi                                2019.11.28
chardet                             3.0.4
docutils                             0.16
future                                0.18.2
idna                                   2.8
Kivy                                  1.11.1
kivy-deps.glew                  0.1.12
kivy-deps.glew-dev           0.1.12
kivy-deps.gstreamer         0.1.17
kivy-deps.gstreamer-dev  0.1.17
kivy-deps.sdl2                  0.1.22
kivy-deps.sdl2-dev           0.1.22
Kivy-Garden                     0.1.4
mpf                                   0.53.2
mpf-mc                             0.53.0
mpf-monitor                     0.53.0
Pillow                               7.0.0
pip                                   20.0.2
psutil                                5.6.7
pyfiglet                             0.8.post1
Pygments                        2.5.2
pypiwin32                        223
PyQt5                              5.14.1
PyQt5-sip                        12.7.1
pyserial                           3.4
pyserial-asyncio              0.4
pywin32                           227
requests                          2.22.0
ruamel.yaml                    0.15.100
setuptools                       45.2.0
sortedcontainers            2.1.0
terminaltables                3.1.0
typing                             3.7.4.1
urllib3                            1.25.8
wcwidth                         0.1.8

atum

unread,
Apr 15, 2020, 11:20:45 AM4/15/20
to MPF Users
I updated my stuff to latest (53.3, etc.), but am still running into the same issue.  With MPF IMC, I get the following when it crashes:  Failed to write to bcp since transport is closing. Transport <_SelectorSocketTransport closing fd=1916 read=idle write=<idle, bufsize=0>>, not sure if this helps or not.

Here is my new pip list:
Package                 Version
----------------------- ----------
asciimatics             1.11.0
certifi                 2019.11.28
chardet                 3.0.4
docutils                0.16
future                  0.18.2
idna                    2.8
Kivy                    1.11.1
kivy-deps.glew          0.1.12
kivy-deps.glew-dev      0.1.12
kivy-deps.gstreamer     0.1.17
kivy-deps.gstreamer-dev 0.1.17
kivy-deps.sdl2          0.1.22
kivy-deps.sdl2-dev      0.1.22
Kivy-Garden             0.1.4
mpf                     0.53.3
mpf-mc                  0.53.3

mpf-monitor             0.53.0
Pillow                  7.0.0
pip                     20.0.2
psutil                  5.6.7
pyfiglet                0.8.post1
Pygments                2.5.2
pypiwin32               223
PyQt5                   5.14.1
PyQt5-sip               12.7.1
pyserial                3.4
pyserial-asyncio        0.4
pywin32                 227
requests                2.22.0
ruamel.yaml             0.15.100
setuptools              46.1.3

sortedcontainers        2.1.0
terminaltables          3.1.0
typing                  3.7.4.1
urllib3                 1.25.8
wcwidth                 0.1.8

Thanks!
Avery

jabdoa

unread,
Apr 15, 2020, 12:52:55 PM4/15/20
to MPF Users
I will have a look and let you know if I can crash it.

Jan

atum

unread,
Apr 16, 2020, 9:40:12 AM4/16/20
to MPF Users
Jan,

I appreciate it.  I also tried with a new file yesterday and ran into the same issue.  I turned on my computer camera, waved at the camera for a 3 second clip.  test.mp4.  I then dropped that file into my videos folder ([main_game_folder]/videos.  I then went in and triggered it to play video: test.  It did the same thing, and ran 4 times, and then crashed the MPF IMC utility.  So something about this crashes the video.  I ready the full log, and it captured all of my .mp4 assets in the folder (not .wmv - not sure if it should or not), and loaded them before I started.  So they were queued up as expected, but then just crash.

Thanks again for your help!

Avery

jabdoa

unread,
Apr 17, 2020, 3:53:29 PM4/17/20
to MPF Users
I can reproduce this. However it takes a few hundred plays. It seems to leak the video somehow. I verified that we properly unload the slide and widget. But the video somehow leaks. Probably some kivy magic going on. Have to dig deeper there.

Jan

atum

unread,
Apr 17, 2020, 4:42:38 PM4/17/20
to MPF Users
Jan,

So your computer is more powerful than mine, and thus takes longer for it to catch up?  I have a ton going on with this computer normally, so I am using up about 70% of memory when I have been running it, so there isn't much room for a leak before it crashes.  I will close out a bunch of my other stuff to see if I can lower my memory usage and get it to go longer before a crash.

In the meantime, I will pause my progress of adding videos and just use images as placeholders so that I can keep moving forward with figuring out what I want to add.

Thanks for taking the time to dig in, and I would offer to help, but I don't have a darn clue Kivy works, and got really confused when I jumped over to their documentation pages!

Avery

jabdoa

unread,
Apr 18, 2020, 9:39:59 AM4/18/20
to MPF Users
I looked into this. Unfortunately this is a leak in gstreamer somehow. If I run "KIVY_VIDEO=ffpyplayer mpf imc" it won't leak nor could I get it to crash. The crash in gstreamer occurs because it leaks file descriptors and at some point runs out of descriptors. Not sure what your options are on Windows. Maybe "KIVY_VIDEO=ffmpeg" but not sure if that works. You could try to update kivy-deps.gstreamer to 0.1.18. Not sure how much that will help and it requires an edit to setup.py of mpf-mc.


Jan

atum

unread,
Apr 18, 2020, 11:15:18 AM4/18/20
to MPF Users
Jan,

If I am following, I tried to launch like normal through CMD, but instead of jump "mpf imc", I typed "KIVY_VIDEO=ffmpeg mpf imc", but that returned a message that KIVY_VIDEO is not recognized as an internal or external command.  So unless I am doing something wrong, it doesn't seem that it works on Windows.

Is there anyway to lower the number of descriptors that I have by editing the file?  Or is that just hte basic descriptors that Kivy reads as it is processing and loading the video?

As for the update to 0.1.18, is there anywhere that lists steps on how to do that?  I made it to:C:\Users\user\AppData\Local\Programs\Python\Python36\Lib\site-packages, but I am not finding a setup.py that has anything useful.  Found one for Python, but not for MPF, and no idea how to specifically tell it to go grab that file.  On the internet found a Kivy Gstreamer 0.2.0, but when I tried to load that, it said it was already installed.

Thanks!

Avery

jabdoa

unread,
Apr 18, 2020, 1:14:40 PM4/18/20
to MPF Users
Not sure how the windows syntax is. Also I have no idea how to increase the number of file descriptors on Windows. On Linux that can be done with ulimit but that is certainly different on Windows. You probably cannot use the kivy 2.0 deps without upgrading kivy to 2.0 (currently beta) which has breaking api changes.

Jan

atum

unread,
Apr 18, 2020, 2:28:28 PM4/18/20
to MPF Users
Jan,

Marking this one as solved!  Still obviously some issue with the gstreamer and the leak, if you have that captured as a bug somewhere.  But there is no way to increase the file descriptors on Windows, unless you compile from base source code, which isn't really an option.

BUT I did run: pip install ffpyplayer, which installed ffpyplayer-4.3.1.  With that installed, it now works as expected.  I am sure just like you saw it will crash after a large number of plays on a windows machine, but I just went over 30 without issue, and swapped between videos without issue as well.

Not sure if there is anyway to force that for Windows or not, but if anyone runs into this issue, that seems to be all that is needed to get it out of the funk.  Hoping it stays this way!

Thanks for all your help and guidance, as always!

Avery

jabdoa

unread,
Apr 18, 2020, 3:21:55 PM4/18/20
to MPF Users
Awesome. Thanks for testing. Did not know that this is possible. Maybe we can make it a default for windows. Does sound work properly with ffpyplayer?

Jan

atum

unread,
Apr 18, 2020, 5:31:48 PM4/18/20
to MPF Users
Sound works as expected, and syncs up just as if I were playing the raw video file.  So from there, all systems go.  I have not played around with controls where events would pause,seek, etc.  But assuming that would work for windows if it works on linux.  I am not there with my code yet, but I can try to get something together this weekend to report back with a positive test of those features.

Avery

mike wiz

unread,
Apr 18, 2020, 6:50:56 PM4/18/20
to MPF Users

Hey Avery,

Did you have to uninstall gstreamer?

Do you mind posting your pip list now?

I had this issue on a Windows box and would like to test your fix.

Thanks.

atum

unread,
Apr 18, 2020, 8:17:14 PM4/18/20
to MPF Users
I did not have to uninstall anything, I tried some reinstall and some goofy stuff, but it never took.  The only action that was "valid" was: "pip install ffpyplayer".

Here is my pip list.  Note it is all the same as above, except that ffpyplayer shows up on the list (version 4.3.1)
Package                 Version
----------------------- ----------
asciimatics 1.11.0
certifi 2019.11.28
chardet 3.0.4
docutils 0.16
ffpyplayer 4.3.1

Check it out, and hopefully you can verify that it isn't just a fluke on my machine!

jabdoa

unread,
Apr 19, 2020, 8:52:38 AM4/19/20
to MPF Users
This is now a requirement on all platforms in MPF dev.

Jan

mike wiz

unread,
Apr 19, 2020, 9:52:40 AM4/19/20
to MPF Users
Ok so I got 53 to work.

ffpyplayer was not installed.  when I checked log I saw this.

kivy : Factory: 194 symbols loaded
kivy : Cache: register <kv.lang> with limit=None, timeout=None
kivy : Cache: register <kv.image> with limit=None, timeout=60
kivy : Cache: register <kv.atlas> with limit=None, timeout=None
kivy : Image: Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
kivy : Cache: register <kv.texture> with limit=1000, timeout=60
kivy : Cache: register <kv.shader> with limit=1000, timeout=3600
kivy : VideoGstplayer: Using Gstreamer 1.10.2.0
kivy : Video: Provider: gstplayer
kivy : Loading MPF-MC controller

When I installed ffpyplayer I saw this:

kivy : Factory: 194 symbols loaded
kivy : ImageLoaderFFPy: Using ffpyplayer 4.3.1
kivy : Image: Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer, img_gif
kivy : VideoGstplayer: Using Gstreamer 1.10.2.0
kivy : Video: Provider: gstplayer
kivy : Loading MPF-MC controller

Game worked fine, no crashes.

I then tried to upgrade to dev and get this error message.

C:\Users\mwiz\Desktop\robotech>mpf both -t -P
INFO : root : Loading config.
Traceback (most recent call last):
  File "C:\Users\mwiz\AppData\Local\Programs\Python\Python36\Scripts\mpf-script.py", line 11, in <module>
    load_entry_point('mpf==0.54.0.dev25', 'console_scripts', 'mpf')()
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\site-packages\mpf\commands\__init__.py", line 175, in run_from_command_line
    CommandLineUtility(path).execute()
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\site-packages\mpf\commands\__init__.py", line 163, in execute
    _module.Command(self.mpf_path, machine_path, remaining_args)
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\site-packages\mpf\commands\both.py", line 27, in __init__
    _start_mpf(mpf_path, machine_path, args)
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\site-packages\mpf\commands\both.py", line 9, in _start_mpf
    module.Command(mpf_path, machine_path, args)
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\site-packages\mpf\commands\game.py", line 227, in __init__
    config = config_loader.load_mpf_config()
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\site-packages\mpf\core\config_loader.py", line 288, in load_mpf_config
    with open(self.get_mpf_bundle_path(self.machine_path), "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\mwiz\\Desktop\\robotech\\mpf_config.bundle'
kivy: Factory: 184 symbols loaded
kivy: ImageLoaderFFPy: Using ffpyplayer 4.3.1
kivy: Image: Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer, img_gif
kivy: VideoGstplayer: Using Gstreamer 1.16.0.0
kivy: Video: Provider: gstplayer
kivy: Loading MPF-MC controller
Process Process-1:
Traceback (most recent call last):
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\multiprocessing\process.py", line 258, in _bootstrap
    self.run()
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\multiprocessing\process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\site-packages\mpf\commands\both.py", line 14, in _start_mc
    module.Command(mpf_path, machine_path, args + ["--both"])
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\site-packages\mpfmc\commands\mc.py", line 219, in __init__
    config = config_loader.load_mc_config()
  File "c:\users\mwiz\appdata\local\programs\python\python36\lib\site-packages\mpf\core\config_loader.py", line 293, in load_mc_config
    with open(self.get_mpf_mc_bundle_path(self.machine_path), "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\mwiz\\Desktop\\robotech\\mpf_mc_config.bundle'

mike wiz

unread,
Apr 19, 2020, 1:33:02 PM4/19/20
to MPF Users
Ok I figured it out.  It is working.  I forgot about this change with -P flag


Reply all
Reply to author
Forward
0 new messages