[postprocessor:ugoira] optimize writing ffconcat files
collect all content in-memory first and write everything with a single 'write()'
This commit is contained in:
@@ -117,15 +117,19 @@ class UgoiraPP(PostProcessor):
|
|||||||
pathfmt.set_extension("zip")
|
pathfmt.set_extension("zip")
|
||||||
|
|
||||||
def _concat(self, path):
|
def _concat(self, path):
|
||||||
# write ffconcat file
|
|
||||||
ffconcat = path + "/ffconcat.txt"
|
ffconcat = path + "/ffconcat.txt"
|
||||||
|
|
||||||
|
content = ["ffconcat version 1.0"]
|
||||||
|
append = content.append
|
||||||
|
for frame in self._frames:
|
||||||
|
append("file '{}'\nduration {}".format(
|
||||||
|
frame["file"], frame["delay"] / 1000))
|
||||||
|
if self.repeat:
|
||||||
|
append("file '{}'".format(frame["file"]))
|
||||||
|
append("")
|
||||||
|
|
||||||
with open(ffconcat, "w") as file:
|
with open(ffconcat, "w") as file:
|
||||||
file.write("ffconcat version 1.0\n")
|
file.write("\n".join(content))
|
||||||
for frame in self._frames:
|
|
||||||
file.write("file '{}'\n".format(frame["file"]))
|
|
||||||
file.write("duration {}\n".format(frame["delay"] / 1000))
|
|
||||||
if self.repeat:
|
|
||||||
file.write("file '{}'\n".format(frame["file"]))
|
|
||||||
|
|
||||||
rate_in, rate_out = self.calculate_framerate(self._frames)
|
rate_in, rate_out = self.calculate_framerate(self._frames)
|
||||||
args = [self.ffmpeg, "-f", "concat"]
|
args = [self.ffmpeg, "-f", "concat"]
|
||||||
|
|||||||
Reference in New Issue
Block a user