phone: Move pinephone video script to separate package

Now it's possible to use the video recording script outside of fish.
This commit is contained in:
Donovan Glover 2024-09-08 19:29:33 -04:00
parent 58e227efc0
commit 5df2225472
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 73 additions and 24 deletions

View File

@ -47,30 +47,7 @@ in
; ;
config = { config = {
programs = { programs.man.generateCaches = mkForce false;
fish.functions.video = # fish
''
${pkgs.v4l-utils}/bin/media-ctl -d1 --links '"gc2145 3-003c":0->1:0[0],"ov5640 3-004c":0->1:0[1]'
${pkgs.v4l-utils}/bin/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"
'';
man.generateCaches = mkForce false;
};
xdg = { xdg = {
desktopEntries = { desktopEntries = {

View File

@ -0,0 +1,72 @@
{
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;
};
}