From 9bcfc36b7aeca0d3c923793e7a51405e79b705fb Mon Sep 17 00:00:00 2001 From: Steven Robertson Date: Mon, 15 May 2017 11:56:37 -0700 Subject: [PATCH] Retrieve out suffix without creating a renderer --- cuburn/output.py | 39 +++++++-------------------------------- main.py | 2 +- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/cuburn/output.py b/cuburn/output.py index 21e5e72..7701004 100644 --- a/cuburn/output.py +++ b/cuburn/output.py @@ -64,14 +64,6 @@ class Output(object): """ raise NotImplementedError() - @property - def suffix(self): - """ - Return the file suffix that will be used. If more than one suffix will - be used, the value returned is the one considered to be "primary". - """ - raise NotImplementedError() - class PILOutput(Output, ClsMod): lib = pixfmtlib @@ -112,13 +104,6 @@ class PILOutput(Output, ClsMod): return {'.jpg': out}, {} return {'.'+self.type: self._convert_buf(buf)}, [] - @property - def suffix(self): - if self.type == 'jpeg': - if self.alpha: return '_color.jpg' - return '.jpg' - return '.'+self.type - class TiffOutput(Output, ClsMod): lib = pixfmtlib @@ -149,10 +134,6 @@ class TiffOutput(Output, ClsMod): out.seek(0) return {'.tiff': out}, [] - @property - def suffix(self): - return '.tiff' - class ProResOutput(Output, ClsMod): lib = pixfmtlib @@ -203,10 +184,6 @@ class ProResOutput(Output, ClsMod): self._subp.stdin.write(buffer(host_frame)) return {}, [] - @property - def suffix(self): - return '.mov' - class X264Output(Output, ClsMod): lib = pixfmtlib @@ -314,11 +291,6 @@ class X264Output(Output, ClsMod): self._write(buffer(self.zeros), self.asubp) return out - @property - def suffix(self): - if self.alpha: return '_color.h264' - return '.h264' - class VPxOutput(Output, ClsMod): lib = pixfmtlib @@ -435,10 +407,13 @@ class VPxOutput(Output, ClsMod): self._write(buf, self.subp) return out - @property - def suffix(self): - return '.webm' - +def get_suffix_for_profile(gprof): + opts = dict(gprof.output._val) + ext = dict(jpeg='.jpg', png='.png', tiff='.tiff', x264='.h264', + prores='.mov', vp8='.webm', vp9='.webm')[opts.get('type', 'jpeg')] + if opts.get('alpha'): + ext = '_color' + ext + return ext def get_output_for_profile(gprof): opts = dict(gprof.output._val) diff --git a/main.py b/main.py index 1cc04d0..e4f3e4a 100755 --- a/main.py +++ b/main.py @@ -62,7 +62,7 @@ def main(args, prof): m = os.path.getmtime(args.flame) for name, times in frames: if args.resume: - fp = name + rdr.out.suffix + fp = name + output.get_suffix_for_profile(gprof) if os.path.isfile(fp) and m < os.path.getmtime(fp): continue