diff --git a/flamenco_worker/commands.py b/flamenco_worker/commands.py index 5df5d15..93e3405 100644 --- a/flamenco_worker/commands.py +++ b/flamenco_worker/commands.py @@ -805,6 +805,20 @@ class AbstractBlenderCommand(AbstractSubprocessCommand): self._last_activity_time = 0.0 + def _format_dna_to_cli(self, format_for_dna: str) -> str: + """Converts the DNA image format enum to a CLI -F argument for Blender. + + The DNA enum value is generally the same as what would be passed on the + command line, except the EXR formats. + """ + + # See https://developer.blender.org/D4502 + dna_to_cli = { + 'OPEN_EXR': 'EXR', + 'OPEN_EXR_MULTILAYER': 'MULTILAYER', + } + return dna_to_cli.get(format_for_dna, format_for_dna) + def validate(self, settings: Settings): blender_cmd, err = self._setting(settings, 'blender_cmd', True) if err: @@ -979,7 +993,7 @@ class BlenderRenderCommand(AbstractBlenderCommand): if settings.get('render_output'): cmd.extend(['--render-output', settings['render_output']]) if settings.get('format'): - cmd.extend(['--render-format', settings['format']]) + cmd.extend(['--render-format', self._format_dna_to_cli(settings['format'])]) if settings.get('frames'): cmd.extend(['--render-frame', settings['frames']]) return cmd diff --git a/tests/test_commands_blender_render.py b/tests/test_commands_blender_render.py index 1deee3d..3ea87e5 100644 --- a/tests/test_commands_blender_render.py +++ b/tests/test_commands_blender_render.py @@ -108,6 +108,40 @@ class BlenderRenderTest(AbstractCommandTest): stderr=subprocess.STDOUT, ) + def test_cli_openexr(self): + from tests.mock_responses import CoroMock + + filepath = Path(__file__).parent.as_posix() + settings = { + # Point blender_cmd to this file so that we're sure it exists. + 'blender_cmd': f'{self.thisfile!r} --with --cli="args for CLI"', + 'chunk_size': 100, + 'frames': '1..2', + 'format': 'OPEN_EXR', + 'filepath': filepath, + } + + cse = CoroMock(...) + cse.coro.return_value.wait = CoroMock(return_value=0) + cse.coro.return_value.pid = 47 + with patch('asyncio.create_subprocess_exec', new=cse) as mock_cse: + self.loop.run_until_complete(self.cmd.run(settings)) + + mock_cse.assert_called_once_with( + self.thisfile, + '--with', + '--cli=args for CLI', + '--enable-autoexec', + '-noaudio', + '--background', + filepath, + '--render-format', 'EXR', # see https://developer.blender.org/D4502 + '--render-frame', '1..2', + stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + ) + def test_python_expr(self): from tests.mock_responses import CoroMock