aboutsummaryrefslogtreecommitdiff
path: root/encoder.py
diff options
context:
space:
mode:
Diffstat (limited to 'encoder.py')
-rw-r--r--encoder.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/encoder.py b/encoder.py
index 38d89cb..d71990d 100644
--- a/encoder.py
+++ b/encoder.py
@@ -29,7 +29,7 @@ with open(args.input, "rb") as f:
data = f.read()
rsc = RSCodec(int(args.level * 255))
encoder = Encoder.with_defaults(data, rs_bytes)
-packets = encoder.get_encoded_packets(int(len(data) / rs_bytes * (1 / (1 - args.level) - 1)))
+packets = encoder.get_encoded_packets(int(len(data) / rs_bytes))
# Make corners
ones = np.ones((cheight - 1, cwidth - 1))
@@ -51,7 +51,7 @@ def mkframe(packet):
frame[:reshape_len] = np.ravel(frame[:reshape_len].reshape(reshape_len // 255, 255), "F")
frame = np.unpackbits(frame)
# Pad to be multiple of 3 so we can reshape into RGB channels
- frame = np.pad(frame, (0, (3 - len(frame)) % 3))
+ frame = np.pad(frame, (0, 3 * frame_size - len(frame)))
frame = np.reshape(frame, (frame_size, 3))
frame = np.concatenate(
(
@@ -90,7 +90,7 @@ if args.mix:
vidframe[hscale * (args.height - cheight) :, wscale * (args.width - cwidth) :] = 0
frame = np.repeat(np.repeat(mkframe(packets[i]), hscale, 0), wscale, 1)
# Set edges in original video to black
- frame[vidframe % 255 != 0] = 0
+ frame[(32 <= vidframe) & (vidframe < 224)] = 0
out.write(cv2.cvtColor(frame, cv2.COLOR_RGB2BGR))
i = (i + 1) % len(packets)
else: