move imports in stream component (#27647)

This commit is contained in:
Michał Mrozek authored and Paulus Schoutsen committed 2019-10-14 14:20:18 -07:00
1 parent 4efa2f3244
commit 9aa28dfd54
9 files changed
+45 -42

No files matched your search

+3 -4
View File
@@ -3,6 +3,8 @@ from fractions import Fraction
import io
import logging
import av
from .const import AUDIO_SAMPLE_RATE
from .core import Segment, StreamBuffer
@@ -11,9 +13,8 @@ _LOGGER = logging.getLogger(__name__)
def generate_audio_frame():
"""Generate a blank audio frame."""
from av import AudioFrame
audio_frame = AudioFrame(format="dbl", layout="mono", samples=1024)
audio_frame = av.AudioFrame(format="dbl", layout="mono", samples=1024)
# audio_bytes = b''.join(b'\x00\x00\x00\x00\x00\x00\x00\x00'
# for i in range(0, 1024))
audio_bytes = b"\x00\x00\x00\x00\x00\x00\x00\x00" * 1024
@@ -25,7 +26,6 @@ def generate_audio_frame():
def create_stream_buffer(stream_output, video_stream, audio_frame):
"""Create a new StreamBuffer."""
import av
a_packet = None
segment = io.BytesIO()
@@ -45,7 +45,6 @@ def create_stream_buffer(stream_output, video_stream, audio_frame):
def stream_worker(hass, stream, quit_event):
"""Handle consuming streams."""
import av
container = av.open(stream.source, options=stream.options)
try: