H.264 Video¶
H.264 (AVC) compressed video for bandwidth-efficient streaming.
Overview¶
H.264 provides significant bandwidth reduction compared to uncompressed video, making it suitable for:
- Network-constrained environments
- Recording and storage
- Wide device compatibility
Native VAAPI Backend¶
MediaX uses native VAAPI for H.264 encoding and decoding, providing:
- Hardware acceleration support (Intel, AMD)
- Direct libva integration
- Low-latency encode/decode pipeline
Hardware Acceleration Options¶
| Backend | Platform | GPU/Device |
|---|---|---|
| VAAPI | Linux | Intel (6th gen+), AMD (GCN 3+) |
Transmitting H.264 Video¶
#include "h264/vaapi/rtp_h264_vaapi_payloader.h"
mediax::rtp::h264::vaapi::RtpH264VaapiPayloader payloader;
mediax::rtp::StreamInformation stream_info;
stream_info.session_name = "h264-stream";
stream_info.hostname = "239.192.1.1";
stream_info.port = 5004;
stream_info.width = 1920;
stream_info.height = 1080;
stream_info.framerate = 30;
stream_info.encoding = mediax::rtp::ColourspaceType::kColourspaceH264Part10;
payloader.SetStreamInfo(stream_info);
payloader.Open();
// Send RGB24 frames - encoder handles conversion and compression
std::vector<uint8_t> rgb_buffer(1920 * 1080 * 3);
// Fill buffer with video frame...
payloader.Transmit(rgb_buffer.data(), true);
payloader.Close();
Receiving H.264 Video¶
#include "h264/vaapi/rtp_h264_vaapi_depayloader.h"
mediax::rtp::h264::vaapi::RtpH264VaapiDepayloader depayloader;
mediax::rtp::StreamInformation stream_info;
stream_info.hostname = "239.192.1.1";
stream_info.port = 5004;
stream_info.width = 1920;
stream_info.height = 1080;
stream_info.encoding = mediax::rtp::ColourspaceType::kColourspaceH264Part10;
depayloader.SetStreamInfo(stream_info);
depayloader.Open();
depayloader.Start();
// Receive decoded RGB frames
std::vector<uint8_t> rgb_buffer(1920 * 1080 * 3);
depayloader.Receive(rgb_buffer.data(), 1000);
depayloader.Stop();
depayloader.Close();
Encoder Settings¶
Quality vs Speed Trade-offs¶
// These can be configured before Open()
// Higher bitrate = better quality, more bandwidth
// Lower bitrate = lower quality, less bandwidth
Typical Bandwidth Requirements¶
| Resolution | Quality | Approximate Bitrate |
|---|---|---|
| 640x480 | Good | 1-2 Mbps |
| 1280x720 | Good | 3-5 Mbps |
| 1920x1080 | Good | 6-10 Mbps |
| 1920x1080 | High | 15-25 Mbps |
| 3840x2160 | Good | 25-35 Mbps |
RTP Payload Format¶
MediaX implements RFC 6184 for H.264 RTP payload format:
- Packetization modes supported: Single NAL, Non-interleaved
- SPS/PPS in-band signaling
- FU-A fragmentation for large NAL units
VAAPI Setup¶
For Intel or AMD hardware acceleration on Linux:
# Ubuntu/Debian
sudo apt install libva-dev intel-media-va-driver
# Verify VAAPI support
vainfo
Troubleshooting¶
No Hardware Acceleration¶
If software encoding is used instead of hardware:
- Check driver installation
- Verify VAAPI support:
bash
vainfo
High Latency¶
H.264 introduces encoding/decoding latency:
- Use low-latency encoder presets when available
- Consider uncompressed video for lowest latency
Support¶
- Website: https://astutesys.com/support
- Email: support@astutesys.com