savant_rs.gstreamer
- class savant_rs.gstreamer.Codec
Python enum for video codecs.
H264— H.264 / AVC.HEVC— H.265 / HEVC.JPEG— Motion JPEG.AV1— AV1.PNG— PNG (CPU-based, lossless).
- AV1 = Codec.AV1
- H264 = Codec.H264
- HEVC = Codec.HEVC
- JPEG = Codec.JPEG
- PNG = Codec.PNG
- static from_name(name)
Parse a codec from a string name.
Accepted names (case-insensitive):
h264,hevc,h265,jpeg,av1,png.- Parameters:
name (str) – Codec name.
- Returns:
The parsed codec.
- Return type:
- Raises:
ValueError – If the name is not recognized.
- name()
Return the canonical name of this codec.
- class savant_rs.gstreamer.FlowResult
- CustomError = FlowResult.CustomError
- CustomError1 = FlowResult.CustomError1
- CustomError2 = FlowResult.CustomError2
- CustomSuccess = FlowResult.CustomSuccess
- CustomSuccess1 = FlowResult.CustomSuccess1
- CustomSuccess2 = FlowResult.CustomSuccess2
- Eos = FlowResult.Eos
- Error = FlowResult.Error
- Flushing = FlowResult.Flushing
- NotLinked = FlowResult.NotLinked
- NotNegotiated = FlowResult.NotNegotiated
- NotSupported = FlowResult.NotSupported
- Ok = FlowResult.Ok
- class savant_rs.gstreamer.InvocationReason
- Buffer = InvocationReason.Buffer
- IngressMessageTransformer = InvocationReason.IngressMessageTransformer
- SinkEvent = InvocationReason.SinkEvent
- SourceEvent = InvocationReason.SourceEvent
- StateChange = InvocationReason.StateChange
- class savant_rs.gstreamer.Mp4Muxer(codec, output_path, fps_num=30, fps_den=1)
Minimal GStreamer pipeline:
appsrc -> parser -> qtmux -> filesink.Accepts raw encoded frames (H.264, HEVC, JPEG, AV1) and writes them into an MP4 (QuickTime) container.
- Parameters:
Example:
from savant_rs.gstreamer import Mp4Muxer, Codec muxer = Mp4Muxer(Codec.HEVC, "/tmp/out.mp4", fps_num=30) muxer.push(b"\\x00\\x00\\x00\\x01...", pts_ns=0, dts_ns=0, duration_ns=33_333_333) muxer.finish()
- finish()
Send EOS and shut down the muxer pipeline.
Safe to call multiple times. After this call,
push()will raise.
- is_finished
Whether the muxer has been finalized.
- push(data, pts_ns, dts_ns=None, duration_ns=None)
Push an encoded frame into the muxer pipeline.
- Parameters:
data (bytes) – Raw encoded bitstream for a single frame.
pts_ns (int) – Presentation timestamp in nanoseconds.
dts_ns (int | None) – Optional decode timestamp in nanoseconds. Required for streams with B-frames where DTS != PTS.
duration_ns (int | None) – Optional frame duration in nanoseconds.
- Raises:
RuntimeError – On push failure or if the muxer has been finalized.