2023-12-29 17:33:10 +02:00
|
|
|
#!/usr/bin/env python3
|
2023-12-29 17:05:44 +02:00
|
|
|
from pathlib import Path
|
|
|
|
from thermaldecoder import decode
|
|
|
|
import numpy as np
|
2024-02-15 00:26:10 +02:00
|
|
|
import subprocess
|
2023-12-29 17:05:44 +02:00
|
|
|
import matplotlib.pyplot as plt
|
2024-02-15 00:26:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Create a directory to store the frames if it doesn't exist
|
2023-12-29 17:05:44 +02:00
|
|
|
root = Path('frames')
|
|
|
|
root.mkdir(exist_ok=True)
|
2024-02-15 00:26:10 +02:00
|
|
|
|
|
|
|
# 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}")
|