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
This commit is contained in:
Anthony Wang 2024-07-26 14:10:08 -05:00
parent 463516f48f
commit e7f51477d8
Signed by: a
SSH key fingerprint: SHA256:B5ADfMCqd2M7d/jtXDoihAV/yfXOAbWWri9+GdCN4hQ

View file

@ -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)