Browse Source

pipeline: move ffmpeg to background process and allow for main thread runner

master
Shiz 1 year ago
parent
commit
5d0889e85e
2 changed files with 27 additions and 6 deletions
  1. +3
    -3
      src/overlay/__main__.py
  2. +24
    -3
      src/overlay/filters.py

+ 3
- 3
src/overlay/__main__.py View File

@ -31,7 +31,7 @@ graph = scene.to_ffmpeg()
graph.fixup()
ffmpeg_args = graph.format()
# Launch background runners
# Launch render process
subprocess.Popen(['ffmpeg'] + ffmpeg_args + args.args)
# Launch graph
graph.run()
# Launch main process
subprocess.run(['ffmpeg'] + ffmpeg_args + args.args)

+ 24
- 3
src/overlay/filters.py View File

@ -1,3 +1,4 @@
import os
import threading
@ -81,9 +82,20 @@ class FFmpegChain:
return ', '.join(str(f) for f in self.filters)
def run(self):
main = None
for r in self.runners:
t = threading.Thread(target=r, daemon=True)
t.start()
if isinstance(r, tuple):
r, is_main = r
else:
is_main = False
if is_main:
if main:
raise ValueError("can not have multiple main threads")
main = r
else:
t = threading.Thread(target=r, daemon=True)
t.start()
return main
class FFmpegGraph:
def __init__(self, *chains):
@ -121,5 +133,14 @@ class FFmpegGraph:
return args
def run(self):
main = None
for c in self.chains:
c.run()
c_main = c.run()
if c_main:
if main:
raise ValueError("can not have multiple main threads")
main = c_main
if main:
main()
else:
os.wait()

Loading…
Cancel
Save