added state api

This commit is contained in:
2020-02-24 16:00:41 +01:00
parent 6ba38cd42d
commit 1d011af64b
10 changed files with 74 additions and 80 deletions

View File

@@ -9,29 +9,6 @@ from pydub import AudioSegment
from pydub.playback import play
def old_test():
file_name = tempfile.gettempdir() + os.path.sep + "test.jpg"
print(file_name)
if os.path.exists(file_name):
os.remove(file_name)
process = (
ffmpeg
.input('rtsp://172.22.246.207/extron1')
# .input('rtsp://172.22.246.207/extron3')
.output(file_name, vframes=1)
# .output('-', format='h264')
.run(capture_stdout=True)
)
image = Image.open(file_name)
r, g, b = image.split()
print(r.histogram())
print(g.histogram())
print(b.histogram())
image.show()
# old_test()
def is_single_color_image(image):
single_color_image = True
color = {}
@@ -97,7 +74,7 @@ def check_if_audio_is_valid(stream_url, sample_length_sec=3, lower_alert_limit_d
sound = AudioSegment.from_file(file_name, "aac")
# print(sound.dBFS)
play(sound)
#play(sound)
if sound.max_dBFS == -float('inf'):
return False, "No active audio signal detected!"
elif sound.max_dBFS < lower_alert_limit_dBFS:
@@ -115,9 +92,14 @@ def check_if_audio_is_valid(stream_url, sample_length_sec=3, lower_alert_limit_d
else:
return False, msg
print(check_if_audio_is_valid('rtsp://172.22.246.207/extron1'))
"""
Following code is not working correctly - ffmpeg parameters are wrong.
"""
"""
def check_if_audio_is_valid_stream(stream_url, raise_errors=True):
audio, _ = (
ffmpeg
@@ -130,3 +112,4 @@ def check_if_audio_is_valid_stream(stream_url, raise_errors=True):
play(sound)
# check_if_audio_is_valid('rtsp://172.22.246.207/extron1')
"""