ffmpeg scripts update

This commit is contained in:
Ingolf Wagner 2021-02-27 21:48:40 +01:00
parent 85cd11822c
commit eb817f4f5f
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 28 additions and 6 deletions

View file

@ -58,7 +58,7 @@ in {
advanced.pan_id = 1337;
# add last seen information
advanced.last_seen = "ISO_8601_local";
advanced.last_seen = "ISO_8601_local";
# configure web ui
frontend.port = 9666;

View file

@ -5,13 +5,14 @@ let
cfg = config.programs.custom.ffmpeg;
ffmpegTemplate = name:
{ profile, preset, tune ? null }:
{ profile, preset, tune ? null, width ? 1280, height ? 720
, resolution ? "720p" }:
pkgs.writeShellScriptBin "ffmpeg-${name}" ''
if [ $# -eq 0 ]
then
cat <<EOF
ffmpeg-<profile>-<preset>-<tunes>-720p <input> <output>
ffmpeg-<profile>-<preset>-<tunes>-${resolution} <input> <output>
profiles =
"baseline" - Primarily for low-cost applications that require additional data loss robustness
@ -62,7 +63,9 @@ let
exec ${pkgs.ffmpeg}/bin/ffmpeg \
-i "$input" \
-filter:v scale=h='min(720\,ih)':w='min(1280\,iw)' \
-filter:v scale=h='min(${toString height}\,ih)':w='min(${
toString width
}\,iw)' \
-vcodec libx264 \
-preset ${preset} \
-profile:v ${profile} \
@ -77,11 +80,27 @@ let
ffmpegDescriptive = profile: preset:
ffmpegTemplate "${profile}-${preset}-720p" { inherit profile preset; };
ffmpegDescriptive1080p = profile: preset:
ffmpegTemplate "${profile}-${preset}-1080p" {
inherit profile preset;
height = 1080;
width = 1920;
resolution = "1080p";
};
ffmpegDescriptiveTune = profile: preset: tune:
ffmpegTemplate "${profile}-${preset}-${tune}-720p" {
inherit profile preset tune;
};
ffmpegDescriptiveTune1080p = profile: preset: tune:
ffmpegTemplate "${profile}-${preset}-${tune}-720p" {
inherit profile preset tune;
height = 1080;
width = 1920;
resolution = "1080p";
};
# https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Profiles
profiles = [
"baseline"
@ -104,9 +123,12 @@ let
];
tunes = [ "film" "animation" "grain" "stillimage" "fastdecode" ];
ffmpegs = lib.crossLists ffmpegDescriptive [ profiles presets ];
ffmpegs = (lib.crossLists ffmpegDescriptive [ profiles presets ])
++ (lib.crossLists ffmpegDescriptive1080p [ profiles presets ]);
ffmpegsTune = lib.crossLists ffmpegDescriptiveTune [ profiles presets tunes ];
ffmpegsTune =
(lib.crossLists ffmpegDescriptiveTune [ profiles presets tunes ])
++ (lib.crossLists ffmpegDescriptiveTune1080p [ profiles presets tunes ]);
in {