Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
All services: admin-v2, studio-v2, website, ai-compliance-sdk, consent-service, klausur-service, voice-service, and infrastructure. Large PDFs and compiled binaries excluded via .gitignore.
93 lines
2.9 KiB
Bash
Executable File
93 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Jibri Finalize Script
|
|
# Wird aufgerufen wenn eine Aufzeichnung beendet ist
|
|
# Uploaded die Aufzeichnung zu MinIO und benachrichtigt das Backend
|
|
|
|
set -e
|
|
|
|
RECORDINGS_DIR="$1"
|
|
RECORDING_NAME=$(basename "$RECORDINGS_DIR")
|
|
|
|
echo "[Finalize] Starting finalization for: $RECORDING_NAME"
|
|
echo "[Finalize] Recordings directory: $RECORDINGS_DIR"
|
|
|
|
# Finde die Aufzeichnungsdatei
|
|
RECORDING_FILE=$(find "$RECORDINGS_DIR" -name "*.mp4" | head -1)
|
|
|
|
if [ -z "$RECORDING_FILE" ]; then
|
|
echo "[Finalize] ERROR: No MP4 file found in $RECORDINGS_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
echo "[Finalize] Found recording file: $RECORDING_FILE"
|
|
FILE_SIZE=$(stat -c%s "$RECORDING_FILE" 2>/dev/null || stat -f%z "$RECORDING_FILE")
|
|
echo "[Finalize] File size: $FILE_SIZE bytes"
|
|
|
|
# MinIO Upload mit mc (MinIO Client)
|
|
MINIO_ALIAS="minio"
|
|
BUCKET="${MINIO_BUCKET:-breakpilot-recordings}"
|
|
DEST_PATH="recordings/${RECORDING_NAME}/video.mp4"
|
|
|
|
# MinIO Client konfigurieren (wenn noch nicht konfiguriert)
|
|
if ! mc alias list | grep -q "$MINIO_ALIAS"; then
|
|
echo "[Finalize] Configuring MinIO client..."
|
|
mc alias set "$MINIO_ALIAS" "http://${MINIO_ENDPOINT:-minio:9000}" \
|
|
"${MINIO_ACCESS_KEY:-minioadmin}" \
|
|
"${MINIO_SECRET_KEY:-minioadmin}"
|
|
fi
|
|
|
|
# Bucket erstellen falls nicht vorhanden
|
|
mc mb --ignore-existing "${MINIO_ALIAS}/${BUCKET}"
|
|
|
|
# Upload
|
|
echo "[Finalize] Uploading to MinIO: ${BUCKET}/${DEST_PATH}"
|
|
mc cp "$RECORDING_FILE" "${MINIO_ALIAS}/${BUCKET}/${DEST_PATH}"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "[Finalize] Upload successful!"
|
|
|
|
# Audio extrahieren fuer Transkription
|
|
AUDIO_FILE="${RECORDINGS_DIR}/audio.wav"
|
|
echo "[Finalize] Extracting audio for transcription..."
|
|
ffmpeg -i "$RECORDING_FILE" -vn -acodec pcm_s16le -ar 16000 -ac 1 "$AUDIO_FILE" -y 2>/dev/null
|
|
|
|
if [ -f "$AUDIO_FILE" ]; then
|
|
AUDIO_DEST_PATH="recordings/${RECORDING_NAME}/audio.wav"
|
|
mc cp "$AUDIO_FILE" "${MINIO_ALIAS}/${BUCKET}/${AUDIO_DEST_PATH}"
|
|
echo "[Finalize] Audio extracted and uploaded: ${AUDIO_DEST_PATH}"
|
|
fi
|
|
|
|
# Backend Webhook benachrichtigen
|
|
if [ -n "$BACKEND_WEBHOOK_URL" ]; then
|
|
echo "[Finalize] Notifying backend webhook..."
|
|
METADATA_FILE=$(find "$RECORDINGS_DIR" -name "*.json" | head -1)
|
|
|
|
WEBHOOK_PAYLOAD=$(cat <<EOF
|
|
{
|
|
"event": "recording_completed",
|
|
"recording_name": "${RECORDING_NAME}",
|
|
"storage_path": "${DEST_PATH}",
|
|
"audio_path": "recordings/${RECORDING_NAME}/audio.wav",
|
|
"file_size_bytes": ${FILE_SIZE},
|
|
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
}
|
|
EOF
|
|
)
|
|
|
|
curl -X POST "$BACKEND_WEBHOOK_URL" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$WEBHOOK_PAYLOAD" \
|
|
--max-time 30 \
|
|
|| echo "[Finalize] WARNING: Webhook notification failed"
|
|
fi
|
|
|
|
# Lokale Dateien aufraeumen
|
|
echo "[Finalize] Cleaning up local files..."
|
|
rm -rf "$RECORDINGS_DIR"
|
|
|
|
echo "[Finalize] Finalization completed successfully!"
|
|
else
|
|
echo "[Finalize] ERROR: Upload failed!"
|
|
exit 1
|
|
fi
|