From 7922f94ae1b4c5e039b3cc4878fd28cff181b59c Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Mon, 20 Mar 2023 23:23:38 +0200 Subject: [PATCH] conert videos --- files/process_motion_event.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/files/process_motion_event.sh b/files/process_motion_event.sh index 76aa337..5a42ee6 100644 --- a/files/process_motion_event.sh +++ b/files/process_motion_event.sh @@ -230,24 +230,23 @@ if [ "${mail_alert}" == "true" ]; then fi if [ -n "${ntfy_server}" ]; then - if [ -n "${file}" ]; then - ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\", \"filename\": \"${file}\" }" - else - ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\"}" - fi ntfy_password="$(cat "${ntfy_password_file}")" message "Sending event to ntfy server '${ntfy_server}/motion_detection' ..." - message "Data: ${ntfy_data}" if [ -n "${file}" ]; then - curl -s "${ntfy_server}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}" + temp_file="$(mktemp /tmp/tmp.XXXXX.mkv)" + $(which ffmpeg) -filter_complex "[0:v] fps=12,scale=480:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" -i "${file}" "${temp_file}" + ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\", \"filename\": \"${temp_file}\" }" + curl -s "${ntfy_server}" -T "${temp_file}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}" return_code=$? else - curl -s "${ntfy_server}" -T "${file}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}" + ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\"}" + curl -s "${ntfy_server}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}" return_code=$? fi if [ $return_code != 0 ]; then message "Error ${return_code} publishing in ntfy server '${ntfy}'" fi + message "Data sent: ${ntfy_data}" fi if [ -n "${ha_url}" ]; then