nix-config/packages/pinephone-scripts.nix
Donovan Glover 5df2225472
phone: Move pinephone video script to separate package
Now it's possible to use the video recording script outside of fish.
2024-09-08 19:29:34 -04:00

73 lines
1.6 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
lib,
stdenvNoCC,
writeTextFile,
makeWrapper,
fish,
v4l-utils,
ffmpeg,
}:
let
pinephone-video = writeTextFile {
name = "pinephone-video";
text = # fish
''
media-ctl -d1 --links '"gc2145 3-003c":0->1:0[0],"ov5640 3-004c":0->1:0[1]'
media-ctl -d1 --set-v4l2 '"ov5640 3-004c":0[fmt:UYVY8_2X8/1280x720@1/30]'
ffmpeg \
-input_format yuv420p \
-s 1280x720 \
-f video4linux2 \
-thread_queue_size 4096 \
-i /dev/video1 \
-f pulse \
-thread_queue_size 256 \
-i alsa_input.platform-sound.Voice_Call__DigitalMic__source \
-c:a libopus \
-c:v libx264 \
-preset ultrafast \
-qp 23 \
"$(date '+%x%a%R').mp4"
'';
};
in
stdenvNoCC.mkDerivation {
pname = "pinephone-scripts";
version = "0.1.0";
dontUnpack = true;
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
install -Dm755 ${pinephone-video} $out/bin/pinephone-video
runHook postInstall
'';
postInstall = ''
for bin in $out/bin/*; do
wrapProgram "$bin" \
--prefix PATH ":" "${
lib.makeBinPath [
fish
v4l-utils
ffmpeg
]
}"
done
'';
meta = {
homepage = "https://github.com/donovanglover/nix-config";
description = "PinePhone-specific scripts like video recording";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ donovanglover ];
platforms = lib.platforms.linux;
};
}