[Maya-Python] mayapy playblast

1,589 views
Skip to first unread message

Marcus Ottosson

unread,
Feb 25, 2016, 6:02:01 PM2/25/16
to python_in...@googlegroups.com

Hi all,

This one is probably for the Autodesk forums, but I figured I’d give it a show.

In a virtual machine, with bare essentials installed, I’m attempting to playblast but are running into fatal errors.

[marcus@docker:~$ docker run --rm -ti mottosso/maya:2013sp1
[root@69e43200bda7 ~]# mayapy
Python 2.6.4 (r264:75706, Jul 27 2011, 17:36:42)
[GCC 4.1.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import maya.standalone
maya.standalone.initialize()>>> maya.standalone.initialize()
>>> from maya import cmds
>>> cmds.playblast()
maya encountered a fatal error
Signal: 11 (Unknown Signal)
Result: untitled
Fatal Error. Attempting to save in /usr/tmp/.20160225.2226.ma

The bare essentials are these:

RUN yum update -y && yum install -y \
    nano \
    csh \
    libXp \
    libXmu \
    libXpm \
    libXi \
    libtiff \
    libXinerama \
    elfutils \
    gstreamer-plugins-base.x86_64 \
    gamin \
    git \
    mesa-utils \
    tcsh \
    xorg-x11-server-Xorg \
    wget && \
    yum groupinstall -y "X Window System"

My question to you then is:

  • What else could be needed for playblasting to work?

Best,
Marcus

--
Marcus Ottosson
konstr...@gmail.com

Justin Israel

unread,
Feb 25, 2016, 7:26:34 PM2/25/16
to python_in...@googlegroups.com
Maybe you are missing video drivers in the bare bones image? Or maybe you need to actually pass the display to the docker container:

docker run -ti --rm  -e DISPLAY=$DISPLAY  -v /tmp/.X11-unix:/tmp/.X11-unix mottosso/maya:2013sp1

If that doesn't work, does it work under an ubuntu image?


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCzU7a12LmHJv9CXLTEmgKDxt-yDWm_UGWM4tROPUpBkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Justin Israel

unread,
Feb 25, 2016, 7:32:05 PM2/25/16
to python_in...@googlegroups.com
And also, you might get a better idea of what Maya was doing when it crashed if you debug it with gdb?

gdb -ex run --args /bin/bash `which mayapy`
...
>>> # do stuff
[crash]
(gdb) bt
[back track follow]


Marcus Ottosson

unread,
Feb 26, 2016, 2:33:25 AM2/26/16
to python_in...@googlegroups.com
Thanks Justin.

Passing the display did not make a difference, possibly because the docker image is being run in yet another virtual machine that also does not have a window manager installed. The goal is to run this on something like Travis.

The gdb route seems promising. I just can't wrap my head around how to use it with mayapy, or how to pass additional flags to mayapy like a script so it can run on its own. :S Passing just the above causes gdb to sit and wait until I force quit with CTRL-Z.

What am I doing wrong?


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Nicolas Chaverou

unread,
Feb 26, 2016, 6:37:06 AM2/26/16
to python_in...@googlegroups.com
I'd have bet on the graphics drivers / opengl.
Else if your Maya viewport is active, you may try to dump the frame buffer to images and run a post process to assemble them as a video:

http://nathanhorne.com/python-api-grab-frame-buffer-to-image/

Justin Israel

unread,
Feb 26, 2016, 2:58:44 PM2/26/16
to python_in...@googlegroups.com
Yea, I wonder if it is even possible to run this on a Travis CI, unless you can be sure there is a graphics card available on the runner and that your environment has graphic drivers installed. 

Marcus Ottosson

unread,
Feb 27, 2016, 3:26:59 AM2/27/16
to python_in...@googlegroups.com

I’d like to think it’s possible with mesa drivers or the like.

Grabbing the framebuffer was an interesting tip, but unfortunately did not bear any fruit.

[root@9378ed216bc0 ~]# mayapy

Python 2.6.4 (r264:75706, Jul 27 2011, 17:36:42)
[GCC 4.1.2] on linux2
Type "help", "copyright", "credits" or "license" for
 more information.
>>> from maya import standalone
>>> standalone.initialize()
>>> import maya.OpenMaya as api
>>> import maya.OpenMayaUI as apiUI
>>> view = apiUI.M3dView.active3dView()
>>> image = api.MImage()
>>> view.readColorBuffer(image, True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: (kFailure): Unexpected Internal Failure
>>>

I got gdb to run, but it wasn’t particularly helpful. Maybe there’s a flag of sorts to have it tell me more?

[root@9378ed216bc0 ~]# export PYTHONHOME=/usr/autodesk/maya2013-x64                                        [root@9378ed216bc0 ~]# gdb --args python-bin -c "import maya.standalone;maya.standalone.initialize();import maya.cmds;maya.cmds.playblast()"
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-83.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/autodesk/maya2013-x64/bin/python-bin...done.
(gdb) r
Starting program: /usr/autodesk/maya2013-x64/bin/python-bin -c import\ maya.standalone\;maya.standalone.initialize\(\)\;import\ maya.cmds\;maya.cmds.playblast\(\)

maya encountered a fatal error

Signal: 11 (Unknown Signal)
Result: untitled
Fatal Error. Attempting to save in /usr/tmp/.20160227.0821.ma
During startup program exited with code 1.
(gdb)


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Justin Israel

unread,
Feb 27, 2016, 4:42:32 AM2/27/16
to python_in...@googlegroups.com

Did you run the 'bt' command after it seg faulted and gave you back the gdb prompt? The stack info may not even be helpful. I just wondered if it would highlight what specifically it was trying to do when it crashed.


Marcus Ottosson

unread,
Feb 27, 2016, 5:30:38 AM2/27/16
to python_in...@googlegroups.com
No I did not. Doing it now, it simply says "No stack". :(


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Justin Israel

unread,
Feb 27, 2016, 5:10:35 PM2/27/16
to python_in...@googlegroups.com
On Sat, Feb 27, 2016 at 11:30 PM Marcus Ottosson <konstr...@gmail.com> wrote:
No I did not. Doing it now, it simply says "No stack". :(

Maybe there was an error when gdb started up, with it not being able to load the binary. Oh well.
 

Marcus Ottosson

unread,
Sep 17, 2016, 12:12:32 PM9/17/16
to python_in...@googlegroups.com

Got this somewhat further, with newfound knowledge of Xvfb.

$ yum install xorg-x11-server-Xorg
$ Xvfb :99 -screen 0 1024x768x16 2>/dev/null &
$ mayapy -c "from maya import standalone, cmds; \
   standalone.initialize(); \
   cmds.playblast(format='image')"

In a nutshell how it works is that as far as Maya is concerned, there is an X environment running, only it’s running entirely in-memory.

The problem now is that it tries running a playblast with Viewport 2.0.

# VP2 Error : Failed to initialize graphics device.

Is there any way of playblasting without Viewport 2.0? Or any way of disabling it entirely? Alternatively, what kind of drivers can I install to emulate whatever it needs, e.g. mesa?

I’m expecting Viewport 2.0 to have more advanced requirements than what Mesa is capable of, but could be wrong. It might not work with Legacy either.

Thanks!

Marcus Ottosson

unread,
Sep 17, 2016, 12:20:52 PM9/17/16
to python_in...@googlegroups.com

Sorry, that yum command should have been:

$ yum install xorg-x11-server-Xvfb
--
Marcus Ottosson
konstr...@gmail.com

Fredrik Averpil

unread,
Sep 17, 2016, 12:49:03 PM9/17/16
to python_in...@googlegroups.com
> xvfb

Ah, that was clever!

Following this topic with interest. 

Marcus Ottosson

unread,
Sep 18, 2016, 6:21:45 AM9/18/16
to python_in...@googlegroups.com

Next piece of the puzzle, no errors this time, and a successfully created Quicktime file.

$ yum install mesa-libGL-devel
$ export LIBQUICKTIME_PLUGIN_DIR=/usr/autodesk/maya/lib
$ mayapy -c "from maya import standalone, cmds; \
   standalone.initialize(); \
   cmds.playblast(filename='/root/workspace/myplayblast')"
# VP2 Warning : Graphics hardware has been detected to have insufficient memory (0 MB).
# Please check your video card and driver to ensure that a minimum amount of memory exists (512 MB).
# The environment variable MAYA_OGS_GPU_MEMORY_LIMIT can be used to explicitly set the GPU memory limit.
# VP2 Warning : Insufficient shader level capabilities. Vertex (3 vs 4), Geometry (0 vs 0) Pixel (3 vs 4)
# VP2 Warning : Graphics hardware feature level insufficient to support renderer (2 vs 4)

The file is, however, 700 bytes and contains no images. :(

My guess is it successfully creates the file and is just about to fetch images from the viewport (which one?) and silently fails.

$ hexdump -C myplayblast.mov
00000000  00 00 00 20 66 74 79 70  71 74 20 20 20 05 03 00  |... ftypqt   ...|
00000010  71 74 20 20 00 00 00 00  00 00 00 00 00 00 00 00  |qt  ............|
00000020  00 00 00 01 6d 64 61 74  00 00 00 00 00 00 00 10  |....mdat........|
00000030  00 00 02 a4 6d 6f 6f 76  00 00 00 6c 6d 76 68 64  |....moov...lmvhd|
00000040  00 00 00 00 d4 04 17 19  d4 04 17 19 00 00 00 18  |................|
00000050  00 00 00 00 00 01 00 00  01 00 00 00 00 00 00 00  |................|
00000060  00 00 00 00 00 01 00 00  00 00 00 00 00 00 00 00  |................|
*
00000080  00 00 00 00 40 00 00 00  00 00 00 00 00 00 00 00  |....@...........|
00000090  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000a0  00 00 00 02 00 00 02 28  74 72 61 6b 00 00 00 5c  |.......(trak...\|
000000b0  74 6b 68 64 00 00 00 0f  d4 04 17 19 d4 04 17 19  |tkhd............|
000000c0  00 00 00 01 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 01 00 00  |................|
*
000000f0  00 00 00 00 00 00 00 00  00 00 00 00 40 00 00 00  |............@...|
00000100  01 40 00 00 00 f0 00 00  00 00 00 24 65 64 74 73  |.@.........$edts|
00000110  00 00 00 1c 65 6c 73 74  00 00 00 00 00 00 00 01  |....elst........|
00000120  00 00 00 00 00 00 00 00  00 01 00 00 00 00 01 a0  |................|
00000130  6d 64 69 61 00 00 00 20  6d 64 68 64 00 00 00 00  |mdia... mdhd....|
00000140  d4 04 17 19 d4 04 17 19  00 00 00 18 00 00 00 00  |................|
00000150  00 00 00 64 00 00 00 41  68 64 6c 72 00 00 00 00  |...d...Ahdlr....|
00000160  6d 68 6c 72 76 69 64 65  00 00 00 00 00 00 00 00  |mhlrvide........|
00000170  00 00 00 00 20 4c 69 62  71 75 69 63 6b 74 69 6d  |.... Libquicktim|
00000180  65 20 56 69 64 65 6f 20  4d 65 64 69 61 20 48 61  |e Video Media Ha|
00000190  6e 64 6c 65 72 00 00 01  37 6d 69 6e 66 00 00 00  |ndler...7minf...|
000001a0  14 76 6d 68 64 00 00 00  01 00 40 80 00 80 00 80  |.vmhd.....@.....|
000001b0  00 00 00 00 39 68 64 6c  72 00 00 00 00 64 68 6c  |....9hdlr....dhl|
000001c0  72 61 6c 69 73 00 00 00  00 00 00 00 00 00 00 00  |ralis...........|
000001d0  00 18 4c 69 6e 75 78 20  41 6c 69 61 73 20 44 61  |..Linux Alias Da|
000001e0  74 61 20 48 61 6e 64 6c  65 72 00 00 00 24 64 69  |ta Handler...$di|
000001f0  6e 66 00 00 00 1c 64 72  65 66 00 00 00 00 00 00  |nf....dref......|
00000200  00 01 00 00 00 0c 61 6c  69 73 00 00 00 01 00 00  |......alis......|
00000210  00 be 73 74 62 6c 00 00  00 66 73 74 73 64 00 00  |..stbl...fstsd..|
00000220  00 00 00 00 00 01 00 00  00 56 70 6e 67 20 00 00  |.........Vpng ..|
00000230  00 00 00 00 00 01 00 00  00 00 6c 71 74 20 00 00  |..........lqt ..|
00000240  00 64 00 00 01 02 01 40  00 f0 00 48 00 00 00 48  |.d.....@...H...H|
00000250  00 00 00 00 00 00 00 01  12 6c 69 62 71 75 69 63  |.........libquic|
00000260  6b 74 69 6d 65 2d 31 2e  31 2e 34 00 00 00 00 00  |ktime-1.1.4.....|
00000270  00 00 00 00 00 00 00 00  00 18 ff ff 00 00 00 10  |................|
00000280  73 74 74 73 00 00 00 00  00 00 00 00 00 00 00 1c  |stts............|
00000290  73 74 73 63 00 00 00 00  00 00 00 01 00 00 00 01  |stsc............|
000002a0  00 00 00 01 00 00 00 01  00 00 00 14 73 74 73 7a  |............stsz|
000002b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 10  |................|
000002c0  73 74 63 6f 00 00 00 00  00 00 00 00 00 00 00 08  |stco............|
000002d0  75 64 74 61                                       |udta|
000002d4

Full reproducible here.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWO1ze3AiSuuQt8K1kUymrWXE9ttfDXK4S1R6wLrtYa0Mw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Geordie Martinez

unread,
Sep 19, 2016, 1:42:37 AM9/19/16
to python_inside_maya
Yes you CAN subprocess without viewport 2.0. I've been having the problem as well at work. 

you have to swap your preferences back to Legacy. then when ```maya.standalone.initialize()``` runs it won't search for synchronized color settings. which is where this devil is originating from.

Legacy viewport in prefs prevents the subprocess from hanging. explanation below.

the way I found this was deleting my prefs then noticing the subprocess worked fine. I eventually narrowed it down to the synColor folder in the prefs as well as synColor config.xml in my prefs folder. googled it and found out this started in Maya 2016. and that this bug is supposed to be fixed in the latest patches. but... I think it's back.  

basically, on a lark, I turned my prefs back to legacy and made sure that was the last maya I closed.
then ran all of my subprocesses and lo and behold, it worked. 
the issue is that if you have more than one subprocess/session of maya  attempting to read/modify/write any of the synchronized color files for Viewport 2.0 it somehow freezes the subprocesses. 
I think it's a filesystem thing with file open/read/close conflicts. this is just a guess.






To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Fredrik Averpil

unread,
Sep 20, 2016, 2:24:09 PM9/20/16
to python_inside_maya

synColor

Oh the memories …of segfault.

Anyway, this is something I’ve wanted to know for a while; is it possible to switch to “legacy” from commandline somehow, prior to launching Maya or maya.standalone? (sorry for possibly derailing the thread)


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABPXW4gAS3hJLopkH%2BUvtuJhVzWMF1rRYXhsUnQTtzAyQcdCkA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages