From e7f51477d847793432b2410d74a9784d06a0eaf0 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Fri, 26 Jul 2024 14:10:08 -0500 Subject: Don't skip frames when decoding This increases bandwidth since we don't have to resync after failing to decode a frame, but at the cost of higher CPU usage --- decoder.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/decoder.py b/decoder.py index 5b3178c..8166382 100644 --- a/decoder.py +++ b/decoder.py @@ -48,7 +48,6 @@ if isinstance(args.input, str) and args.input.isdecimal(): cap = cv2.VideoCapture(args.input) data = None start_time = 0 -status = 0 decoded = 0 while data is None: try: @@ -56,10 +55,6 @@ while data is None: if not ret: print("End of stream") break - if isinstance(args.input, int) and (status == 1 or (status == 0 and np.random.rand() < 0.5)): - status = 2 - print("Skipped") - continue # raw_frame is a uint8 BE CAREFUL cv2.imshow("", raw_frame) cv2.waitKey(1) @@ -113,14 +108,12 @@ while data is None: frame[:reshape_len] = np.ravel(frame[:reshape_len].reshape(255, reshape_len // 255), "F") data = decoder.decode(bytes(rsc.decode(bytearray(frame ^ frame_xor))[0][: args.psize])) decoded += 1 - status = 1 if start_time == 0: start_time = time.time() print("Decoded frame") except KeyboardInterrupt: break except Exception as e: - status = 0 print(e) cap.release() print(decoded) -- cgit v1.2.3-70-g09d2