diff --git a/README.md b/README.md index e73ee7c..5eb8ec0 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ Jeder Stream wird durch eine `.job`-Datei im `jobs/`-Verzeichnis definiert. Vorl ./stream-recorder.sh create ``` -Das Script fragt Schritt für Schritt nach URL, Name, Typ, Dauer, Zeitplan und Plik-Upload und erstellt die Job-Datei automatisch. +Das Script fragt Schritt für Schritt nach URL, Name, Typ, Zeitplan und Plik-Upload und erstellt die Job-Datei automatisch. Bei aktiviertem Zeitplan wird die Aufnahmedauer wahlweise per Endzeit oder Laufzeit begrenzt — das jeweils andere wird automatisch berechnet. **Manuell (aus Vorlage):** @@ -123,7 +123,7 @@ nano jobs/mein-stream.job | `STREAM_URL` | Ja | URL des Streams | | `STREAM_TYPE` | Nein | `auto`, `rtmp`, `hls`, `mp3`, `aac`, `ogg`, `flac` | | `OUTPUT_FORMAT` | Nein | Dateiendung (z.B. `mp4`, `mp3`) - sonst automatisch | -| `MAX_DURATION` | Nein | Maximale Dauer, z.B. `300`, `5m`, `1h30m` (leer = unbegrenzt) | +| `MAX_DURATION` | Nein | Aufnahmedauer in Sekunden (wird bei Zeitplanung automatisch aus Endzeit oder Laufzeit berechnet) | | `EXTRA_FFMPEG_ARGS`| Nein | Zusätzliche ffmpeg-Parameter | | `PLIK_ENABLED` | Nein | Plik-Upload aktivieren (`true`/`false`) | diff --git a/stream-recorder.sh b/stream-recorder.sh index ef1fa45..23f1589 100644 --- a/stream-recorder.sh +++ b/stream-recorder.sh @@ -8,15 +8,15 @@ # Web: https://www.cleveradmin.de # Repository: https://git.techniverse.net/scriptos/stream-recorder.git # License: MIT -# Version: v2.4.0 +# Version: v2.5.0 # Date: 06.09.2026 -# Modifications: Scheduler-Watchdog stabilisiert, Plik-Upload repariert, einmalige Zeitplanung ergänzt +# Modifications: Zeitplanung vereinfacht: Endzeit oder Laufzeit statt separater Max-Dauer ############################################### set -uo pipefail readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -readonly VERSION="2.4.0" +readonly VERSION="2.5.0" # --- Standardwerte (überschreibbar via Konfiguration) --- CONFIG_FILE="${SCRIPT_DIR}/config/stream-recorder.conf" @@ -821,11 +821,7 @@ create_job() { read -rp "Ausgabeformat [${default_ext}]: " custom_ext local ext="${custom_ext:-}" - read -rp "Max. Dauer (z.B. 1h, 30m, 3600 oder leer=unbegrenzt): " duration_input local duration="" - if [[ -n "$duration_input" ]]; then - duration=$(parse_duration "$duration_input") - fi echo "" echo "--- Zeitplanung (optional) ---" @@ -851,7 +847,51 @@ create_job() { echo "Kein Datum angegeben - Zeitplan deaktiviert." sched_enabled="false" else - read -rp "Endzeit (HH:MM, leer=keine): " sched_stop + echo "" + echo "Wie soll die Aufnahme begrenzt werden?" + echo " 1) Endzeit angeben (z.B. 18:30)" + echo " 2) Laufzeit angeben (z.B. 1h, 30m)" + echo " 3) Unbegrenzt (läuft bis manuell gestoppt)" + read -rp "Auswahl [1/2/3]: " limit_choice + case "$limit_choice" in + 1) + read -rp "Endzeit (HH:MM): " sched_stop + if [[ -n "$sched_stop" ]]; then + local start_min stop_min diff_min + start_min=$(_time_to_minutes "$sched_start") + stop_min=$(_time_to_minutes "$sched_stop") + diff_min=$(( stop_min - start_min )) + [[ $diff_min -le 0 ]] && diff_min=$(( diff_min + 1440 )) + duration=$(( diff_min * 60 )) + echo " -> Laufzeit automatisch berechnet: ${diff_min} Minuten" + fi + ;; + 2) + read -rp "Laufzeit (z.B. 1h, 30m, 1h30m, 3600): " duration_input + if [[ -n "$duration_input" ]]; then + duration=$(parse_duration "$duration_input") + if [[ -n "$duration" ]]; then + local start_min end_min end_h end_m + start_min=$(_time_to_minutes "$sched_start") + end_min=$(( start_min + duration / 60 )) + [[ $end_min -ge 1440 ]] && end_min=$(( end_min - 1440 )) + end_h=$(( end_min / 60 )) + end_m=$(( end_min % 60 )) + sched_stop=$(printf "%02d:%02d" "$end_h" "$end_m") + echo " -> Endzeit automatisch berechnet: ${sched_stop}" + fi + fi + ;; + *) + ;; + esac + fi + fi + + if [[ "$sched_enabled" != "true" ]]; then + read -rp "Laufzeit (z.B. 1h, 30m, 3600 oder leer=unbegrenzt): " duration_input + if [[ -n "$duration_input" ]]; then + duration=$(parse_duration "$duration_input") fi fi @@ -885,7 +925,12 @@ create_job() { echo " URL: ${url}" echo " Typ: ${stream_type}" echo " Format: ${ext:-auto}" - echo " Dauer: ${duration:-unbegrenzt}" + local duration_display="unbegrenzt" + if [[ -n "$duration" ]]; then + local d_h=$((duration / 3600)) d_m=$(( (duration % 3600) / 60 )) + duration_display="${d_h}h ${d_m}m (${duration}s)" + fi + echo " Dauer: ${duration_display}" if [[ "$sched_enabled" == "true" ]]; then if [[ "$sched_once" == "true" ]]; then echo " Zeitplan: einmalig ${sched_date} ${sched_start}${sched_stop:+ - ${sched_stop}}"