pkt2vid
is a command-line tool for extracting MJPEG frames from a PCAP file and converting them into a video using ffmpeg
. It's designed for network forensics, reverse engineering, and multimedia recovery from packet captures.
- Extracts JPEG frames from TCP MJPEG streams.
- Automatically reconstructs video with
ffmpeg
. - CLI interface with options for FPS and output filename.
- Built with Python and Scapy.
To install the required Python packages, use:
git clone https://github.com/l0n3m4n/pkt2vid.git && cd pkt2vid
python3 -m venv venv-pkt2vid
source venv-pkt2vid/bin/activate
pip install scapy
apt install ffmpeg
~> python3 pkt2vid.py -h
__________ __ __ ________ .__ .___
\______ \ | ___/ |_\_____ \___ _|__| __| _/
| ___/ |/ /\ __\/ ____/\ \/ / |/ __ |
| | | < | | / \ \ /| / /_/ |
|____| |__|_ \ |__| \_______ \ \_/ |__\____ |
\/ \/ \/
Author: l0n3m4n Version: v1.0.0
usage: pkt2vid.py [-h] [-f FPS] [-o OUTPUT] [pcap]
📦 Extract MJPEG frames from a PCAP file and create a video using FFmpeg.
positional arguments:
pcap Path to the PCAP file to process (default: rec.pcap)
options:
-h, --help show this help message and exit
-f FPS, --fps FPS Frames per second for output video (default: 10)
-o OUTPUT, --output OUTPUT
Output video filename (default: output_video.mp4)
Example: python3 rec.py capture.pcap -f 15 -o output.mp4
> python3 pkt2vid.py assets/example.pcap -f 15 -o output.mp4
__________ __ __ ________ .__ .___
\______ \ | ___/ |_\_____ \___ _|__| __| _/
| ___/ |/ /\ __\/ ____/\ \/ / |/ __ |
| | | < | | / \ \ /| / /_/ |
|____| |__|_ \ |__| \_______ \ \_/ |__\____ |
\/ \/ \/
Author: l0n3m4n Version: v1.0.0
✅ Saved frame 0
✅ Saved frame 1
✅ Saved frame 2
...
...
✅ Saved frame 537
✅ Saved frame 538
✅ Saved frame 539
🎉 Extraction complete: 540 frames saved.
ffmpeg version 7.1.1-1+b1 Copyright (c) 2000-2025 the FFmpeg developers
built with gcc 14 (Debian 14.2.0-19)
...
...
libavformat 61. 7.100 / 61. 7.100
libavdevice 61. 3.100 / 61. 3.100
libavfilter 10. 4.100 / 10. 4.100
libswscale 8. 3.100 / 8. 3.100
libswresample 5. 3.100 / 5. 3.100
libpostproc 58. 3.100 / 58. 3.100
Input #0, image2, from 'frames/frame_%04d.jpg':
Duration: 00:00:36.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 640x480 [SAR 1:1 DAR 4:3], 15 fps, 15 tbr, 15 tbn
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
...
...
[libx264 @ 0x558c43a31d80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 64% 24% 7% 1% 1% 1% 1% 1% 1%
[libx264 @ 0x558c43a31d80] i8c dc,h,v,p: 53% 23% 22% 2%
[libx264 @ 0x558c43a31d80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x558c43a31d80] ref P L0: 48.2% 2.7% 22.9% 26.2%
[libx264 @ 0x558c43a31d80] ref B L0: 65.3% 23.5% 11.2%
[libx264 @ 0x558c43a31d80] ref B L1: 87.9% 12.1%
[libx264 @ 0x558c43a31d80] kb/s:521.90
🎞️ Video created: output.mp4