-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_defined.sh
45 lines (35 loc) · 1.08 KB
/
user_defined.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
#!/bin/bash
INPUT="$1"
TARGET="/usr/local/antmedia/custom"
BITRATE="4000k"
# If you want to upload to S3, fill in the below lines.
AWS_ACCESS_KEY=""
AWS_SECRET_KEY=""
AWS_DEFAULT_REGION=""
S3_BUCKET_NAME=""
S3_UPLOAD="NO"
mkdir -p $TARGET
chown -R antmedia:antmedia $TARGET
upload(){
if [ -z `which aws` ]; then
rm -r aws* > /dev/null 2>&1
echo "Please wait. AWS Client is installing..."
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" > /dev/null 2>&1
unzip awscliv2.zip > /dev/null 2>&1
sudo ./aws/install &
wait $!
echo "AWS Client installed."
rm -r aws*
fi
# Set credentials
aws configure set aws_access_key_id $AWS_ACCESS_KEY
aws configure set aws_secret_access_key $AWS_SECRET_KEY
aws configure set default.region $AWS_DEFAULT_REGION
aws s3 sync $TARGET s3://$S3_BUCKET_NAME/
}
FILE=`echo $INPUT |egrep "[0-9]+p"`
FILE_NAME=`echo $FILE |egrep "[0-9]+p" | awk -F "/" '{print $(NF-0)}'`
echo $FILE | xargs -I {} ffmpeg -v quiet -i {} -c:v libx264 -b:v $BITRATE -bufsize 1835k $TARGET/$FILE_NAME
if [ "$S3_UPLOAD" == "YES" ]; then
upload
fi