Download

Get headless screenshot

Hi,
I want to take a screenshot of the viewport only by running a python script from the command line.
I wrote this:

import unreal

actor_class = unreal.CameraActor
actor_location = unreal.Vector(-250,0.0,150.0)
actor_rotation = unreal.Rotator(0.0,0.0,0.0)
_spawnedCamera = unreal.EditorLevelLibrary.spawn_actor_from_class(actor_class, actor_location, actor_rotation)
unreal.EditorLevelLibrary.editor_set_game_view(True)
unreal.log_warning("getting screenshot")
unreal.AutomationLibrary.take_high_res_screenshot(640,480,"E:/test.jpg",_spawnedCamera)
unreal.log_warning("got screenshot")

But the script crashes on
unreal.AutomationLibrary.take_high_res_screenshot(640,480,“E:/test.jpg”,_spawnedCamera)
I got this error:

[2021.12.30-14.01.41:138][  0]LogPython: Warning: getting screenshot
[2021.12.30-14.02.00:286][  0]LogWindows: Error: === Critical error: ===
[2021.12.30-14.02.00:286][  0]LogWindows: Error:
[2021.12.30-14.02.00:287][  0]LogWindows: Error: Fatal error!
[2021.12.30-14.02.00:288][  0]LogWindows: Error:
[2021.12.30-14.02.00:288][  0]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000448
[2021.12.30-14.02.00:288][  0]LogWindows: Error:
[2021.12.30-14.02.00:289][  0]LogWindows: Error: [Callstack] 0x00007fffb2832643 UE4Editor-FunctionalTesting.dll!UnknownFunction []
[2021.12.30-14.02.00:289][  0]LogWindows: Error: [Callstack] 0x00007fffb2845778 UE4Editor-FunctionalTesting.dll!UnknownFunction []
[2021.12.30-14.02.00:290][  0]LogWindows: Error: [Callstack] 0x00007ffff1a52604 UE4Editor-CoreUObject.dll!UnknownFunction []
[2021.12.30-14.02.00:290][  0]LogWindows: Error: [Callstack] 0x00007ffff1ce0e63 UE4Editor-CoreUObject.dll!UnknownFunction []
[2021.12.30-14.02.00:291][  0]LogWindows: Error: [Callstack] 0x00007fffad437ea1 UE4Editor-PythonScriptPlugin.dll!UnknownFunction []
[2021.12.30-14.02.00:291][  0]LogWindows: Error: [Callstack] 0x00007fffad41967f UE4Editor-PythonScriptPlugin.dll!UnknownFunction []
[2021.12.30-14.02.00:292][  0]LogWindows: Error: [Callstack] 0x00007fffad417ee8 UE4Editor-PythonScriptPlugin.dll!UnknownFunction []
[2021.12.30-14.02.00:292][  0]LogWindows: Error: [Callstack] 0x00007fffad3cab4c UE4Editor-PythonScriptPlugin.dll!UnknownFunction []
[2021.12.30-14.02.00:293][  0]LogWindows: Error: [Callstack] 0x00007fffbc7ef2b6 python37.dll!_PyObject_FastCallKeywords() [c:\a\18\s\objects\call.c:199]
[2021.12.30-14.02.00:293][  0]LogWindows: Error: [Callstack] 0x00007fffbc7edc3b python37.dll!call_function() [c:\a\18\s\python\ceval.c:4619]
[2021.12.30-14.02.00:294][  0]LogWindows: Error: [Callstack] 0x00007fffbc7f53b8 python37.dll!_PyEval_EvalFrameDefault() [c:\a\18\s\python\ceval.c:3095]
[2021.12.30-14.02.00:294][  0]LogWindows: Error: [Callstack] 0x00007fffbc7ee3ac python37.dll!_PyEval_EvalCodeWithName() [c:\a\18\s\python\ceval.c:3930]
[2021.12.30-14.02.00:295][  0]LogWindows: Error: [Callstack] 0x00007fffbc7fb573 python37.dll!PyEval_EvalCodeEx() [c:\a\18\s\python\ceval.c:3966]
[2021.12.30-14.02.00:295][  0]LogWindows: Error: [Callstack] 0x00007fffbc7fb4d1 python37.dll!PyEval_EvalCode() [c:\a\18\s\python\ceval.c:530]
[2021.12.30-14.02.00:296][  0]LogWindows: Error: [Callstack] 0x00007fffad3d0395 UE4Editor-PythonScriptPlugin.dll!UnknownFunction []
[2021.12.30-14.02.00:296][  0]LogWindows: Error: [Callstack] 0x00007fffad401efd UE4Editor-PythonScriptPlugin.dll!UnknownFunction []
[2021.12.30-14.02.00:296][  0]LogWindows: Error: [Callstack] 0x00007fffad3d0950 UE4Editor-PythonScriptPlugin.dll!UnknownFunction []
[2021.12.30-14.02.00:297][  0]LogWindows: Error: [Callstack] 0x00007fffad3e59df UE4Editor-PythonScriptPlugin.dll!UnknownFunction []
[2021.12.30-14.02.00:297][  0]LogWindows: Error: [Callstack] 0x00007ff684509a29 UE4Editor-Cmd.exe!UnknownFunction []
[2021.12.30-14.02.00:298][  0]LogWindows: Error: [Callstack] 0x00007ff684500eec UE4Editor-Cmd.exe!UnknownFunction []
[2021.12.30-14.02.00:298][  0]LogWindows: Error: [Callstack] 0x00007ff68450125a UE4Editor-Cmd.exe!UnknownFunction []
[2021.12.30-14.02.00:299][  0]LogWindows: Error: [Callstack] 0x00007ff6845152bd UE4Editor-Cmd.exe!UnknownFunction []
[2021.12.30-14.02.00:299][  0]LogWindows: Error: [Callstack] 0x00007ff68451736e UE4Editor-Cmd.exe!UnknownFunction []
[2021.12.30-14.02.00:300][  0]LogWindows: Error: [Callstack] 0x00007ff8234c7034 KERNEL32.DLL!UnknownFunction []
[2021.12.30-14.02.00:300][  0]LogWindows: Error: [Callstack] 0x00007ff823c22651 ntdll.dll!UnknownFunction []
[2021.12.30-14.02.00:301][  0]LogWindows: Error:

Can this be done or is it impossible?
Thank you.