3

I am trying to playblast multiple Maya scenes in a folder, without bringing up the Maya GUI.

  • I have successfully invoked a headless Maya instance with mayabatch.exe
  • That instance calls a script that crawls a folder
  • Each scene is opened
  • But I cannot playblast the scene file

1. Purple noise

If I simply call pm.playblast(format='movie', filename=some_filepathname, viewer=False, forceOverwrite=True, offScreen=True) I get an AVI file with purple noise. If I switch to format='image' I get a sequence of images with purple noise.

2. Cannot lookThru

Based on some sample playblast code, I tried calling pm.lookThru("persp") first, but this triggers the following traceback:

#   File "C:\Users\username\Documents\playbatch\blaster.py", line 23, in blast_file
#     pm.lookThru("persp")
#   File "C:\Program Files\Autodesk\Maya2016\Python\lib\site-packages\pymel\inte
rnal\pmcmds.py", line 133, in wrappedCmd
#     res = new_cmd(*new_args, **new_kwargs)
# RuntimeError: There is no active view.

...presumably because a headless instance has no view.

3. Forcing a single renderable camera has no effect

A relatively recent (2015) post TO [Maya-Python], "Playblasting in standalone" suggests that all that is needed is a single renderable camera.

cams = cmds.ls(type='camera')
for cam in cams:
    cmds.setAttr(cam + '.rnd', 0)
cmds.setAttr('persp.rnd', 1)

...but this still renders purple noise.

Calling the playblast command from the Maya Script Editor / GUI works. Is it possible to playblast from a headless/mayabatch instance? If so, what other values need to be set for a successful playblast?

lofidevops
  • 15,528
  • 14
  • 79
  • 119

2 Answers2

2

Actually you can do playblasts in mayabatch or mayapy mode (The two having different background by default in playblasts). I never went very deeply into it but I had similar results than with a classic Maya playblast. I don't think you have access to HUD options and other graphical settings and there can be problems if you have hardware shaders or other non-standards shaders to display.

Never use "look through", just set your cameras as renderable cameras with that script you linked, Maya will do the rest. Don't use pymel either, it can bring very sneaky bugs and I wouldn't be surprised if it didn't work in batch mode. Try not to even import its module as it sets a lot of things in the background (I encountered some weird behaviour and bugs in batch mode while it was working in interactive mode).

  1. Are your purple playblasts done with an already custom made Maya scene or did you create a very basic file first with like primitives and nothing fancy? Get a good result with a basic setup, then once you have a good result try with your real scenes. If it doesn't work with them then try to reduce it to find what's wrong in it. Or implement, step by step, things from your final scenes to your basic working scene to find what is doing that.

  2. Otherwise you can launch Maya without GUI with the environment variable MAYA_OVERRIDE_UI. Set it to a mel filename located in a script folder and you can then launch Maya with a simpler window with a bit of mel.

  3. You can also get help from the maya-capture library so that you don't have to code everything yourself.

  4. Use Hardware Renderer.

Regnareb
  • 134
  • 6
  • the purple turned out to be problems in the scene, when I fixed the scene, the purple went away, but the playblasts were black; since then I switched to the hardware renderer – lofidevops May 05 '16 at 15:17
  • thanks for the maya-capture link, I'm always encouraged by "X done right" in a library's description :) – lofidevops May 05 '16 at 15:18
1

You can't blast with mayabatch as it uses the GUI.

You have two options :

  • Render with hardware renderer
  • Open a maya and execute playblast
DrWeeny
  • 2,487
  • 1
  • 14
  • 17