0.11.0 WIP
Former-commit-id: 94fcad7d7cf1f7733a2f773572c1b0990a31232d
This commit is contained in:
parent
121b1df927
commit
6e89300675
12
src/main.rs
12
src/main.rs
@ -19,7 +19,7 @@ mod workunit;
|
|||||||
use workunit::WUnit;
|
use workunit::WUnit;
|
||||||
use workunit::EStatus;
|
use workunit::EStatus;
|
||||||
|
|
||||||
const VERSION: &str = "0.10.0";
|
const VERSION: &str = "0.11.0";
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
struct SharedState {
|
struct SharedState {
|
||||||
@ -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", baseurl="https://av1.dodsorf.as", version=VERSION)
|
curl -L {baseurl}/av1client > av1client && chmod +x ./av1client && ./av1client {baseurl}", baseurl="https://av1.dodsorf.as", version=VERSION)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/version")]
|
#[get("/version")]
|
||||||
@ -134,5 +134,13 @@ fn main() {
|
|||||||
.manage(SharedState::default())
|
.manage(SharedState::default())
|
||||||
.mount("/", StaticFiles::from("src/static")) // switch to templates or something cause this is dumb
|
.mount("/", StaticFiles::from("src/static")) // switch to templates or something cause this is dumb
|
||||||
.mount("/", routes![index, version, get_jobs, get_job, request_job, edit_status, add_job, upload])
|
.mount("/", routes![index, version, get_jobs, get_job, request_job, edit_status, add_job, upload])
|
||||||
|
.mount("/", routes![test_job])
|
||||||
.launch();
|
.launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[get("/test_job/<jobset>")]
|
||||||
|
fn test_job(jobset: String, shared: State<SharedState>) {
|
||||||
|
let id = uuid::Uuid::new_v4();
|
||||||
|
shared.jobs.lock().unwrap().insert(id, WUnit::new(id, jobset, workunit::WDesc::new("https://pomf.dodsorf.as/f/vz9dtl.mkv", "014", None, 90, (540, 960), None)));
|
||||||
|
}
|
@ -3,8 +3,8 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
base_url="https://av1.dodsorf.as"
|
base_url="$1"
|
||||||
version="0.10.0"
|
version="0.11.0"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
sleep 30
|
sleep 30
|
||||||
@ -71,96 +71,121 @@ while true; do
|
|||||||
|
|
||||||
echo "Starting Encode"
|
echo "Starting Encode"
|
||||||
|
|
||||||
|
etype=`echo $job | jq -r '.description.options | keys | .[]'`
|
||||||
|
|
||||||
|
if [$etype != "FFMPEG"] || [$etype != "AOMENC" ]; then
|
||||||
|
echo "That's not a valid encoder!! Are you being attacked?"
|
||||||
|
fi
|
||||||
|
|
||||||
height=`echo $job | jq -r .description.resolution[0]`
|
height=`echo $job | jq -r .description.resolution[0]`
|
||||||
width=`echo $job | jq -r .description.resolution[1]`
|
width=`echo $job | jq -r .description.resolution[1]`
|
||||||
|
|
||||||
echo $job | jq
|
echo $job | jq
|
||||||
|
|
||||||
aomenco=`echo $job | jq -r .description.options.aomenc`
|
options=`echo $job | jq .description.options.$etype`
|
||||||
aomenco=${aomenco//[^a-zA-Z0-9_\- =]/}
|
|
||||||
ffmpego=`echo $job | jq -r .description.options.ffmpeg`
|
|
||||||
ffmpego=${ffmpego//[^a-zA-Z0-9_\- =:]/}
|
|
||||||
|
|
||||||
pix_fmt=`echo $job | jq -r .description.options.pix_fmt`
|
case $etype in
|
||||||
if [[ $pix_fmt = "YV12" ]]; then
|
AOMENC)
|
||||||
ffpix="yuv12p"
|
aomenco=`echo $options | jq -r .aomenc`
|
||||||
aompix="--yv12"
|
aomenco=${aomenco//[^a-zA-Z0-9_\- =]/}
|
||||||
elif [[ $pix_fmt = "I420" ]]; then
|
ffmpego=`echo $options | jq -r .ffmpeg`
|
||||||
ffpix="yuv420p"
|
ffmpego=${ffmpego//[^a-zA-Z0-9_\- =:]/}
|
||||||
aompix="--i420"
|
|
||||||
elif [[ $pix_fmt = "I422" ]]; then
|
pix_fmt=`echo $job | jq -r .pix_fmt`
|
||||||
ffpix="yuv422p"
|
if [[ $pix_fmt = "YV12" ]]; then
|
||||||
aompix="--i422"
|
ffpix="yuv12p"
|
||||||
elif [[ $pix_fmt = "I444" ]]; then
|
aompix="--yv12"
|
||||||
ffpix="yuv444p"
|
elif [[ $pix_fmt = "I420" ]]; then
|
||||||
aompix="--i444"
|
ffpix="yuv420p"
|
||||||
fi
|
aompix="--i420"
|
||||||
|
elif [[ $pix_fmt = "I422" ]]; then
|
||||||
|
ffpix="yuv422p"
|
||||||
|
aompix="--i422"
|
||||||
|
elif [[ $pix_fmt = "I444" ]]; then
|
||||||
|
ffpix="yuv444p"
|
||||||
|
aompix="--i444"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fps=`echo $job | jq -r .description.options.fps`
|
fps=`echo $options | jq -r .fps`
|
||||||
if [[ $fps = "null" ]]; then
|
if [[ $fps = "null" ]]; then
|
||||||
fffps=""
|
fffps=""
|
||||||
aomfps=""
|
aomfps=""
|
||||||
else
|
else
|
||||||
fpsrate=`echo $fps | jq -r '.[0]'`
|
fpsrate=`echo $fps | jq -r '.[0]'`
|
||||||
fpsscale=`echo $fps | jq -r '.[1]'`
|
fpsscale=`echo $fps | jq -r '.[1]'`
|
||||||
fpsv="$fpsrate/$fpsscale"
|
fpsv="$fpsrate/$fpsscale"
|
||||||
fffps="fps=fps=$fpsv -r $fpsv"
|
fffps="fps=fps=$fpsv -r $fpsv"
|
||||||
aomfps="--fps=$fpsv"
|
aomfps="--fps=$fpsv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
two_pass=`echo $options | jq -r .two_pass`
|
||||||
|
|
||||||
two_pass=`echo $job | jq -r .description.options.two_pass`
|
if [[ $two_pass = true ]]; then
|
||||||
|
set +e
|
||||||
|
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
||||||
|
-i "'$input'" '$ffmpego' -vf scale='$width':'$height','$fffps' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$aomfps' '$aompix' '$aomenco' \
|
||||||
|
--pass=1 --passes=2 --fpf="'$input'.fpf" --ivf -o "'$input'.out.ivf"'
|
||||||
|
|
||||||
if [[ $two_pass = true ]]; then
|
retval=$?
|
||||||
set +e
|
if [ $retval -ne 0 ]; then
|
||||||
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
echo "Error running encode pass 1"
|
||||||
-i "'$input'" '$ffmpego' -vf scale='$width':'$height','$fffps' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$aomfps' '$aompix' '$aomenco' \
|
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
||||||
--pass=1 --passes=2 --fpf="'$input'.fpf" --ivf -o "'$input'.out.ivf"'
|
echo ""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
retval=$?
|
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
||||||
if [ $retval -ne 0 ]; then
|
-i "'$input'" '$ffmpego' -vf scale='$width':'$height','$fffps' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$aomfps' '$aompix' '$aomenco' \
|
||||||
echo "Error running encode pass 1"
|
--pass=2 --passes=2 --fpf="'$input'.fpf" --ivf -o "'$input'.out.ivf"'
|
||||||
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
|
||||||
echo ""
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
retval=$?
|
||||||
-i "'$input'" '$ffmpego' -vf scale='$width':'$height','$fffps' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$aomfps' '$aompix' '$aomenco' \
|
if [ $retval -ne 0 ]; then
|
||||||
--pass=2 --passes=2 --fpf="'$input'.fpf" --ivf -o "'$input'.out.ivf"'
|
echo "Error running encode pass 2"
|
||||||
|
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
||||||
|
echo ""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
|
||||||
retval=$?
|
echo "Deleting Source and Temporary files"
|
||||||
if [ $retval -ne 0 ]; then
|
rm "$input" "$input".fpf
|
||||||
echo "Error running encode pass 2"
|
|
||||||
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
|
||||||
echo ""
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "Deleting Source and Temporary files"
|
else
|
||||||
rm "$input" "$input".fpf
|
set +e
|
||||||
|
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
||||||
|
-i "'$input'" '$ffmpego' -vf scale='$width':'$height','$fffps' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$aomfps' '$aompix' '$aomenco' \
|
||||||
|
--passes=1 --fpf="'$input'.fpf" --ivf -o "'$input'.out.ivf"'
|
||||||
|
|
||||||
else
|
retval=$?
|
||||||
set +e
|
if [ $retval -ne 0 ]; then
|
||||||
eval 'ffmpeg -nostats -hide_banner -loglevel warning \
|
echo "Error running encode"
|
||||||
-i "'$input'" '$ffmpego' -vf scale='$width':'$height','$fffps' -pix_fmt '$ffpix' -f yuv4mpegpipe - | aomenc - '$aomfps' '$aompix' '$aomenco' \
|
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
||||||
--passes=1 --fpf="'$input'.fpf" --ivf -o "'$input'.out.ivf"'
|
echo ""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
|
||||||
retval=$?
|
echo "Deleting Source"
|
||||||
if [ $retval -ne 0 ]; then
|
rm "$input"
|
||||||
echo "Error running encode"
|
fi
|
||||||
curl -s -L "$base_url"/edit_status/"$job_id"/error || true
|
;;
|
||||||
echo ""
|
FFMPEG)
|
||||||
continue
|
echo "Starting FFMPEG encode"
|
||||||
fi
|
if [[ $two_pass = true ]]; then
|
||||||
set -e
|
echo "Running in two-pass mode"
|
||||||
|
|
||||||
echo "Deleting Source"
|
options=`echo $job | jq -r .options.$etype`
|
||||||
rm "$input"
|
|
||||||
fi
|
pix_fmt=`echo $options | jq -r .pix_fmt`
|
||||||
|
tiles=`echo $options | jq -r .tiles`
|
||||||
|
lag_in_frames=`echo $options | jq -r .lag_in_frames`
|
||||||
|
|
||||||
|
set +e
|
||||||
|
ffmpeg -i $input -c:v libaom-av1 -strict experimental -pass 1 -an -vf scale=$width:$height -pix_fmt $pix_fmt -tiles $tiles -lag-in-frames $lag_in_frames $flag_g -f ivf /dev/null
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
curl -s -L "$base_url"/edit_status/"$job_id"/completed
|
curl -s -L "$base_url"/edit_status/"$job_id"/completed
|
||||||
|
@ -49,27 +49,62 @@ impl WDesc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub enum EOptions {
|
||||||
|
AOMENC(AomencO),
|
||||||
|
FFMPEG(FffmpegO)
|
||||||
|
}
|
||||||
|
impl Default for EOptions {
|
||||||
|
fn default() -> Self {
|
||||||
|
let default = AomencO::default();
|
||||||
|
EOptions::AOMENC(default)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct EOptions {
|
pub struct AomencO {
|
||||||
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,
|
||||||
pub fps: (u16, u16)
|
pub fps: (u16, u16)
|
||||||
}
|
}
|
||||||
impl Default for EOptions {
|
impl Default for AomencO {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
EOptions{
|
AomencO{
|
||||||
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=35 --tile-columns=0 --tile-rows=0 --enable-fwd-kf=1 --bit-depth=10 --cpu-used=4 --cq-level=30 --end-usage=q".to_string(),
|
||||||
two_pass: false,
|
two_pass: true,
|
||||||
pix_fmt: EPixFmt::I422,
|
pix_fmt: EPixFmt::I422,
|
||||||
fps: (25, 1)
|
fps: (25, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub struct FffmpegO {
|
||||||
|
pub two_pass: bool,
|
||||||
|
pub crf: u8,
|
||||||
|
pub b_v: String,
|
||||||
|
pub lag_in_frames: u8,
|
||||||
|
pub pix_fmt: String,
|
||||||
|
pub tiles: String,
|
||||||
|
pub speed: u8
|
||||||
|
}
|
||||||
|
impl Default for FffmpegO {
|
||||||
|
fn default() -> Self {
|
||||||
|
FffmpegO {
|
||||||
|
two_pass: true,
|
||||||
|
crf: 30,
|
||||||
|
b_v: "0".to_string(),
|
||||||
|
lag_in_frames: 35,
|
||||||
|
pix_fmt: "yuv420p10le"
|
||||||
|
tiles: "1x1".to_string(),
|
||||||
|
speed: 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
||||||
pub enum EStatus {
|
pub enum EStatus {
|
||||||
Queued,
|
Queued,
|
||||||
|
14
test.sh
14
test.sh
@ -8,7 +8,7 @@ curl "$base_url"
|
|||||||
|
|
||||||
curl "$base_url"/get_jobs | jq
|
curl "$base_url"/get_jobs | jq
|
||||||
|
|
||||||
curl "$base_url"/add_job -X POST -H "Content-Type: application/json" -d \
|
curl "$base_url"/add_job/b -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",
|
||||||
@ -17,11 +17,13 @@ curl "$base_url"/add_job -X POST -H "Content-Type: application/json" -d \
|
|||||||
"length": 90,
|
"length": 90,
|
||||||
"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",
|
"FFMPEG": {
|
||||||
"ffmpeg": "",
|
"two_pass": true,
|
||||||
"two_pass": true,
|
"crf": 45,
|
||||||
"pix_fmt": "YV12",
|
"b_v": "0",
|
||||||
"fps": [24000, 1001]
|
"tiles": "1x1",
|
||||||
|
"speed": 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'
|
'
|
||||||
|
Loading…
Reference in New Issue
Block a user