|
@@ -89,7 +89,7 @@ def extract_image(path):
|
|
|
byte |= 1 << ((r >> 2) & 1)
|
|
|
byte |= 1 << ((r >> 2) & 1)
|
|
|
|
|
|
- data.append(byte & 255)
|
|
|
+ data.append(byte)
|
|
|
|
|
|
return bytes(data)
|
|
|
|
|
@@ -115,7 +115,9 @@ def extract_video(path):
|
|
|
)
|
|
|
|
|
|
data = b""
|
|
|
- for filename in sorted(os.listdir(tmpd), key=lambda filename: int(filename.split(".")[0])):
|
|
|
+ for filename in sorted(
|
|
|
+ os.listdir(tmpd), key=lambda filename: int(filename.split(".")[0])
|
|
|
+ ):
|
|
|
data += extract_image(os.path.join(tmpd, filename))
|
|
|
|
|
|
return data
|
|
@@ -129,13 +131,16 @@ def extract_lsbs(data):
|
|
|
if len(data) % 2 != 0:
|
|
|
data = data[:-1]
|
|
|
|
|
|
- for chunk in chunks(data, 2):
|
|
|
+ for chunk in chunks(data, 4):
|
|
|
+ if len(chunk) != 4:
|
|
|
+ break
|
|
|
+
|
|
|
tmp_byte = 0
|
|
|
for byte in chunk:
|
|
|
- for n in range(4):
|
|
|
+ for n in range(2):
|
|
|
tmp_byte |= 1 << ((byte >> n) & 1)
|
|
|
|
|
|
- buffer.append(tmp_byte & 255)
|
|
|
+ buffer.append(tmp_byte)
|
|
|
|
|
|
return bytes(buffer)
|
|
|
|
|
@@ -163,6 +168,10 @@ def read_video(source, duration=60):
|
|
|
return extract_video(tmpf.name)
|
|
|
|
|
|
|
|
|
+def read_video2(source, _):
|
|
|
+ raise NotImplementedError
|
|
|
+
|
|
|
+
|
|
|
def read_audio(source, duration=60):
|
|
|
tmpf = NamedTemporaryFile(suffix=".wav", mode=None, dir=tmp_dir)
|
|
|
|
|
@@ -207,6 +216,9 @@ def sample(source, source_type, multiplier=1):
|
|
|
sampler = read_video
|
|
|
multiplier *= 60
|
|
|
|
|
|
+ case "video2":
|
|
|
+ sampler = read_video2
|
|
|
+
|
|
|
case "audio":
|
|
|
sampler = read_audio
|
|
|
multiplier *= 60
|