-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[minor] Add HLS streaming derivative service (#59)
- Loading branch information
Showing
13 changed files
with
140 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: islandora-hls | ||
spec: | ||
selector: | ||
app: islandora-hls | ||
ports: | ||
- protocol: TCP | ||
port: 8085 | ||
targetPort: 8080 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: islandora-hls | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: islandora-hls | ||
template: | ||
metadata: | ||
labels: | ||
app: islandora-hls | ||
spec: | ||
containers: | ||
- name: scyllaridae-hls | ||
image: lehighlts/scyllaridae-hls:main | ||
imagePullPolicy: IfNotPresent | ||
resources: | ||
requests: | ||
memory: "512Mi" | ||
cpu: "250m" | ||
limits: | ||
memory: "4Gi" | ||
ports: | ||
- hostPort: 8085 | ||
containerPort: 8080 | ||
readinessProbe: | ||
httpGet: | ||
path: /healthcheck | ||
port: 8080 | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ARG TAG=main | ||
ARG DOCKER_REPOSITORY=lehighlts | ||
FROM ${DOCKER_REPOSITORY}/scyllaridae:${TAG} | ||
|
||
RUN apk update && \ | ||
apk add --no-cache \ | ||
ffmpeg==6.1.1-r8 \ | ||
jq==1.7.1-r0 | ||
|
||
COPY scyllaridae.yml /app/scyllaridae.yml | ||
COPY cmd.sh /app/cmd.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Streaming Audio and Video Derivatives | ||
|
||
Create an HLS streaming derivative for audio and video files | ||
|
||
Requires `islandora_hls` module running on your Islandora site to render the streaming derivative. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eou pipefail | ||
|
||
SOURCE_MIMETYPE="$1" | ||
NODE_URL="$2" | ||
NID=$(basename "$NODE_URL") | ||
TMP_DIR=$(mktemp -d) | ||
|
||
ffmpeg \ | ||
-f "$SOURCE_MIMETYPE" \ | ||
-i - \ | ||
-profile:v \ | ||
baseline \ | ||
-level 3.0 \ | ||
-s 640x360 \ | ||
-start_number 0 \ | ||
-hls_time 10 \ | ||
-hls_list_size 0 \ | ||
-f hls \ | ||
-b:v 800k \ | ||
-maxrate 800k \ | ||
-bufsize 1200k \ | ||
-b:a 96k "$TMP_DIR/$NID.m3u8" > /dev/null 2>&1 | ||
|
||
if [ ! -f "$TMP_DIR/$NID.m3u8" ]; then | ||
exit 1 | ||
fi | ||
|
||
# shellcheck disable=SC2046 | ||
tar -czf "$TMP_DIR/hls.tar.gz" -C "$TMP_DIR" "./$NID.m3u8" $(cd "$TMP_DIR" ; echo ./*.ts) | ||
|
||
BASE_URL=$(dirname "$NODE_URL" | xargs dirname) | ||
TID=$(curl -s "$BASE_URL/term_from_term_name?vocab=islandora_media_use&name=Service+File&_format=json" | jq '.[0].tid[0].value') | ||
|
||
curl -s \ | ||
-H "Authorization: $SCYLLARIDAE_AUTH" \ | ||
-H "Content-Type: application/gzip" \ | ||
-H "Content-Location: private://derivatives/hls/$NID/hls.tar.gz" \ | ||
-T "$TMP_DIR/hls.tar.gz" \ | ||
"$NODE_URL/media/file/$TID" | ||
|
||
rm -rf "$TMP_DIR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
forwardAuth: true | ||
allowedMimeTypes: | ||
- "audio/*" | ||
- "video/*" | ||
cmdByMimeType: | ||
default: | ||
cmd: /app/cmd.sh | ||
args: | ||
- "%source-mime-ext" | ||
- "%canonical" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters