add framerate options

Former-commit-id: 340d6cf9e0212cdb596f95007249887f504005e9
This commit is contained in:
Daniel Løvbrøtte Olsen 2020-04-21 13:59:52 +02:00
parent b2d9f4f40b
commit 88dbfdc6d4
4 changed files with 22 additions and 12 deletions

View File

@ -30,7 +30,7 @@ struct SharedState {
fn index() -> String { fn index() -> String {
format!("Wecome to the AV1Master Server version {version}\n format!("Wecome to the AV1Master Server version {version}\n
This currently requires a distro with CAP_SYS_USER_NS enabled and correct permissions This currently requires a distro with CAP_SYS_USER_NS enabled and correct permissions
curl -L {baseurl}/av1client > av1client && chmod +x ./av1client && ./av1client", version=VERSION) curl -L {baseurl}/av1client > av1client && chmod +x ./av1client && ./av1client", baseurl="https://av1.dodsorf.as", version=VERSION)
} }
#[get("/version")] #[get("/version")]

View File

@ -4,7 +4,7 @@ set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
base_url="https://av1.dodsorf.as" base_url="https://av1.dodsorf.as"
version="0.5.0" version="0.6.0"
while true; do while true; do
sleep 30 sleep 30
@ -88,20 +88,29 @@ while true; do
elif [[ $pix_fmt = "I420" ]]; then elif [[ $pix_fmt = "I420" ]]; then
ffpix="yuv420p" ffpix="yuv420p"
aompix="--i420" aompix="--i420"
elif [[ $pix_fmt = I422 ]]; then elif [[ $pix_fmt = "I422" ]]; then
ffpix="yuv422p" ffpix="yuv422p"
aompix="--i422" aompix="--i422"
elif [[ $pix_fmt = I444 ]]; then elif [[ $pix_fmt = "I444" ]]; then
ffpix="yuv444p" ffpix="yuv444p"
aompix="--i444" aompix="--i444"
fi fi
fps=`echo $job | jq -r .description.options.fps`
if [[ $fps = "null" ]]; then
fpsoption=""
else
fpsrate=`echo $fps | jq -r '.[0]'`
fpsscale=`echo $fps | jq -r '.[1]'`
fpsoption="$fpsrate/$fpsscale"
fi
two_pass=`echo $job | jq -r .description.options.two_pass` two_pass=`echo $job | jq -r .description.options.two_pass`
if [[ $two_pass = true ]]; then if [[ $two_pass = true ]]; then
set +e set +e
eval 'ffmpeg -nostats -hide_banner -loglevel warning \ eval 'ffmpeg -nostats -hide_banner -loglevel warning \
-i "'$input'" '$ffmpego' -vf scale='$height':'$width' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$aompix' '$aomenco' \ -i "'$input'" '$ffmpego' -vf scale='$height':'$width' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$fpsoption' '$aompix' '$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=$? retval=$?
@ -113,7 +122,7 @@ while true; do
fi fi
eval 'ffmpeg -nostats -hide_banner -loglevel warning \ eval 'ffmpeg -nostats -hide_banner -loglevel warning \
-i "'$input'" '$ffmpego' -vf scale='$height':'$width' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$aompix' '$aomenco' \ -i "'$input'" '$ffmpego' -vf scale='$height':'$width' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$fpsoption' '$aompix' '$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=$? retval=$?
@ -131,7 +140,7 @@ while true; do
else else
set +e set +e
eval 'ffmpeg -nostats -hide_banner -loglevel warning \ eval 'ffmpeg -nostats -hide_banner -loglevel warning \
-i "'$input'" '$ffmpego' -vf scale='$height':'$width' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$aompix' '$aomenco' \ -i "'$input'" '$ffmpego' -vf scale='$height':'$width' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$fpsoption' '$aompix' '$aomenco' \
--passes=1 --fpf="'$input'.fpf" --webm -o "'$input'.out.webm"' --passes=1 --fpf="'$input'.fpf" --webm -o "'$input'.out.webm"'
retval=$? retval=$?
@ -166,6 +175,4 @@ while true; do
echo "Upload finished, deleting result!" echo "Upload finished, deleting result!"
rm "$input".out.webm rm "$input".out.webm
fi fi
done done

View File

@ -47,7 +47,9 @@ pub struct EOptions {
pub ffmpeg: String, pub ffmpeg: String,
pub aomenc: String, pub aomenc: String,
pub two_pass: bool, pub two_pass: bool,
pub pix_fmt: EPixFmt pub pix_fmt: EPixFmt,
#[serde(default)]
pub fps: Option<(u16, u16)>
} }
impl Default for EOptions { impl Default for EOptions {
fn default() -> Self { fn default() -> Self {
@ -55,7 +57,8 @@ impl Default for EOptions {
ffmpeg: String::default(), ffmpeg: String::default(),
aomenc: "--lag-in-frames=25 --tile-columns=0 --tile-rows=0 --enable-fwd-kf=1 --bit-depth=10 --cpu-used=3 --cq-level=30 --end-usage=q".to_string(), aomenc: "--lag-in-frames=25 --tile-columns=0 --tile-rows=0 --enable-fwd-kf=1 --bit-depth=10 --cpu-used=3 --cq-level=30 --end-usage=q".to_string(),
two_pass: false, two_pass: false,
pix_fmt: EPixFmt::I422 pix_fmt: EPixFmt::I422,
fps: Option::None
} }
} }
} }

View File

@ -14,7 +14,7 @@ curl "$base_url"/add_job -X POST -H "Content-Type: application/json" -d \
"file_url": "https://pomf.dodsorf.as/f/vz9dtl.mkv", "file_url": "https://pomf.dodsorf.as/f/vz9dtl.mkv",
"file_name": "014", "file_name": "014",
"priority": 0, "priority": 0,
"length": 15, "length": 20,
"resolution": [540, 960], "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",