Fix recording duration flag (#34648)

pull/34668/head
Jason Hunter 2020-04-24 17:18:58 -04:00 committed by GitHub
parent 77443b3d09
commit 40d3d64027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View File

@ -2,7 +2,7 @@
"domain": "stream",
"name": "Stream",
"documentation": "https://www.home-assistant.io/integrations/stream",
"requirements": ["av==6.1.2"],
"requirements": ["av==7.0.1"],
"dependencies": ["http"],
"codeowners": ["@hunterjm"],
"quality_scale": "internal"

View File

@ -17,7 +17,8 @@ def async_setup_recorder(hass):
def recorder_save_worker(file_out: str, segments: List[Segment]):
"""Handle saving stream."""
output = av.open(file_out, "w", options={"movflags": "frag_keyframe"})
first_pts = None
output = av.open(file_out, "w")
output_v = None
for segment in segments:
@ -29,13 +30,22 @@ def recorder_save_worker(file_out: str, segments: List[Segment]):
# Add output streams
if not output_v:
output_v = output.add_stream(template=source_v)
context = output_v.codec_context
context.flags |= "GLOBAL_HEADER"
# Remux video
for packet in source.demux(source_v):
if packet is not None and packet.dts is not None:
if first_pts is None:
first_pts = packet.pts
packet.pts -= first_pts
packet.dts -= first_pts
packet.stream = output_v
output.mux(packet)
source.close()
output.close()

View File

@ -282,7 +282,7 @@ atenpdu==0.3.0
aurorapy==0.2.6
# homeassistant.components.stream
av==6.1.2
av==7.0.1
# homeassistant.components.avea
avea==1.4

View File

@ -126,7 +126,7 @@ arcam-fmj==0.4.3
async-upnp-client==0.14.13
# homeassistant.components.stream
av==6.1.2
av==7.0.1
# homeassistant.components.axis
axis==25