RTP Video Tools - dcomp-leris/CGSynth GitHub Wiki

RTP Video Tools

End-to-end payload path through realistic network encapsulation.

Overview

  • 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.

Requirements

  • Python 3.6+
  • Scapy (pip install scapy)
  • FFmpeg installed and available on PATH

Install python deps:

pip install scapy

Packetizer (Frames → RTP PCAP)

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:

  1. Read PNG frames from a directory (e.g., server/<Game>/%04d.png)
  2. Encode them to H.264/H.265 using FFmpeg
  3. Packetize the encoded bitstream into RTP packets
  4. 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 or h265)
  • Timing: target FPS, RTP timestamp increment, optional jitter/pacing

Extractor (RTP PCAP → MP4)

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 or h265 (default h264)

Example:

python tools/rtp_pcap_to_video_extractor.py \
  --input rtp_stream_h264_fixed.pcap \
  --output extracted_video.mp4 \
  --codec h264

Validation checklist

  • 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.
⚠️ **GitHub.com Fallback** ⚠️