RTP Video Tools - dcomp-leris/CGSynth GitHub Wiki
End-to-end payload path through realistic network encapsulation.
-
tools/rtp_video_packetizer.py
: Converts a series of PNG images into an H.264/H.265 stream, packetizes over RTP, and writes a PCAP. -
tools/rtp_pcap_to_video_extractor.py
: Reconstructs H.264/H.265 elementary stream from RTP in a PCAP and remuxes/encodes to MP4.
- Python 3.6+
- Scapy (
pip install scapy
) - FFmpeg installed and available on PATH
Install python deps:
pip install scapy
Usage:
# From repository root
python tools/rtp_video_packetizer.py
# Configure input frame directory, codec, IPs/ports, and output PCAP inside the script
This script will:
- Read PNG frames from a directory (e.g.,
server/<Game>/%04d.png
) - Encode them to H.264/H.265 using FFmpeg
- Packetize the encoded bitstream into RTP packets
- Save the packets into a PCAP file
Configuration (inside the script):
- Image source directory
- Output PCAP filename
- Network parameters (
src_ip
,dst_ip
,src_port
,dst_port
, SSRC) - Video codec (
h264
orh265
) - Timing: target FPS, RTP timestamp increment, optional jitter/pacing
Usage:
python tools/rtp_pcap_to_video_extractor.py \
--input input_pcap.pcap \
--output output.mp4 \
--codec h264
Arguments:
-
--input
: PCAP path -
--output
: MP4 path (default:output.mp4
) -
--codec
:h264
orh265
(defaulth264
)
Example:
python tools/rtp_pcap_to_video_extractor.py \
--input rtp_stream_h264_fixed.pcap \
--output extracted_video.mp4 \
--codec h264
- Inspect PCAP with Wireshark; verify RTP payload type and timestamp increments at 90kHz clock (for H.264/H.265).
- Confirm sequence numbers increment and SSRC remains stable.
- If payload appears fragmented incorrectly, ensure FFmpeg packaging and MTU assumptions align.
- For heavy packet loss PCAPs, the output may be playable with visual artifacts—pair with the degradation simulator to study controlled impairments.