[postprocessor:ugoira] add a few options
- ffmpeg-location: path to the ffmpeg (or avconv) executable - ffmpeg-args: additional command line args for ffmpeg - extension: filename extension of the resulting video file
This commit is contained in:
@@ -18,6 +18,9 @@ class UgoiraPP(PostProcessor):
|
|||||||
|
|
||||||
def __init__(self, pathfmt, options):
|
def __init__(self, pathfmt, options):
|
||||||
PostProcessor.__init__(self)
|
PostProcessor.__init__(self)
|
||||||
|
self.extension = options.get("extension") or "webm"
|
||||||
|
self.ffmpeg = options.get("ffmpeg-location") or "ffmpeg"
|
||||||
|
self.args = options.get("ffmpeg-args")
|
||||||
|
|
||||||
def run(self, pathfmt):
|
def run(self, pathfmt):
|
||||||
if pathfmt.keywords["extension"] != "txt":
|
if pathfmt.keywords["extension"] != "txt":
|
||||||
@@ -30,8 +33,8 @@ class UgoiraPP(PostProcessor):
|
|||||||
for line in file:
|
for line in file:
|
||||||
name, _, duration = line.partition(" ")
|
name, _, duration = line.partition(" ")
|
||||||
framelist.append((name, int(duration.rstrip())))
|
framelist.append((name, int(duration.rstrip())))
|
||||||
# list the last frame twice to prevent it from only being
|
# add the last frame twice to prevent it from only being
|
||||||
# displayed for a very short time
|
# displayed for a very short amount of time
|
||||||
framelist.append((name, int(duration.rstrip())))
|
framelist.append((name, int(duration.rstrip())))
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tempdir:
|
with tempfile.TemporaryDirectory() as tempdir:
|
||||||
@@ -49,8 +52,11 @@ class UgoiraPP(PostProcessor):
|
|||||||
file.write("duration {}\n".format(duration / 1000))
|
file.write("duration {}\n".format(duration / 1000))
|
||||||
|
|
||||||
# invoke ffmpeg
|
# invoke ffmpeg
|
||||||
pathfmt.set_extension("webm")
|
pathfmt.set_extension(self.extension)
|
||||||
args = ["ffmpeg", "-i", ffconcat, pathfmt.realpath]
|
args = [self.ffmpeg, "-i", ffconcat]
|
||||||
|
if self.args:
|
||||||
|
args += self.args
|
||||||
|
args.append(pathfmt.realpath)
|
||||||
subprocess.Popen(args).wait()
|
subprocess.Popen(args).wait()
|
||||||
|
|
||||||
# mark framelist file for deletion
|
# mark framelist file for deletion
|
||||||
|
|||||||
Reference in New Issue
Block a user