Update ha-ffmpeg 2.0 (#22427)
This commit is contained in:
parent
19d99ddf57
commit
a55afa8119
14 changed files with 41 additions and 31 deletions
|
@ -78,7 +78,7 @@ class AmcrestCam(Camera):
|
||||||
self.hass, request, stream_coro)
|
self.hass, request, stream_coro)
|
||||||
|
|
||||||
# streaming via ffmpeg
|
# streaming via ffmpeg
|
||||||
from haffmpeg import CameraMjpeg
|
from haffmpeg.camera import CameraMjpeg
|
||||||
|
|
||||||
streaming_url = self._camera.rtsp_url(typeno=self._resolution)
|
streaming_url = self._camera.rtsp_url(typeno=self._resolution)
|
||||||
stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop)
|
stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop)
|
||||||
|
@ -86,8 +86,9 @@ class AmcrestCam(Camera):
|
||||||
streaming_url, extra_cmd=self._ffmpeg_arguments)
|
streaming_url, extra_cmd=self._ffmpeg_arguments)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
stream_reader = await stream.get_reader()
|
||||||
return await async_aiohttp_proxy_stream(
|
return await async_aiohttp_proxy_stream(
|
||||||
self.hass, request, stream,
|
self.hass, request, stream_reader,
|
||||||
self._ffmpeg.ffmpeg_stream_content_type)
|
self._ffmpeg.ffmpeg_stream_content_type)
|
||||||
finally:
|
finally:
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
|
@ -83,7 +83,7 @@ class ArloCam(Camera):
|
||||||
|
|
||||||
async def handle_async_mjpeg_stream(self, request):
|
async def handle_async_mjpeg_stream(self, request):
|
||||||
"""Generate an HTTP MJPEG stream from the camera."""
|
"""Generate an HTTP MJPEG stream from the camera."""
|
||||||
from haffmpeg import CameraMjpeg
|
from haffmpeg.camera import CameraMjpeg
|
||||||
video = self._camera.last_video
|
video = self._camera.last_video
|
||||||
if not video:
|
if not video:
|
||||||
error_msg = \
|
error_msg = \
|
||||||
|
@ -97,8 +97,9 @@ class ArloCam(Camera):
|
||||||
video.video_url, extra_cmd=self._ffmpeg_arguments)
|
video.video_url, extra_cmd=self._ffmpeg_arguments)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
stream_reader = await stream.get_reader()
|
||||||
return await async_aiohttp_proxy_stream(
|
return await async_aiohttp_proxy_stream(
|
||||||
self.hass, request, stream,
|
self.hass, request, stream_reader,
|
||||||
self._ffmpeg.ffmpeg_stream_content_type)
|
self._ffmpeg.ffmpeg_stream_content_type)
|
||||||
finally:
|
finally:
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
|
@ -80,7 +80,7 @@ class CanaryCamera(Camera):
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
self.renew_live_stream_session()
|
self.renew_live_stream_session()
|
||||||
|
|
||||||
from haffmpeg import ImageFrame, IMAGE_JPEG
|
from haffmpeg.tools import ImageFrame, IMAGE_JPEG
|
||||||
ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop)
|
ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop)
|
||||||
image = await asyncio.shield(ffmpeg.get_image(
|
image = await asyncio.shield(ffmpeg.get_image(
|
||||||
self._live_stream_session.live_stream_url,
|
self._live_stream_session.live_stream_url,
|
||||||
|
@ -93,15 +93,16 @@ class CanaryCamera(Camera):
|
||||||
if self._live_stream_session is None:
|
if self._live_stream_session is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
from haffmpeg import CameraMjpeg
|
from haffmpeg.camera import CameraMjpeg
|
||||||
stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop)
|
stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop)
|
||||||
await stream.open_camera(
|
await stream.open_camera(
|
||||||
self._live_stream_session.live_stream_url,
|
self._live_stream_session.live_stream_url,
|
||||||
extra_cmd=self._ffmpeg_arguments)
|
extra_cmd=self._ffmpeg_arguments)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
stream_reader = await stream.get_reader()
|
||||||
return await async_aiohttp_proxy_stream(
|
return await async_aiohttp_proxy_stream(
|
||||||
self.hass, request, stream,
|
self.hass, request, stream_reader,
|
||||||
self._ffmpeg.ffmpeg_stream_content_type)
|
self._ffmpeg.ffmpeg_stream_content_type)
|
||||||
finally:
|
finally:
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.helpers.dispatcher import (
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['ha-ffmpeg==1.11']
|
REQUIREMENTS = ['ha-ffmpeg==2.0']
|
||||||
|
|
||||||
DOMAIN = 'ffmpeg'
|
DOMAIN = 'ffmpeg'
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ class FFmpegCamera(Camera):
|
||||||
|
|
||||||
async def async_camera_image(self):
|
async def async_camera_image(self):
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
from haffmpeg import ImageFrame, IMAGE_JPEG
|
from haffmpeg.tools import ImageFrame, IMAGE_JPEG
|
||||||
ffmpeg = ImageFrame(self._manager.binary, loop=self.hass.loop)
|
ffmpeg = ImageFrame(self._manager.binary, loop=self.hass.loop)
|
||||||
|
|
||||||
image = await asyncio.shield(ffmpeg.get_image(
|
image = await asyncio.shield(ffmpeg.get_image(
|
||||||
|
@ -58,15 +58,16 @@ class FFmpegCamera(Camera):
|
||||||
|
|
||||||
async def handle_async_mjpeg_stream(self, request):
|
async def handle_async_mjpeg_stream(self, request):
|
||||||
"""Generate an HTTP MJPEG stream from the camera."""
|
"""Generate an HTTP MJPEG stream from the camera."""
|
||||||
from haffmpeg import CameraMjpeg
|
from haffmpeg.camera import CameraMjpeg
|
||||||
|
|
||||||
stream = CameraMjpeg(self._manager.binary, loop=self.hass.loop)
|
stream = CameraMjpeg(self._manager.binary, loop=self.hass.loop)
|
||||||
await stream.open_camera(
|
await stream.open_camera(
|
||||||
self._input, extra_cmd=self._extra_arguments)
|
self._input, extra_cmd=self._extra_arguments)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
stream_reader = await stream.get_reader()
|
||||||
return await async_aiohttp_proxy_stream(
|
return await async_aiohttp_proxy_stream(
|
||||||
self.hass, request, stream,
|
self.hass, request, stream_reader,
|
||||||
self._manager.ffmpeg_stream_content_type)
|
self._manager.ffmpeg_stream_content_type)
|
||||||
finally:
|
finally:
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
|
@ -86,7 +86,7 @@ class FFmpegMotion(FFmpegBinarySensor):
|
||||||
|
|
||||||
def __init__(self, hass, manager, config):
|
def __init__(self, hass, manager, config):
|
||||||
"""Initialize FFmpeg motion binary sensor."""
|
"""Initialize FFmpeg motion binary sensor."""
|
||||||
from haffmpeg import SensorMotion
|
from haffmpeg.sensor import SensorMotion
|
||||||
|
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
self.ffmpeg = SensorMotion(
|
self.ffmpeg = SensorMotion(
|
||||||
|
|
|
@ -55,7 +55,7 @@ class FFmpegNoise(FFmpegBinarySensor):
|
||||||
|
|
||||||
def __init__(self, hass, manager, config):
|
def __init__(self, hass, manager, config):
|
||||||
"""Initialize FFmpeg noise binary sensor."""
|
"""Initialize FFmpeg noise binary sensor."""
|
||||||
from haffmpeg import SensorNoise
|
from haffmpeg.sensor import SensorNoise
|
||||||
|
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
self.ffmpeg = SensorNoise(
|
self.ffmpeg = SensorNoise(
|
||||||
|
|
|
@ -190,7 +190,7 @@ class ONVIFHassCamera(Camera):
|
||||||
|
|
||||||
async def async_camera_image(self):
|
async def async_camera_image(self):
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
from haffmpeg import ImageFrame, IMAGE_JPEG
|
from haffmpeg.tools import ImageFrame, IMAGE_JPEG
|
||||||
|
|
||||||
if not self._input:
|
if not self._input:
|
||||||
await self.hass.async_add_job(self.obtain_input_uri)
|
await self.hass.async_add_job(self.obtain_input_uri)
|
||||||
|
@ -207,7 +207,7 @@ class ONVIFHassCamera(Camera):
|
||||||
|
|
||||||
async def handle_async_mjpeg_stream(self, request):
|
async def handle_async_mjpeg_stream(self, request):
|
||||||
"""Generate an HTTP MJPEG stream from the camera."""
|
"""Generate an HTTP MJPEG stream from the camera."""
|
||||||
from haffmpeg import CameraMjpeg
|
from haffmpeg.camera import CameraMjpeg
|
||||||
|
|
||||||
if not self._input:
|
if not self._input:
|
||||||
await self.hass.async_add_job(self.obtain_input_uri)
|
await self.hass.async_add_job(self.obtain_input_uri)
|
||||||
|
@ -221,8 +221,9 @@ class ONVIFHassCamera(Camera):
|
||||||
self._input, extra_cmd=self._ffmpeg_arguments)
|
self._input, extra_cmd=self._ffmpeg_arguments)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
stream_reader = await stream.get_reader()
|
||||||
return await async_aiohttp_proxy_stream(
|
return await async_aiohttp_proxy_stream(
|
||||||
self.hass, request, stream,
|
self.hass, request, stream_reader,
|
||||||
ffmpeg_manager.ffmpeg_stream_content_type)
|
ffmpeg_manager.ffmpeg_stream_content_type)
|
||||||
finally:
|
finally:
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
|
@ -115,7 +115,7 @@ class RingCam(Camera):
|
||||||
|
|
||||||
async def async_camera_image(self):
|
async def async_camera_image(self):
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
from haffmpeg import ImageFrame, IMAGE_JPEG
|
from haffmpeg.tools import ImageFrame, IMAGE_JPEG
|
||||||
ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop)
|
ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop)
|
||||||
|
|
||||||
if self._video_url is None:
|
if self._video_url is None:
|
||||||
|
@ -128,7 +128,7 @@ class RingCam(Camera):
|
||||||
|
|
||||||
async def handle_async_mjpeg_stream(self, request):
|
async def handle_async_mjpeg_stream(self, request):
|
||||||
"""Generate an HTTP MJPEG stream from the camera."""
|
"""Generate an HTTP MJPEG stream from the camera."""
|
||||||
from haffmpeg import CameraMjpeg
|
from haffmpeg.camera import CameraMjpeg
|
||||||
|
|
||||||
if self._video_url is None:
|
if self._video_url is None:
|
||||||
return
|
return
|
||||||
|
@ -138,8 +138,9 @@ class RingCam(Camera):
|
||||||
self._video_url, extra_cmd=self._ffmpeg_arguments)
|
self._video_url, extra_cmd=self._ffmpeg_arguments)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
stream_reader = await stream.get_reader()
|
||||||
return await async_aiohttp_proxy_stream(
|
return await async_aiohttp_proxy_stream(
|
||||||
self.hass, request, stream,
|
self.hass, request, stream_reader,
|
||||||
self._ffmpeg.ffmpeg_stream_content_type)
|
self._ffmpeg.ffmpeg_stream_content_type)
|
||||||
finally:
|
finally:
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
|
@ -138,7 +138,7 @@ class XiaomiCamera(Camera):
|
||||||
|
|
||||||
async def async_camera_image(self):
|
async def async_camera_image(self):
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
from haffmpeg import ImageFrame, IMAGE_JPEG
|
from haffmpeg.tools import ImageFrame, IMAGE_JPEG
|
||||||
|
|
||||||
url = await self.hass.async_add_job(self.get_latest_video_url)
|
url = await self.hass.async_add_job(self.get_latest_video_url)
|
||||||
if url != self._last_url:
|
if url != self._last_url:
|
||||||
|
@ -152,15 +152,16 @@ class XiaomiCamera(Camera):
|
||||||
|
|
||||||
async def handle_async_mjpeg_stream(self, request):
|
async def handle_async_mjpeg_stream(self, request):
|
||||||
"""Generate an HTTP MJPEG stream from the camera."""
|
"""Generate an HTTP MJPEG stream from the camera."""
|
||||||
from haffmpeg import CameraMjpeg
|
from haffmpeg.camera import CameraMjpeg
|
||||||
|
|
||||||
stream = CameraMjpeg(self._manager.binary, loop=self.hass.loop)
|
stream = CameraMjpeg(self._manager.binary, loop=self.hass.loop)
|
||||||
await stream.open_camera(
|
await stream.open_camera(
|
||||||
self._last_url, extra_cmd=self._extra_arguments)
|
self._last_url, extra_cmd=self._extra_arguments)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
stream_reader = await stream.get_reader()
|
||||||
return await async_aiohttp_proxy_stream(
|
return await async_aiohttp_proxy_stream(
|
||||||
self.hass, request, stream,
|
self.hass, request, stream_reader,
|
||||||
self._manager.ffmpeg_stream_content_type)
|
self._manager.ffmpeg_stream_content_type)
|
||||||
finally:
|
finally:
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
|
@ -118,7 +118,7 @@ class YiCamera(Camera):
|
||||||
|
|
||||||
async def async_camera_image(self):
|
async def async_camera_image(self):
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
from haffmpeg import ImageFrame, IMAGE_JPEG
|
from haffmpeg.tools import ImageFrame, IMAGE_JPEG
|
||||||
|
|
||||||
url = await self._get_latest_video_url()
|
url = await self._get_latest_video_url()
|
||||||
if url and url != self._last_url:
|
if url and url != self._last_url:
|
||||||
|
@ -135,7 +135,7 @@ class YiCamera(Camera):
|
||||||
|
|
||||||
async def handle_async_mjpeg_stream(self, request):
|
async def handle_async_mjpeg_stream(self, request):
|
||||||
"""Generate an HTTP MJPEG stream from the camera."""
|
"""Generate an HTTP MJPEG stream from the camera."""
|
||||||
from haffmpeg import CameraMjpeg
|
from haffmpeg.camera import CameraMjpeg
|
||||||
|
|
||||||
if not self._is_on:
|
if not self._is_on:
|
||||||
return
|
return
|
||||||
|
@ -145,8 +145,9 @@ class YiCamera(Camera):
|
||||||
self._last_url, extra_cmd=self._extra_arguments)
|
self._last_url, extra_cmd=self._extra_arguments)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
stream_reader = await stream.get_reader()
|
||||||
return await async_aiohttp_proxy_stream(
|
return await async_aiohttp_proxy_stream(
|
||||||
self.hass, request, stream,
|
self.hass, request, stream_reader,
|
||||||
self._manager.ffmpeg_stream_content_type)
|
self._manager.ffmpeg_stream_content_type)
|
||||||
finally:
|
finally:
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
|
@ -505,7 +505,7 @@ greenwavereality==0.5.1
|
||||||
gstreamer-player==1.1.2
|
gstreamer-player==1.1.2
|
||||||
|
|
||||||
# homeassistant.components.ffmpeg
|
# homeassistant.components.ffmpeg
|
||||||
ha-ffmpeg==1.11
|
ha-ffmpeg==2.0
|
||||||
|
|
||||||
# homeassistant.components.philips_js.media_player
|
# homeassistant.components.philips_js.media_player
|
||||||
ha-philipsjs==0.0.5
|
ha-philipsjs==0.0.5
|
||||||
|
|
|
@ -114,7 +114,7 @@ geojson_client==0.3
|
||||||
georss_client==0.5
|
georss_client==0.5
|
||||||
|
|
||||||
# homeassistant.components.ffmpeg
|
# homeassistant.components.ffmpeg
|
||||||
ha-ffmpeg==1.11
|
ha-ffmpeg==2.0
|
||||||
|
|
||||||
# homeassistant.components.hangouts
|
# homeassistant.components.hangouts
|
||||||
hangups==0.4.6
|
hangups==0.4.6
|
||||||
|
|
|
@ -33,7 +33,8 @@ class TestFFmpegNoiseSetup:
|
||||||
assert self.hass.data['ffmpeg'].binary == 'ffmpeg'
|
assert self.hass.data['ffmpeg'].binary == 'ffmpeg'
|
||||||
assert self.hass.states.get('binary_sensor.ffmpeg_noise') is not None
|
assert self.hass.states.get('binary_sensor.ffmpeg_noise') is not None
|
||||||
|
|
||||||
@patch('haffmpeg.SensorNoise.open_sensor', return_value=mock_coro())
|
@patch('haffmpeg.sensor.SensorNoise.open_sensor',
|
||||||
|
return_value=mock_coro())
|
||||||
def test_setup_component_start(self, mock_start):
|
def test_setup_component_start(self, mock_start):
|
||||||
"""Set up ffmpeg component."""
|
"""Set up ffmpeg component."""
|
||||||
with assert_setup_component(1, 'binary_sensor'):
|
with assert_setup_component(1, 'binary_sensor'):
|
||||||
|
@ -48,7 +49,7 @@ class TestFFmpegNoiseSetup:
|
||||||
entity = self.hass.states.get('binary_sensor.ffmpeg_noise')
|
entity = self.hass.states.get('binary_sensor.ffmpeg_noise')
|
||||||
assert entity.state == 'unavailable'
|
assert entity.state == 'unavailable'
|
||||||
|
|
||||||
@patch('haffmpeg.SensorNoise')
|
@patch('haffmpeg.sensor.SensorNoise')
|
||||||
def test_setup_component_start_callback(self, mock_ffmpeg):
|
def test_setup_component_start_callback(self, mock_ffmpeg):
|
||||||
"""Set up ffmpeg component."""
|
"""Set up ffmpeg component."""
|
||||||
with assert_setup_component(1, 'binary_sensor'):
|
with assert_setup_component(1, 'binary_sensor'):
|
||||||
|
@ -95,7 +96,8 @@ class TestFFmpegMotionSetup:
|
||||||
assert self.hass.data['ffmpeg'].binary == 'ffmpeg'
|
assert self.hass.data['ffmpeg'].binary == 'ffmpeg'
|
||||||
assert self.hass.states.get('binary_sensor.ffmpeg_motion') is not None
|
assert self.hass.states.get('binary_sensor.ffmpeg_motion') is not None
|
||||||
|
|
||||||
@patch('haffmpeg.SensorMotion.open_sensor', return_value=mock_coro())
|
@patch('haffmpeg.sensor.SensorMotion.open_sensor',
|
||||||
|
return_value=mock_coro())
|
||||||
def test_setup_component_start(self, mock_start):
|
def test_setup_component_start(self, mock_start):
|
||||||
"""Set up ffmpeg component."""
|
"""Set up ffmpeg component."""
|
||||||
with assert_setup_component(1, 'binary_sensor'):
|
with assert_setup_component(1, 'binary_sensor'):
|
||||||
|
@ -110,7 +112,7 @@ class TestFFmpegMotionSetup:
|
||||||
entity = self.hass.states.get('binary_sensor.ffmpeg_motion')
|
entity = self.hass.states.get('binary_sensor.ffmpeg_motion')
|
||||||
assert entity.state == 'unavailable'
|
assert entity.state == 'unavailable'
|
||||||
|
|
||||||
@patch('haffmpeg.SensorMotion')
|
@patch('haffmpeg.sensor.SensorMotion')
|
||||||
def test_setup_component_start_callback(self, mock_ffmpeg):
|
def test_setup_component_start_callback(self, mock_ffmpeg):
|
||||||
"""Set up ffmpeg component."""
|
"""Set up ffmpeg component."""
|
||||||
with assert_setup_component(1, 'binary_sensor'):
|
with assert_setup_component(1, 'binary_sensor'):
|
Loading…
Add table
Reference in a new issue