From 113eb8f7abe2e6a689aec66dee58c0e6cca8b8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 21 Nov 2018 14:23:32 +0100 Subject: [PATCH] Flamenco: add fps, output_file_extension, and images_or_video job settings These are all needed to use FFmpeg on the worker to render a video from rendered image sequences. - fps: float, the scene FPS - images_or_video: either 'images' or 'video', depending on what's being output by Blender. We don't support using FFmpeg to join chunked videos yet. - output_file_extension: string like '.png' or '.exr', only set when outputting images (since doing this for video requires a lookup table and isn't even being used at the moment). --- CHANGELOG.md | 2 ++ blender_cloud/flamenco/__init__.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 753b96e..6efdeda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ## Version 1.9.5 (in development) - Fix crashing Blender when running in background mode (e.g. without GUI). +- Flamenco: Include extra job parameters to allow for encoding a video at the end of a render + job that produced an image sequence. ## Version 1.9.4 (2018-11-01) diff --git a/blender_cloud/flamenco/__init__.py b/blender_cloud/flamenco/__init__.py index 25b94ec..e8695e2 100644 --- a/blender_cloud/flamenco/__init__.py +++ b/blender_cloud/flamenco/__init__.py @@ -53,6 +53,9 @@ log = logging.getLogger(__name__) # Global flag used to determine whether panels etc. can be drawn. flamenco_is_active = False +# 'image' file formats that actually produce a video. +VIDEO_FILE_FORMATS = {'FFMPEG', 'AVI_RAW', 'AVI_JPEG'} + @pyside_cache('manager') def available_managers(self, context): @@ -240,6 +243,9 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin, 'filepath': manager.replace_path(outfile), 'frames': frame_range, 'render_output': manager.replace_path(render_output), + + # Used for FFmpeg combining output frames into a video. + 'fps': scene.render.fps / scene.render.fps_base, } # Add extra settings specific to the job type @@ -256,6 +262,28 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin, settings['cycles_sample_count'] = samples settings['format'] = 'EXR' + # Let Flamenco Server know whether we'll output images or video. + output_format = settings.get('format') or scene.render.image_settings.file_format + if output_format in VIDEO_FILE_FORMATS: + # Currently we don't do any postprocessing for video, so we don't + # bother figuring out the final output filename. + settings['images_or_video'] = 'video' + else: + settings['images_or_video'] = 'images' + # The file extension is necessary to find the output files and + # render them to a video with ffmpeg. + settings['output_file_extension'] = scene.render.file_extension # like '.png' + + # Always pass the file format, even though it won't be + # necessary for the actual render command (the blend file + # already has the correct setting). It's used by other + # commands, such as FFmpeg combining output frames into + # a video. + # + # Note that this might be overridden above when the job type + # requires a specific file format. + settings.setdefault('format', scene.render.image_settings.file_format) + try: job_info = await create_job(self.user_id, prefs.project.project,