From fccc2ba2e5799481579181755420bf899e3b8c1c Mon Sep 17 00:00:00 2001 From: devdesk Date: Thu, 15 Feb 2024 00:27:48 +0200 Subject: [PATCH] almost live, but horrible hack for stream capture, and not live ffmpeg, just live save of images --- decode.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/decode.py b/decode.py index f2b6a2f..7bacb89 100644 --- a/decode.py +++ b/decode.py @@ -165,13 +165,18 @@ if not args.live: print("to play: ffplay thermal.mp4") else: - output = 'to_ffmpeg' - # live: write to named pipe - if not Path(output).exists(): - print(f'making fifo at {output}') - os.mkfifo(output) - fd = open(output, 'wb') - for i, frame in enumerate(frames): - print(f'frame {i:3}') - Image.fromarray(np.frombuffer(frame, dtype='>H').reshape(WIDTH, HEIGHT)).save(f'test_{i:04}.png') - fd.write(frame) + # TODO: to video via ffmpeg; right now just a single png + # of the last frame + def todo_live_ffmpeg(): + output = 'to_ffmpeg' + # live: write to named pipe + if not Path(output).exists(): + print(f'making fifo at {output}') + os.mkfifo(output) + fd = open(output, 'wb') + for frame in frames: + fd.write(frame) + + for frame in frames: + print('.') + Image.fromarray(np.frombuffer(frame, dtype='>H').reshape(WIDTH, HEIGHT)).save(f'live.png')