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:
parent
463516f48f
commit
e7f51477d8
1 changed files with 0 additions and 7 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue