From 53854bdf73e24476cb7e75a4d30ecc342e3f857e Mon Sep 17 00:00:00 2001 From: Andrey Skvortsov Date: Sat, 29 Mar 2025 19:52:32 +0300 Subject: [PATCH] mpegize: add support for dcraw_emu --- mpegize.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/mpegize.py b/mpegize.py index ddef7c1..3f72044 100755 --- a/mpegize.py +++ b/mpegize.py @@ -498,6 +498,19 @@ class Mpegize: def display_frames(m, v): return "%d frames %s" % (v, m.display_usec(v * 1000000 / 30.)) + def dcraw_detect(m): + m.dcraw_bin = shutil.which("dcraw_emu") + if not m.dcraw_bin and os.path.isfile("/usr/lib/libraw/dcraw_emu"): + m.dcraw_bin = "/usr/lib/libraw/dcraw_emu" + if not m.dcraw_bin: + m.dcraw_bin = "dcraw" + return m.dcraw_bin + + def tiffname(m, f): + if m.dcraw_bin == "dcraw": + f = f[:-4] + return f + '.tiff' + def jpegize(m): i = 0 os.chdir(m.base) @@ -506,6 +519,7 @@ class Mpegize: l = list(l) l.sort() print("Have", m.display_frames(len(l)), "dngs") + m.dcraw_detect() for n in l: if n[-4:] != ".dng": print("Something went terribly wrong") @@ -514,7 +528,8 @@ class Mpegize: print("Message: %.0f%%" % ((100*i) / len(l))) sys.stdout.flush() base = n[:-4] - subprocess.run(['dcraw', + tiffname = m.tiffname(n) + subprocess.run([m.dcraw_bin, '-w', # -w Use camera white balance '+M', # +M use embedded color matrix '-H', '2', # -H 2 Recover highlights by blending them @@ -522,8 +537,8 @@ class Mpegize: '-q', '0', # -q 0 Debayer with fast bi-linear interpolation '-f', # -f Interpolate RGGB as four colors '-T', n]) # -T Output TIFF - subprocess.run(['convert', base+'.tiff', base+'.jpeg']) - os.unlink(base+'.tiff') + subprocess.run(['convert', tiffname, base+'.jpeg']) + os.unlink(tiffname) os.unlink(n) os.rename(base+'.jpeg', m.source+"/"+base+'.jpeg.sv')