-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9876a0d
commit eb94a9b
Showing
16 changed files
with
209 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
cd "$(dirname "$0")" | ||
|
||
source config.sh | ||
|
||
# Execute the main encode script | ||
"$AWS_PROJECTPATH/Scripts/MainEncodeScript.sh" "$AWS_PROJECTPATH" "$AWS_INPUTMEDIA" "$AWS_RESULT" "$AWS_FFMPEG_BIN" | ||
|
||
# Execute custom scripts, all scripts in CustomScripts folder | ||
|
||
# Push the result to dedi | ||
scp -r -i "$MASTER_KEYPATH_ON_AWS" -P "$MASTER_PORT" "$AWS_RESULT" $MASTER_USER@$MASTER_ADDRESS:"\"$MASTER_PROJECTPATH\"" | ||
|
||
# Delete the EncodeAutomation Folder | ||
rm -rf "$AWS_PROJECTPATH" | ||
|
||
# Shutdown the instance | ||
sudo shutdown -h now |
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,14 @@ | ||
# Video Options | ||
# video_codec accepts value ['h265','h264'] | ||
video_codec=h265 | ||
video_preset=veryslow | ||
video_crf=20 | ||
video_resize=1 | ||
video_resize_w=1280 | ||
video_resize_h=720 | ||
video_resizer=bicublin | ||
video_deinterlace=0 | ||
|
||
# Audio Options | ||
# audio_codec valid options: copy, flac(will be automatically configured for max compression) | ||
audio_codec=copy |
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,4 @@ | ||
#!/bin/bash | ||
|
||
ls SourceMedia > InputFiles.txt | ||
ls SourceMedia > OutputFiles.txt |
Empty file.
Empty file.
Empty file.
Empty file.
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,39 @@ | ||
#!/bin/bash | ||
|
||
while getopts ":f:i:o:a:p:c:r:w:h:z:d:" opt; do | ||
case $opt in | ||
f) FFMPEG_BIN="$OPTARG/ffmpeg";; | ||
i) FileName="$OPTARG";; | ||
o) OutputName="$OPTARG";; | ||
a) AUDIO_OPTION="$OPTARG";; | ||
p) PARAM_PRESET="$OPTARG";; | ||
c) PARAM_CRF="$OPTARG";; | ||
r) Resize="$OPTARG";; | ||
w) RESIZE_W="$OPTARG";; | ||
h) RESIZE_H="$OPTARG";; | ||
z) RESIZER="$OPTARG";; | ||
d) DEINTERLACE="$OPTARG";; | ||
\?) echo "Invalid option: -$OPTARG" ;; | ||
esac | ||
done | ||
|
||
# Resize? Yes = 1, No = 0 | ||
|
||
#Build video option string | ||
VIDEO_OPT_STR="-c:v libx264 -preset $PARAM_PRESET -crf $PARAM_CRF" | ||
|
||
#Build video filter option string | ||
FILTER_OPT="" | ||
if [ $Resize == "1" ] | ||
then | ||
FILTER_OPT="-vf $FILTER_OPT scale=$RESIZE_W:$RESIZE_H:flags=$RESIZER" | ||
fi | ||
|
||
DEINTERLACE_FLAG="" | ||
if [ $DEINTERLACE == "1" ] | ||
then | ||
DEINTERLACE_FLAG="-deinterlace" | ||
fi | ||
|
||
"$FFMPEG_BIN" -hide_banner -ss 0 -i "$FileName" $DEINTERLACE_FLAG $FILTER_OPT $VIDEO_OPT_STR -c:a $AUDIO_OPTION -scodec copy "$OutputName" | ||
|
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,39 @@ | ||
#!/bin/bash | ||
|
||
while getopts ":f:i:o:a:p:c:r:w:h:z:d:" opt; do | ||
case $opt in | ||
f) FFMPEG_BIN="$OPTARG/ffmpeg";; | ||
i) FileName="$OPTARG";; | ||
o) OutputName="$OPTARG";; | ||
a) AUDIO_OPTION="$OPTARG";; | ||
p) PARAM_PRESET="$OPTARG";; | ||
c) PARAM_CRF="$OPTARG";; | ||
r) Resize="$OPTARG";; | ||
w) RESIZE_W="$OPTARG";; | ||
h) RESIZE_H="$OPTARG";; | ||
z) RESIZER="$OPTARG";; | ||
d) DEINTERLACE="$OPTARG";; | ||
\?) echo "Invalid option: -$OPTARG" ;; | ||
esac | ||
done | ||
|
||
# Resize? Yes = 1, No = 0 | ||
|
||
#Build video option string | ||
VIDEO_OPT_STR="-c:v libx265 -preset $PARAM_PRESET -x265-params crf=$PARAM_CRF" | ||
|
||
#Build video filter option string | ||
FILTER_OPT="" | ||
if [ $Resize == "1" ] | ||
then | ||
FILTER_OPT="-vf $FILTER_OPT scale=$RESIZE_W:$RESIZE_H:flags=$RESIZER" | ||
fi | ||
|
||
DEINTERLACE_FLAG="" | ||
if [ $DEINTERLACE == "1" ] | ||
then | ||
DEINTERLACE_FLAG="-deinterlace" | ||
fi | ||
|
||
"$FFMPEG_BIN" -hide_banner -ss 0 -i "$FileName" $DEINTERLACE_FLAG $FILTER_OPT $VIDEO_OPT_STR -c:a $AUDIO_OPTION -scodec copy "$OutputName" | ||
|
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,39 @@ | ||
#!/bin/bash | ||
|
||
# Change to current script dir | ||
cd "$(dirname "$0")" | ||
|
||
PROJECT_PATH="$1" | ||
INPUT_PATH="$2" | ||
OUTPUT_PATH="$3" | ||
FFMPEG_PATH="$4" | ||
|
||
# Set variables according to parameter | ||
source "$PROJECT_PATH/EncoderConfiguration.txt" | ||
|
||
case $video_codec in | ||
"h264") ENCODER_SCRIPT="./H264Encoder.sh";; | ||
"h265") ENCODER_SCRIPT="./H265Encoder.sh";; | ||
*) ENCODER_SCRIPT="./NullHandler.sh";; | ||
esac | ||
|
||
# Pass the video options to Script for further processing | ||
if [ $video_codec == "h264" ] || [ $video_codec == "h265" ] | ||
then | ||
VIDEO_OPTION="-p $video_preset -c $video_crf -r $video_resize -w $video_resize_w -h $video_resize_h -z $video_resizer -d $video_deinterlace" | ||
fi | ||
|
||
# Audio parameters for ffmpeg directly configured here | ||
case $audio_codec in | ||
"flac") AUDIO_OPTION="flac -compression_level 12";; | ||
*) AUDIO_OPTION="copy";; | ||
esac | ||
|
||
# Execute encoding loop | ||
readarray inputs < "$PROJECT_PATH/InputFiles.txt" | ||
readarray outputs < "$PROJECT_PATH/OutputFiles.txt" | ||
|
||
for (( i=0; i<${#inputs[@]}; i++ )); | ||
do | ||
"$ENCODER_SCRIPT" -f "$FFMPEG_PATH" -i "$INPUT_PATH/$(echo ${inputs[$i]} | tr -d '\r\n')" -o "$OUTPUT_PATH/$(echo ${outputs[$i]} | tr -d '\r\n')" $VIDEO_OPTION -a "$AUDIO_OPTION" | ||
done |
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,3 @@ | ||
#!/bin/bash | ||
|
||
echo "Null value" |
Empty file.
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 @@ | ||
#!/bin/bash | ||
|
||
source config.sh | ||
|
||
# Copy necessary files | ||
scp -r -i "$AWS_KEYPATH_ON_MASTER" "$MASTER_PROJECTPATH" $AWS_USER@$AWS_ADDRESS:"\"$AWS_PROJECTPATH\"" | ||
scp -i "$AWS_KEYPATH_ON_MASTER" "$MASTER_KEYPATH_ON_MASTER" $AWS_USER@$AWS_ADDRESS:"\"$MASTER_KEYPATH_ON_AWS\"" | ||
|
||
# Execute the script on EC2 | ||
ssh -i "$AWS_KEYPATH_ON_MASTER" $AWS_USER@$AWS_ADDRESS "screen -d -m \"$AWS_PROJECTPATH/EC2EncodeExec.sh\"" | ||
#ssh -i "$AWS_KEYPATH_ON_MASTER" $AWS_USER@$AWS_ADDRESS "bash -x \"$AWS_PROJECTPATH/EC2EncodeExec.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,7 @@ | ||
#!/bin/bash | ||
|
||
source config.sh | ||
|
||
CURRENT_DIR=$(pwd) | ||
|
||
./Scripts/MainEncodeScript.sh "$CURRENT_DIR" "$CURRENT_DIR/SourceMedia" "$CURRENT_DIR/Result" "$CURRENT_DIR/ffmpeg-bin" |
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,34 @@ | ||
AWS_ADDRESS=<Your AWS Public DNS> | ||
AWS_USER=ubuntu | ||
AWS_HOMEDIR=/home/$AWS_USER | ||
MASTER_USER=<Username on your server> | ||
MASTER_HOMEDIR=/home/$MASTER_USER | ||
MASTER_KEYPATH_ON_MASTER=<Your server private key path on your server> | ||
AWS_KEYPATH_ON_MASTER=<The AWS private key path on your server> | ||
PROJECT_DIR="$(basename "$(pwd)")" | ||
MASTER_KEYPATH_ON_AWS="$AWS_HOMEDIR/$PROJECT_DIR/Key/your_server_key_name" | ||
MASTER_ADDRESS=<Your server address> | ||
MASTER_PORT=<Your server port> | ||
MASTER_PROJECTPATH="$MASTER_HOMEDIR/$PROJECT_DIR" | ||
AWS_PROJECTPATH="$AWS_HOMEDIR/$PROJECT_DIR" | ||
AWS_RESULT="$AWS_PROJECTPATH/Result" | ||
AWS_INPUTMEDIA="$AWS_PROJECTPATH/SourceMedia" | ||
AWS_FFMPEG_BIN="$AWS_PROJECTPATH/ffmpeg-bin" | ||
|
||
# Example | ||
#AWS_ADDRESS=ec2-52-41-193-193.us-west-2.compute.amazonaws.com | ||
#AWS_USER=ubuntu | ||
#AWS_HOMEDIR=/home/$AWS_USER | ||
#MASTER_USER=nantoka | ||
#MASTER_HOMEDIR=/home/$MASTER_USER | ||
#MASTER_KEYPATH_ON_MASTER=$MASTER_HOMEDIR/.ssh/nantoka_key | ||
#AWS_KEYPATH_ON_MASTER=$MASTER_HOMEDIR/.ssh/AmazonEC2key.pem | ||
#PROJECT_DIR="$(basename "$(pwd)")" | ||
#MASTER_KEYPATH_ON_AWS="$AWS_HOMEDIR/$PROJECT_DIR/Key/nantoka_key" | ||
#MASTER_ADDRESS=nantoka.com | ||
#MASTER_PORT=22 | ||
#MASTER_PROJECTPATH="$MASTER_HOMEDIR/$PROJECT_DIR" | ||
#AWS_PROJECTPATH="$AWS_HOMEDIR/$PROJECT_DIR" | ||
#AWS_RESULT="$AWS_PROJECTPATH/Result" | ||
#AWS_INPUTMEDIA="$AWS_PROJECTPATH/SourceMedia" | ||
#AWS_FFMPEG_BIN="$AWS_PROJECTPATH/ffmpeg-bin" |
Empty file.