33 lines
947 B
Python
Executable File
33 lines
947 B
Python
Executable File
#!/usr/bin/env python3
|
|
from pathlib import Path
|
|
from thermaldecoder import decode
|
|
import numpy as np
|
|
import subprocess
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
# Create a directory to store the frames if it doesn't exist
|
|
root = Path('frames')
|
|
root.mkdir(exist_ok=True)
|
|
|
|
# Decode the frames from the pcap file
|
|
frames = list(decode('indesk.pcapng'))
|
|
|
|
# Iterate over the frames
|
|
for i, frame in enumerate(frames):
|
|
try:
|
|
# Convert the frame to an image file
|
|
img_path = root / f"frame_{i}.png"
|
|
f = np.array(frame)
|
|
f.shape = (384, 288)
|
|
plt.imshow(f)
|
|
plt.axis('off')
|
|
plt.savefig(img_path, bbox_inches='tight', pad_inches=0)
|
|
plt.close()
|
|
|
|
# Use ffmpeg to display the image
|
|
subprocess.run(['ffmpeg', '-i', str(img_path), '-vf', 'scale=800:600', '-framerate', '25', '-f', 'image2pipe', '-'], check=True)
|
|
|
|
except ValueError as e:
|
|
print(f"Error processing frame {i}: {e}")
|