error handling and hsit

This commit is contained in:
Daniel Løvbrøtte Olsen 2020-03-28 21:59:39 +01:00
parent 50af33522d
commit b92cdefcde
3 changed files with 77 additions and 13 deletions

View File

@ -9,13 +9,24 @@ version="0.2.0"
while true; do
sleep 30
set +e
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
echo "Wrong version: client version is $version, while job server requires $upstream_version"
break
fi
set +e
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 ¯\_(ツ)_/¯"
continue
fi
@ -26,8 +37,15 @@ while true; do
job_id=`echo "$job" | jq -r .id`
echo "Reserving Job"
set +e
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`
sourceext=${source##*.}
@ -38,11 +56,25 @@ while true; do
name=`echo $job | jq -r .description.file_name`
input="$name.$job_id.$sourceext"
set +e
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 "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=${aomenco//[^a-zA-Z0-9_\- =]/}
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`
echo $two_pass
if [[ $two_pass = true ]]; then
set +e
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"'
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 \
-i "'$input'" '$ffmpego' -pix_fmt yuv444p -f yuv4mpegpipe - | aomenc - --i444 '$aomenco' \
--pass=2 --passes=2 --fpf="'$input.fpf'" --webm -o "'$input'.out.webm"'
-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"'
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
set +e
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
-i "'$input'" '$ffmpego' -pix_fmt yuv444p -f yuv4mpegpipe - | aomenc - --i444 '$aomenco' \
--passes=1 --fpf="'$input.fpf'" --webm -o "'$input.out.webm'"'
-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"'
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
set +e
curl -s -L "$base_url"/edit_status/"$job_id"/completed
set -e
done

View File

@ -24,15 +24,17 @@ pub struct WDesc {
pub file_name: String,
pub priority: u16,
pub length: u32,
pub options: EOptions,
pub resolution: (u16, u16),
pub options: EOptions
}
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 {
file_url: file_url.to_string(),
file_name: file_name.to_string(),
priority: priority.unwrap_or(0),
length: length,
resolution: resolution,
options: options.unwrap_or(EOptions::default()),
}
}
@ -43,7 +45,7 @@ impl WDesc {
pub struct EOptions {
pub ffmpeg: String,
pub aomenc: String,
pub two_pass: bool
pub two_pass: bool,
}
impl Default for EOptions {
fn default() -> Self {

View File

@ -15,9 +15,10 @@ curl "$base_url"/add_job -X POST -H "Content-Type: application/json" -d \
"file_name": "014",
"priority": 0,
"length": 15,
"resolution": [540, 960],
"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",
"ffmpeg": "-vf scale=540:960",
"ffmpeg": "",
"two_pass": true
}
}