]>
Git — Sourcephile - julm/camera.git/blob - reencode.sh
2 # Copyright: Julien Moutinho <julm+camera@sourcephile.fr>
3 # License: AGPL-3.0-or-later
10 ffmpeg_
() { local -; set -x; nice
-19 time ffmpeg
</dev
/null
-hide_banner -loglevel warning
-stats -y "$@"; }
11 mv_
() { local -; mv -i >&2 "$@"; }
14 IFS
=/ read -r user year
cat month x
<<<"$dir"
16 test -f "$dir" || listing
=1
19 test -n "$year" || exec "$0" "$user"/2*/src
/*/
20 test -n "$month" || exec "$0" "$user"/"$year"/src
/*/
21 pushd "$user/$year" >/dev
/null
22 test -d src
/"$month" || { popd; continue; }
24 pushd "$user/$year" >/dev
/null
27 then (cd src
; find -L "$month" -type f
-size +100M
-printf '%f %p\n') | sort -t/ -k1.5
| cut
-f2 -d ' '
28 else printf '%s\n' "${dir#"$user/$year/$cat/"}"
31 echo >&2 "$dir: processing $user/$year/src/$src"
35 mkdir -p {{tmp
,wip
}/reencode
,old
}/"${base%/*}"
37 # Slow, but needed to make wide videos span two columns of the CSS grid
38 IFS
=' ' read -r width height rotation
<<<"$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height:stream_side_data=rotation -of csv=p=0:s='\ ' src/"$src")"
40 (90|-90) w
=$width; width
=$height; height
=$w;;
42 if [ "$width" -gt "$height" ]
57 ext
="preset=$preset.crf=$crf.av1.webm"
59 test tmp
/reencode
/"$base".opus
-nt src
/"$src" || {
60 ffmpeg_
-i src
/"$src" \
61 -map 0:a
-c:a libopus
-b:a
64k
-application voip \
62 wip
/reencode
/"$base".opus
63 mv_
{wip
,tmp
}/reencode
/"$base".opus
66 test src
/"$base.$ext" -nt src
/"$src" || {
68 ffmpeg_
-i src
/"$src" -i tmp
/reencode
/"$base".opus \
70 -filter:v format
=yuv420p \
71 -c:v libsvtav1
-preset "$preset" -crf "$crf" \
72 -svtav1-params input
-depth=8:keyint
=10s
:enable-overlays=1:enable-tf=0:scd
=1:scm
=0:tune
=0:fast
-decode=1 \
74 wip
/reencode
/"$base.$ext"
75 mv_
{wip
/reencode
,src
}/"$base.$ext"
81 rm -vrf {tmp
,wip
}/reencode