Available on crate feature
std only.Expand description
Streaming TS packet framing over any std::io::Read.
PacketReader turns a byte stream into its 188-byte transport-stream
packets, resynchronising through TsResync as
the stream arrives, so a multi-gigabyte capture is framed in bounded
memory instead of being read whole.
use std::fs::File;
use std::num::NonZeroUsize;
use mpeg_ts::reader::PacketReader;
use mpeg_ts::resync::{PacketStride, ResyncConfig, Unlocked};
let mut packets = PacketReader::new(File::open("capture.ts")?, NonZeroUsize::new(1 << 20).unwrap(), ResyncConfig::new(NonZeroUsize::new(5).unwrap(), &PacketStride::ALL, Unlocked::KeepWindow));
while let Some(packet) = packets.next() {
let packet = packet?;
// one aligned 188-byte TS packet
let _ = packet.len();
}Structsยง
- Packet
Reader - The aligned 188-byte packets of a byte stream, read in bounded chunks.