diff options
author | Leo Vivier <zaeph@zaeph.net> | 2022-12-02 08:51:04 +0100 |
---|---|---|
committer | Leo Vivier <zaeph@zaeph.net> | 2022-12-02 08:51:04 +0100 |
commit | c54df7a0458001693ddd996dc4222e3ff00ad487 (patch) | |
tree | 0ecea1aa0e6196283ece301e0a165256cf2fccd3 /roles/prerec/templates | |
parent | b9fdae5d678fd00ff420c8fa7b4fbf06298aeb1c (diff) | |
download | emacsconf-ansible-c54df7a0458001693ddd996dc4222e3ff00ad487.tar.xz emacsconf-ansible-c54df7a0458001693ddd996dc4222e3ff00ad487.zip |
Prototype upwards fps-limiter
Diffstat (limited to '')
-rwxr-xr-x | roles/prerec/templates/reencode.sh | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/roles/prerec/templates/reencode.sh b/roles/prerec/templates/reencode.sh index 5a0128b..c9c87e1 100755 --- a/roles/prerec/templates/reencode.sh +++ b/roles/prerec/templates/reencode.sh @@ -8,7 +8,12 @@ cpu=4 time_limit="" print_only=false limit_resolution=1080 -limit_fps=30.01 +limit_fps=29.99 + +with_suffix() { + suffix="$1" + echo "$input" | sed "s/--original\.\([a-z0-9]*\$\)/--$suffix\.\\1/" +} while getopts :q:c:t:s OPT; do case $OPT in @@ -33,16 +38,24 @@ shift `expr $OPTIND - 1` OPTIND=1 input="$1" +input_limited="$(with_suffix "original-limited")" output="$2" command="$(cat<<EOF +# Preliminary pass to limit resolution and fps ffmpeg -y -i "$input" $time_limit \ -vf "scale='-1':'min($limit_resolution,ih)', select='eq(n,0)+if(gt(t-prev_selected_t,1/$limit_fps),1,0)'" \ + -c:v rawvideo -c:a pcm_s16le -f nut - | ffmpeg -y -f nut -i - -vf "fps=$limit_fps" "$input_limited" + +# Reencode +ffmpeg -y -i "$input_limited" $time_limit \ + -vf "scale='-1':'min($limit_resolution,ih)', + select='eq(n,0)+if(gt(t-prev_selected_t,1/$limit_fps),1,0)'" \ -c:v libvpx-vp9 -b:v 0 -crf $q -an \ -row-mt 1 -tile-columns 2 -tile-rows 2 -cpu-used $cpu -g 240 \ -pass 1 -f webm -threads $cpu /dev/null && - ffmpeg -y -i "$input" $time_limit \ + ffmpeg -y -i "$input_limited" $time_limit \ -vf "scale='-1':'min($limit_resolution,ih)', select='eq(n,0)+if(gt(t-prev_selected_t,1/$limit_fps),1,0)'" \ -c:v libvpx-vp9 -b:v 0 -crf $q -c:a libopus \ |