added state api
This commit is contained in:
@@ -38,8 +38,6 @@ rec_err_state_log_stream_handler.setLevel(logging.WARNING)
|
||||
logger.addHandler(rec_err_state_log_stream_handler)
|
||||
#logger.addHandler(mem_handler)
|
||||
|
||||
base_url = "https://opencast.bibliothek.kit.edu"
|
||||
|
||||
session = requests.session()
|
||||
session.auth = HTTPBasicAuth(Config.OPENCAST_USER, Config.OPENCAST_PW)
|
||||
|
||||
@@ -55,7 +53,7 @@ def get_service_url(service_type: str):
|
||||
if service_type in config['service_urls']:
|
||||
return config['service_urls'][service_type]
|
||||
params = {'serviceType': service_type}
|
||||
url = base_url + "/services/available.json"
|
||||
url = Config.OPENCAST_URL + "/services/available.json"
|
||||
res = session.get(url, params=params)
|
||||
if res.ok:
|
||||
service = res.json()["services"]["service"]
|
||||
@@ -135,6 +133,7 @@ def check_stream_sanity(recorder: Recorder, recorder_adapter: RecorderAdapter):
|
||||
|
||||
for i in range(0, Config.STREAM_SANITY_CHECK_RETRIES):
|
||||
do_checks = False
|
||||
|
||||
if do_checks:
|
||||
return True
|
||||
else:
|
||||
@@ -224,7 +223,6 @@ if __name__ == '__main__':
|
||||
for a in agents:
|
||||
agent_states[a.get('name')] = 'PROBLEMATIC - unknown'
|
||||
|
||||
|
||||
# pool = ThreadPool(5)
|
||||
# pool.map(check_capture_agent_state, agents)
|
||||
|
||||
@@ -239,7 +237,6 @@ if __name__ == '__main__':
|
||||
except TimeoutError as e:
|
||||
logger.error("Timeout while pinging capture agent! {}".format(e))
|
||||
|
||||
|
||||
with ThreadPool(NUM_THREADS) as pool:
|
||||
results = [pool.apply_async(check_capture_agent_state, (agent,)) for agent in agents]
|
||||
try:
|
||||
|
||||
@@ -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')
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user