Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.stream.worker.StreamMuxer Class Reference

Public Member Functions

None __init__ (self, HomeAssistant hass, av.VideoStream video_stream, av.audio.AudioStream|None audio_stream, str|None audio_bsf, StreamState stream_state, StreamSettings stream_settings)
 
None check_flush_part (self, av.Packet packet)
 
None close (self)
 
None create_segment (self)
 
None flush (self, av.Packet packet, bool last_part)
 
tuple[ av.container.OutputContainer, av.VideoStream, av.audio.AudioStream|None,] make_new_av (self, BytesIO memory_file, int sequence, av.VideoStream input_vstream, av.audio.AudioStream|None input_astream)
 
None mux_packet (self, av.Packet packet)
 
None reset (self, int video_dts)
 

Private Attributes

 _audio_bsf
 
 _audio_bsf_context
 
 _hass
 
 _input_audio_stream
 
 _input_video_stream
 
 _memory_file
 
 _memory_file_pos
 
 _part_has_keyframe
 
 _part_start_dts
 
 _segment
 
 _segment_start_dts
 
 _start_time
 
 _stream_settings
 
 _stream_state
 

Detailed Description

StreamMuxer re-packages video/audio packets for output.

Definition at line 126 of file worker.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.components.stream.worker.StreamMuxer.__init__ (   self,
HomeAssistant  hass,
av.VideoStream  video_stream,
av.audio.AudioStream | None  audio_stream,
str | None  audio_bsf,
StreamState  stream_state,
StreamSettings  stream_settings 
)
Initialize StreamMuxer.

Definition at line 139 of file worker.py.

Member Function Documentation

◆ check_flush_part()

None homeassistant.components.stream.worker.StreamMuxer.check_flush_part (   self,
av.Packet  packet 
)
Check for and mark a part segment boundary and record its duration.

Definition at line 303 of file worker.py.

◆ close()

None homeassistant.components.stream.worker.StreamMuxer.close (   self)
Close stream buffer.

Definition at line 396 of file worker.py.

◆ create_segment()

None homeassistant.components.stream.worker.StreamMuxer.create_segment (   self)
Create a segment when the moov is ready.

Definition at line 289 of file worker.py.

◆ flush()

None homeassistant.components.stream.worker.StreamMuxer.flush (   self,
av.Packet  packet,
bool  last_part 
)
Output a part from the most recent bytes in the memory_file.

If last_part is True, also close the segment, give it a duration,
and clean up the av_output and memory_file.
There are two different ways to enter this function, and when
last_part is True, packet has not yet been muxed, while when
last_part is False, the packet has already been muxed. However,
in both cases, packet is the next packet and is not included in
the Part.
This function writes the duration metadata for the Part and
for the Segment. However, as the fragmentation done by ffmpeg
may result in fragment durations which fall outside the
[0.85x,1.0x] tolerance band allowed by LL-HLS, we need to fudge
some durations a bit by reporting them as being within that
range.
Note that repeated adjustments may cause drift between the part
durations in the metadata and those in the media and result in
playback issues in some clients.

Definition at line 317 of file worker.py.

◆ make_new_av()

tuple[ av.container.OutputContainer, av.VideoStream, av.audio.AudioStream | None, ] homeassistant.components.stream.worker.StreamMuxer.make_new_av (   self,
BytesIO  memory_file,
int  sequence,
av.VideoStream  input_vstream,
av.audio.AudioStream | None  input_astream 
)
Make a new av OutputContainer and add output streams.

Definition at line 159 of file worker.py.

◆ mux_packet()

None homeassistant.components.stream.worker.StreamMuxer.mux_packet (   self,
av.Packet  packet 
)
Mux a packet to the appropriate output stream.

Definition at line 260 of file worker.py.

◆ reset()

None homeassistant.components.stream.worker.StreamMuxer.reset (   self,
int  video_dts 
)
Initialize a new stream segment.

Definition at line 241 of file worker.py.

Member Data Documentation

◆ _audio_bsf

homeassistant.components.stream.worker.StreamMuxer._audio_bsf
private

Definition at line 152 of file worker.py.

◆ _audio_bsf_context

homeassistant.components.stream.worker.StreamMuxer._audio_bsf_context
private

Definition at line 235 of file worker.py.

◆ _hass

homeassistant.components.stream.worker.StreamMuxer._hass
private

Definition at line 149 of file worker.py.

◆ _input_audio_stream

homeassistant.components.stream.worker.StreamMuxer._input_audio_stream
private

Definition at line 151 of file worker.py.

◆ _input_video_stream

homeassistant.components.stream.worker.StreamMuxer._input_video_stream
private

Definition at line 150 of file worker.py.

◆ _memory_file

homeassistant.components.stream.worker.StreamMuxer._memory_file
private

Definition at line 245 of file worker.py.

◆ _memory_file_pos

homeassistant.components.stream.worker.StreamMuxer._memory_file_pos
private

Definition at line 246 of file worker.py.

◆ _part_has_keyframe

homeassistant.components.stream.worker.StreamMuxer._part_has_keyframe
private

Definition at line 154 of file worker.py.

◆ _part_start_dts

homeassistant.components.stream.worker.StreamMuxer._part_start_dts
private

Definition at line 243 of file worker.py.

◆ _segment

homeassistant.components.stream.worker.StreamMuxer._segment
private

Definition at line 244 of file worker.py.

◆ _segment_start_dts

homeassistant.components.stream.worker.StreamMuxer._segment_start_dts
private

Definition at line 243 of file worker.py.

◆ _start_time

homeassistant.components.stream.worker.StreamMuxer._start_time
private

Definition at line 157 of file worker.py.

◆ _stream_settings

homeassistant.components.stream.worker.StreamMuxer._stream_settings
private

Definition at line 155 of file worker.py.

◆ _stream_state

homeassistant.components.stream.worker.StreamMuxer._stream_state
private

Definition at line 156 of file worker.py.


The documentation for this class was generated from the following file: