Refactor av.open calls to support type annotations (#129688)

This commit is contained in:
Marc Mueller 2024-11-02 19:03:32 +01:00 committed by GitHub
parent bf4922a7ef
commit f7103da818
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 60 additions and 60 deletions

View File

@ -105,17 +105,16 @@ class RecorderOutput(StreamOutput):
# Create output on first segment
if not output:
container_options: dict[str, str] = {
"video_track_timescale": str(int(1 / source_v.time_base)),
"movflags": "frag_keyframe+empty_moov",
"min_frag_duration": str(self.stream_settings.min_segment_duration),
}
output = av.open(
self.video_path + ".tmp",
"w",
format=RECORDER_CONTAINER_FORMAT,
container_options={
"video_track_timescale": str(int(1 / source_v.time_base)),
"movflags": "frag_keyframe+empty_moov",
"min_frag_duration": str(
self.stream_settings.min_segment_duration
),
},
container_options=container_options,
)
# Add output streams if necessary

View File

@ -164,11 +164,7 @@ class StreamMuxer:
av.audio.stream.AudioStream | None,
]:
"""Make a new av OutputContainer and add output streams."""
container = av.open(
memory_file,
mode="w",
format=SEGMENT_CONTAINER_FORMAT,
container_options={
container_options: dict[str, str] = {
# Removed skip_sidx - see:
# https://github.com/home-assistant/core/pull/39970
# "cmaf" flag replaces several of the movflags used,
@ -220,7 +216,12 @@ class StreamMuxer:
if self._stream_settings.ll_hls
else {}
),
},
}
container = av.open(
memory_file,
mode="w",
format=SEGMENT_CONTAINER_FORMAT,
container_options=container_options,
)
output_vstream = container.add_stream(template=input_vstream)
# Check if audio is requested