Skip to content

Commit

Permalink
Fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Nov 2, 2024
1 parent 003e846 commit 19ae44e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions homeassistant/components/stream/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
)

if TYPE_CHECKING:
from av import Packet
from av.video.codeccontext import VideoCodecContext
from av import Packet, VideoCodecContext

from homeassistant.components.camera import DynamicStreamSettings

Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/stream/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ def write_segment(segment: Segment) -> None:

# Remux video
for packet in source.demux():
if packet.dts is None:
if packet.pts is None:
continue
packet.pts += pts_adjuster[packet.stream.type] # type: ignore[operator]
packet.dts += pts_adjuster[packet.stream.type] # type: ignore[operator]
packet.stream = output_v if packet.stream.type == "video" else output_a
stream = output_v if packet.stream.type == "video" else output_a
assert stream
packet.stream = stream
output.mux(packet)

running_duration += source.duration - source.start_time
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/stream/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class StreamWorkerError(Exception):
def redact_av_error_string(err: av.FFmpegError) -> str:
"""Return an error string with credentials redacted from the url."""
parts = [str(err.type), err.strerror] # type: ignore[attr-defined]
if err.filename is not None:
if err.filename:
parts.append(redact_credentials(err.filename))
return ", ".join(parts)

Expand Down Expand Up @@ -135,7 +135,7 @@ class StreamMuxer:
_segment: Segment | None
# the following 2 member variables are used for Part formation
_memory_file_pos: int
_part_start_dts: int
_part_start_dts: float

def __init__(
self,
Expand Down Expand Up @@ -278,6 +278,7 @@ def mux_packet(self, packet: av.Packet) -> None:
self._part_has_keyframe |= packet.is_keyframe

elif packet.stream == self._input_audio_stream:
assert self._output_audio_stream
if self._audio_bsf_context:
for audio_packet in self._audio_bsf_context.filter(packet):
audio_packet.stream = self._output_audio_stream
Expand Down

0 comments on commit 19ae44e

Please sign in to comment.