WIP code for piping images into ffmpeg (subprocess.Popen)

pull/357/head
nyanpasu64 2018-07-22 00:38:20 -07:00
rodzic 054ba642eb
commit 4b91be9120
3 zmienionych plików z 31 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,31 @@
import glob
import shlex
import subprocess
templates = ['ffplay -autoexit -f image2pipe -framerate 60 -i -']
args = [arg
for template in templates
for arg in shlex.split(template)]
popen = subprocess.Popen(args, stdin=subprocess.PIPE)
stream = popen.stdin
imgs = glob.glob('images/*.png')
imgs.sort()
for img in imgs * 100:
with open(img, 'rb') as f:
stream.write(f.read()) # FIXME https://docs.python.org/3/library/subprocess.html#subprocess.Popen.stdin
# Warning: Use communicate() rather than .stdin.write, .stdout.read or .stderr.read
# to avoid deadlocks due to any of the other OS pipe buffers filling up and blocking
# the child process.
# communicate(): Interact with process: Send data to stdin. Read data from stdout and
# stderr, until end-of-file is reached.
# nope instant reject
# https://stackoverflow.com/questions/9886654/difference-between-communicate-and-stdin-write-stdout-read-or-stderr-read
stream.close()
popen.wait()

BIN
tests/images/0.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 298 B

BIN
tests/images/1.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 266 B