-
Notifications
You must be signed in to change notification settings - Fork 13
/
single-rendition-media-tcp-to-s3.sh
executable file
·46 lines (37 loc) · 1.55 KB
/
single-rendition-media-tcp-to-s3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
if [ $# -lt 0 ]; then
echo "Use ./single-rendition-media-tcp-to-s3.sh [S3Bucket] [S3Region] [StreamID]\n"
echo "Example: ./single-rendition-media-tcp-to-s3.sh"
#exit 1
fi
# S3 Data
S3_BUCKET="${1:-"live-dist-test"}"
S3_REGION="${2:-"us-east-1"}"
# ObjKeyPath
STREAM_ID_DEF=`date '+%Y%m%d%H%M%S'`
STREAM_ID="${3:-"$STREAM_ID_DEF"}"
DST_PATH="ingest/$STREAM_ID"
echo "Using s3 path: $DST_PATH"
# Starts segmenter
../bin/go-ts-segmenter -inputType 2 -manifestDestinationType 0 -s3Bucket $S3_BUCKET -s3Region $S3_REGION -mediaDestinationType 4 -dstPath $DST_PATH -chunksBaseFilename source_ &
PID_720p=$!
echo "Started go-ts-segmenter for 720p as PID $PID_720p"
# Overlay base text
TEXT="SOURCE-"
# Select font path based in OS
# TODO: Probably (depending on the distribuition) for linux you will need to find the right path
if [[ "$OSTYPE" == "linux-gnu" ]]; then
FONT_PATH='/usr/share/fonts/Hack-Regular.ttf'
elif [[ "$OSTYPE" == "darwin"* ]]; then
FONT_PATH='/Library/Fonts/Arial.ttf'
fi
# Start test signal
ffmpeg -hide_banner -y \
-f lavfi -re -i smptebars=size=1280x720:rate=30 \
-f lavfi -i sine=frequency=1000:sample_rate=48000 -pix_fmt yuv420p \
-vf "drawtext=fontfile=$FONT_PATH: text=\'${TEXT} 720p - Local time %{localtime\: %Y\/%m\/%d %H.%M.%S} (%{n})\': x=100: y=50: fontsize=30: fontcolor=pink: box=1: boxcolor=0x00000099" \
-c:v libx264 -b:v 6000k -g 60 -profile:v baseline -preset veryfast \
-c:a aac -b:a 48k \
-f mpegts "tcp://localhost:2002"
# Destination
echo "You should be able to s3 the files in this S3 bucket $S3_BUCKET"