Skip to content

Commit 40d3d64

Browse files
authored
Fix recording duration flag (#34648)
1 parent 77443b3 commit 40d3d64

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

homeassistant/components/stream/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"domain": "stream",
33
"name": "Stream",
44
"documentation": "https://www.home-assistant.io/integrations/stream",
5-
"requirements": ["av==6.1.2"],
5+
"requirements": ["av==7.0.1"],
66
"dependencies": ["http"],
77
"codeowners": ["@hunterjm"],
88
"quality_scale": "internal"

homeassistant/components/stream/recorder.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def async_setup_recorder(hass):
1717

1818
def recorder_save_worker(file_out: str, segments: List[Segment]):
1919
"""Handle saving stream."""
20-
output = av.open(file_out, "w", options={"movflags": "frag_keyframe"})
20+
first_pts = None
21+
output = av.open(file_out, "w")
2122
output_v = None
2223

2324
for segment in segments:
@@ -29,13 +30,22 @@ def recorder_save_worker(file_out: str, segments: List[Segment]):
2930
# Add output streams
3031
if not output_v:
3132
output_v = output.add_stream(template=source_v)
33+
context = output_v.codec_context
34+
context.flags |= "GLOBAL_HEADER"
3235

3336
# Remux video
3437
for packet in source.demux(source_v):
3538
if packet is not None and packet.dts is not None:
39+
if first_pts is None:
40+
first_pts = packet.pts
41+
42+
packet.pts -= first_pts
43+
packet.dts -= first_pts
3644
packet.stream = output_v
3745
output.mux(packet)
3846

47+
source.close()
48+
3949
output.close()
4050

4151

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ atenpdu==0.3.0
282282
aurorapy==0.2.6
283283

284284
# homeassistant.components.stream
285-
av==6.1.2
285+
av==7.0.1
286286

287287
# homeassistant.components.avea
288288
avea==1.4

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ arcam-fmj==0.4.3
126126
async-upnp-client==0.14.13
127127

128128
# homeassistant.components.stream
129-
av==6.1.2
129+
av==7.0.1
130130

131131
# homeassistant.components.axis
132132
axis==25

0 commit comments

Comments
 (0)