diff options
author | Raymaekers Luca <luca@spacehb.net> | 2025-01-22 16:33:11 +0100 |
---|---|---|
committer | Raymaekers Luca <luca@spacehb.net> | 2025-01-22 16:33:11 +0100 |
commit | a3ea2d173b486ef2460e28108462c997fba90cc2 (patch) | |
tree | ae21e734233fe627813ac79d391526cc7e0bb622 | |
parent | a5d21a49ccdc6141790085d4bd26b667b8d5618d (diff) |
checkpoint
-rwxr-xr-x | bin/extra/discord_compress | 37 | ||||
-rwxr-xr-x | bin/extra/notes_index | 4 | ||||
-rwxr-xr-x | bin/menuscripts/mdbsrv | 7 |
3 files changed, 43 insertions, 5 deletions
diff --git a/bin/extra/discord_compress b/bin/extra/discord_compress new file mode 100755 index 0000000..eacc364 --- /dev/null +++ b/bin/extra/discord_compress @@ -0,0 +1,37 @@ +#!/bin/sh + +# Compresses a video to a target size, for configuration see VARIABLES +# From: https://trac.ffmpeg.org/wiki/Encode/H.264#Two-PassExample +# +# $1: input file + +# VARIABLES +video_codec="libx264" +audio_codec="aac" +audio_bitrate="96" +target_size="8" + +MEGABIT="8388" + +# Main + +input="$1" +if [ -z "$input" ] +then + >&2 printf 'Usage: discord_compress <input>\n' + exit 1 +fi + +duration="$(date -u -d @"$(ffprobe -show_entries format=duration -v quiet -of csv="p=0" -i "$input")" +'%s')" + +video_bitrate="$(((target_size * MEGABIT / duration) - audio_bitrate))" +[ "$video_bitrate" ] || exit 1 + +common_args="-hide_banner -v quiet -stats -y -hwaccel auto -i $input -c:v $video_codec -b:v ${video_bitrate}K" + +set -ex + +ffmpeg $common_args -pass 1 -an -f null /dev/null +ffmpeg $common_args -pass 2 -c:a "$audio_codec" -b:a "${audio_bitrate}K" compressed_"${input%.*}".mp4 + +rm -f ffmpeg2pass*.log* diff --git a/bin/extra/notes_index b/bin/extra/notes_index index 28942cb..05a2452 100755 --- a/bin/extra/notes_index +++ b/bin/extra/notes_index @@ -22,7 +22,7 @@ do -printf '%f ' \ -exec grep '^# ' -m1 {} \; | sed 's/\(.\+\.md\) # \(.\+\)/- [\2][\1]/' | - sort -t '[' -k 2 -n >> index.md + sort -k 3 -n >> index.md if [ "$(find . -mindepth 2 -maxdepth 2 -type f -name '*.md' | wc -l)" -gt 0 ] then @@ -33,7 +33,7 @@ do -type d \ -not -name '.*'\ -printf '- [%f][%f/index.md]\n' | - sort -t '[' -k 2 >> index.md + sort -k 3 >> index.md fi cd - > /dev/null diff --git a/bin/menuscripts/mdbsrv b/bin/menuscripts/mdbsrv index 81b5109..a7e3416 100755 --- a/bin/menuscripts/mdbsrv +++ b/bin/menuscripts/mdbsrv @@ -2,13 +2,14 @@ services() { cat <<-EOF - 5030 slsksd - 9091 transmission + 5000 dufs 8096 jellyfin - 80 ntfy 24961 miniflux + 80 ntfy 24880 pihole + 5030 slsksd 8384 syncthing + 9091 transmission EOF } |