error handling and hsit
This commit is contained in:
parent
50af33522d
commit
b92cdefcde
79
client.sh
79
client.sh
@ -9,13 +9,24 @@ version="0.2.0"
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
sleep 30
|
sleep 30
|
||||||
|
set +e
|
||||||
upsteam_version=`curl -s "$base_url"/version`
|
upsteam_version=`curl -s "$base_url"/version`
|
||||||
|
retval=$?
|
||||||
|
set -e
|
||||||
|
if [ $retval -ne 0 ]; then
|
||||||
|
echo "Is the Job Server Down?"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
if [[ $version != $upsteam_version ]]; then
|
if [[ $version != $upsteam_version ]]; then
|
||||||
|
echo "Wrong version: client version is $version, while job server requires $upstream_version"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set +e
|
||||||
job=`curl -s "$base_url"/request_job | jq`
|
job=`curl -s "$base_url"/request_job | jq`
|
||||||
if [[ $job = "null" ]]; then
|
retval=$?
|
||||||
|
set -e
|
||||||
|
if [[ $job = "null" ]] || [ $retval -ne 0 ]; then
|
||||||
echo "No Jobs Available ¯\_(ツ)_/¯"
|
echo "No Jobs Available ¯\_(ツ)_/¯"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -26,8 +37,15 @@ while true; do
|
|||||||
job_id=`echo "$job" | jq -r .id`
|
job_id=`echo "$job" | jq -r .id`
|
||||||
|
|
||||||
echo "Reserving Job"
|
echo "Reserving Job"
|
||||||
|
set +e
|
||||||
curl -s "$base_url"/edit_status/"$job_id"/reserved
|
curl -s "$base_url"/edit_status/"$job_id"/reserved
|
||||||
echo ""
|
retval=$?
|
||||||
|
set -e
|
||||||
|
if [ $retval -ne 0 ]; then
|
||||||
|
echo "Is the Job Server Down?"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "Reserved!"
|
||||||
|
|
||||||
source=`echo $job | jq -r .description.file_url`
|
source=`echo $job | jq -r .description.file_url`
|
||||||
sourceext=${source##*.}
|
sourceext=${source##*.}
|
||||||
@ -38,11 +56,25 @@ while true; do
|
|||||||
name=`echo $job | jq -r .description.file_name`
|
name=`echo $job | jq -r .description.file_name`
|
||||||
input="$name.$job_id.$sourceext"
|
input="$name.$job_id.$sourceext"
|
||||||
|
|
||||||
|
set +e
|
||||||
curl "$source" -o "$input"
|
curl "$source" -o "$input"
|
||||||
|
retval=$?
|
||||||
|
set -e
|
||||||
|
if [ $retval -ne 0 ]; then
|
||||||
|
echo "Could not Download file!"
|
||||||
|
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "Starting Encode"
|
echo "Starting Encode"
|
||||||
|
|
||||||
|
height=`echo $job | jq -r .description.resolution[0]`
|
||||||
|
width=`echo $job | jq -r .description.resolution[1]`
|
||||||
|
|
||||||
|
echo $job | jq
|
||||||
|
|
||||||
aomenco=`echo $job | jq -r .description.options.aomenc`
|
aomenco=`echo $job | jq -r .description.options.aomenc`
|
||||||
aomenco=${aomenco//[^a-zA-Z0-9_\- =]/}
|
aomenco=${aomenco//[^a-zA-Z0-9_\- =]/}
|
||||||
ffmpego=`echo $job | jq -r .description.options.ffmpeg`
|
ffmpego=`echo $job | jq -r .description.options.ffmpeg`
|
||||||
@ -50,22 +82,51 @@ while true; do
|
|||||||
|
|
||||||
two_pass=`echo $job | jq -r .description.options.two_pass`
|
two_pass=`echo $job | jq -r .description.options.two_pass`
|
||||||
|
|
||||||
echo $two_pass
|
|
||||||
|
|
||||||
if [[ $two_pass = true ]]; then
|
if [[ $two_pass = true ]]; then
|
||||||
|
set +e
|
||||||
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
||||||
-i "'$input'" '$ffmpego' -pix_fmt yuv444p -f yuv4mpegpipe - | aomenc - --i444 '$aomenco' \
|
-i "'$input'" '$ffmpego' -vf scale='$height':'$width' -pix_fmt yuv422p -f yuv4mpegpipe - | aomenc - --i422 '$aomenco' \
|
||||||
--pass=1 --passes=2 --fpf="'$input'.fpf" --webm -o "'$input'.out.webm"'
|
--pass=1 --passes=2 --fpf="'$input'.fpf" --webm -o "'$input'.out.webm"'
|
||||||
|
|
||||||
|
retval=$?
|
||||||
|
if [ $retval -ne 0 ]; then
|
||||||
|
echo "Error running encode pass 1"
|
||||||
|
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
||||||
|
echo ""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
||||||
-i "'$input'" '$ffmpego' -pix_fmt yuv444p -f yuv4mpegpipe - | aomenc - --i444 '$aomenco' \
|
-i "'$input'" '$ffmpego' -vf scale='$height':'$width' -pix_fmt yuv422p -f yuv4mpegpipe - | aomenc - --i422 '$aomenco' \
|
||||||
--pass=2 --passes=2 --fpf="'$input.fpf'" --webm -o "'$input'.out.webm"'
|
--pass=2 --passes=2 --fpf="'$input'.fpf" --webm -o "'$input'.out.webm"'
|
||||||
|
|
||||||
|
retval=$?
|
||||||
|
if [ $retval -ne 0 ]; then
|
||||||
|
echo "Error running encode pass 2"
|
||||||
|
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
||||||
|
echo ""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
|
||||||
else
|
else
|
||||||
|
set +e
|
||||||
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
||||||
-i "'$input'" '$ffmpego' -pix_fmt yuv444p -f yuv4mpegpipe - | aomenc - --i444 '$aomenco' \
|
-i "'$input'" '$ffmpego' -vf scale='$height':'$width' -pix_fmt yuv422p -f yuv4mpegpipe - | aomenc - --i422 '$aomenco' \
|
||||||
--passes=1 --fpf="'$input.fpf'" --webm -o "'$input.out.webm'"'
|
--passes=1 --fpf="'$input'.fpf" --webm -o "'$input'.out.webm"'
|
||||||
|
|
||||||
|
retval=$?
|
||||||
|
if [ $retval -ne 0 ]; then
|
||||||
|
echo "Error running encode"
|
||||||
|
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
||||||
|
echo ""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set +e
|
||||||
curl -s -L "$base_url"/edit_status/"$job_id"/completed
|
curl -s -L "$base_url"/edit_status/"$job_id"/completed
|
||||||
|
set -e
|
||||||
|
|
||||||
done
|
done
|
@ -24,15 +24,17 @@ pub struct WDesc {
|
|||||||
pub file_name: String,
|
pub file_name: String,
|
||||||
pub priority: u16,
|
pub priority: u16,
|
||||||
pub length: u32,
|
pub length: u32,
|
||||||
pub options: EOptions,
|
pub resolution: (u16, u16),
|
||||||
|
pub options: EOptions
|
||||||
}
|
}
|
||||||
impl WDesc {
|
impl WDesc {
|
||||||
pub fn new(file_url: &str, file_name: &str, priority: Option<u16>, length: u32, options: Option<EOptions>) -> Self {
|
pub fn new(file_url: &str, file_name: &str, priority: Option<u16>, length: u32, resolution: (u16, u16), options: Option<EOptions>) -> Self {
|
||||||
WDesc {
|
WDesc {
|
||||||
file_url: file_url.to_string(),
|
file_url: file_url.to_string(),
|
||||||
file_name: file_name.to_string(),
|
file_name: file_name.to_string(),
|
||||||
priority: priority.unwrap_or(0),
|
priority: priority.unwrap_or(0),
|
||||||
length: length,
|
length: length,
|
||||||
|
resolution: resolution,
|
||||||
options: options.unwrap_or(EOptions::default()),
|
options: options.unwrap_or(EOptions::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,7 +45,7 @@ impl WDesc {
|
|||||||
pub struct EOptions {
|
pub struct EOptions {
|
||||||
pub ffmpeg: String,
|
pub ffmpeg: String,
|
||||||
pub aomenc: String,
|
pub aomenc: String,
|
||||||
pub two_pass: bool
|
pub two_pass: bool,
|
||||||
}
|
}
|
||||||
impl Default for EOptions {
|
impl Default for EOptions {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
3
test.sh
3
test.sh
@ -15,9 +15,10 @@ curl "$base_url"/add_job -X POST -H "Content-Type: application/json" -d \
|
|||||||
"file_name": "014",
|
"file_name": "014",
|
||||||
"priority": 0,
|
"priority": 0,
|
||||||
"length": 15,
|
"length": 15,
|
||||||
|
"resolution": [540, 960],
|
||||||
"options": {
|
"options": {
|
||||||
"aomenc": "--lag-in-frames=25 --tile-columns=0 --tile-rows=0 --enable-fwd-kf=1 --bit-depth=10 --cpu-used=0 --end-usage=vbr --target-bitrate=60 --kf-min-dist=9999 --kf-max-dist=9999",
|
"aomenc": "--lag-in-frames=25 --tile-columns=0 --tile-rows=0 --enable-fwd-kf=1 --bit-depth=10 --cpu-used=0 --end-usage=vbr --target-bitrate=60 --kf-min-dist=9999 --kf-max-dist=9999",
|
||||||
"ffmpeg": "-vf scale=540:960",
|
"ffmpeg": "",
|
||||||
"two_pass": true
|
"two_pass": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user