]>
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 x month x
<<<"$dir"
15 test -n "$year" || exec "$0" "$user"/2*/src
/*/
16 test -n "$month" || exec "$0" "$user"/"$year"/src
/*/
17 pushd "$user/$year" >/dev
/null
18 test -d src
/"$month" || { popd; continue; }
19 (cd src
; find -L "$month" -type f
-size +180M
-printf '%f %p\n') | sort -t/ -k1.5
| cut
-f2 -d ' ' |
21 echo >&2 "$dir: processing $year/src/$src"
25 mkdir -p {{tmp
,wip
}/reencode
,old
}/"${base%/*}"
27 # Slow, but needed to make wide videos span two columns of the CSS grid
28 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")"
30 (90|-90) w
=$width; width
=$height; height
=$w;;
32 if [ "$width" -gt "$height" ]
47 ext
="preset=$preset.crf=$crf.av1.webm"
49 test tmp
/reencode
/"$base".opus
-nt src
/"$src" || {
50 ffmpeg_
-i src
/"$src" \
51 -map 0:a
-c:a libopus
-b:a
64k
-application voip \
52 wip
/reencode
/"$base".opus
53 mv_
{wip
,tmp
}/reencode
/"$base".opus
56 test src
/"$base.$ext" -nt src
/"$src" || {
58 ffmpeg_
-i src
/"$src" -i tmp
/reencode
/"$base".opus \
60 -filter:v format
=yuv420p \
61 -c:v libsvtav1
-preset "$preset" -crf "$crf" \
62 -svtav1-params input
-depth=8:keyint
=10s
:enable-overlays=1:enable-tf=0:scd
=1:scm
=0:tune
=0:fast
-decode=1 \
64 wip
/reencode
/"$base.$ext"
65 mv_
{wip
/reencode
,src
}/"$base.$ext"
71 rm -vrf {tmp
,wip
}/reencode