[docs]classSlateRenderer(RendererBase):"""Class for rendering slates. .. admonition:: Example .. code-block:: python # render slate image to 1080p slate_generator = SlateHtmlGenerator( # data used to fill up the slate template { "project": {"name": "test_project"}, "intent": {"value": "test_intent"}, "task": {"short": "test_task"}, "asset": "test_asset", "comment": "some random comment", "scope": "test_scope", "@version": "123", }, "/templates/slates/slate_generic/slate_generic.html", ) rend = SlateRenderer( slate_generator, SequenceInfo.scan("resources/public/plateMain/v002")[0], ) rend.render(debug=True) """def__init__(self,slate_generator:SlateHtmlGenerator,source_sequence:SequenceInfo,destination:str=None# default prepend to the source sequence):self._slate_proc=slate_generatorself._dest=None# default destinationself._forced_dest=destination# explicit destinationself._source_sequence=Noneself.source_sequence=source_sequenceself._thumbs:List=Noneself._command:List=[]@propertydefslate_generator(self)->SlateHtmlGenerator:""" Returns: SlateHtmlGenerator: The generator associated to the renderer. """returnself._slate_proc@slate_generator.setterdefslate_generator(self,generator:SlateHtmlGenerator)->None:""" Args: generator (SlateHtmlGenerator): The new generator for the renderer. """self._slate_proc=generatorself._slate_proc.source_files=self._source_sequence.frames@propertydefsource_sequence(self)->SequenceInfo:"""Return the source sequence. Returns: SequenceInfo. The source sequence. """returnself._source_sequence@source_sequence.setterdefsource_sequence(self,source_sequence:SequenceInfo)->None:"""Set new source sequence. """self._source_sequence=source_sequenceself._slate_proc.source_files=self._source_sequence.framesfirst_frame=self._source_sequence.frames[0]frame_number=first_frame.frame_numberslate_frame=str(frame_number-1).zfill(source_sequence.padding)ext=first_frame.extensionhead,_,__=first_frame.filepath.rsplit(".",3)self._dest=f"{head}.{slate_frame}{ext}"@propertydefdestination(self):""" Returns: str: The renderer destination. """returnself._forced_destorself._dest
[docs]defrender(self,debug=False)->None:"""Render the slate sequence. Arguments: debug (Optional[bool]): Whether to increase log verbosity. """first_frame=self.source_sequence.frames[0]timecode=offset_timecode(tc=first_frame.timecode,frame_offset=-1,fps=first_frame.fps,)self._slate_proc.create_base_slate()cmd=["oiiotool"]cmd.extend(self._slate_proc.get_oiiotool_cmd())cmd.extend(["--ch","R,G,B","--attrib:type=timecode","smpte:TimeCode",timecode,])ifdebug:cmd.extend(["--debug","-v"])cmd.extend(["-o",self.destination])call_cmd(cmd)slate_base_image_path=Path(self._slate_proc._slate_base_image_path).resolve()slate_base_image_path.unlink()shutil.rmtree(slate_base_image_path.parent)