nix/bin/record.nix (view raw)
1{ pkgs, ... }:
2
3let
4 name = "record";
5 slop = "${pkgs.slop}/bin/slop";
6 ffmpeg = "${pkgs.ffmpeg}/bin/ffmpeg";
7in
8pkgs.writeScriptBin name
9 ''
10 echo starting recording ...
11 coords=$(${slop} -f "%x %y %w %h %g %i") || exit 1
12 read -r X Y W H G ID < <(echo $coords)
13 ${ffmpeg} \
14 -f x11grab \
15 -s "$W"x"$H" \
16 -i :0.0+$X,$Y \
17 -f alsa \
18 -thread_queue_size 512 \
19 -ac 2 \
20 -ar 48000 \
21 -i hw:0 \
22 -framerate 60 \
23 -vcodec libx264 \
24 -threads 4 \
25 -y \
26 /home/icy/tmp/x.mkv
27
28 ${ffmpeg} \
29 -i /home/icy/tmp/x.mkv \
30 -pix_fmt yuv420p \
31 -vf scale=-2:1080 \
32 "/home/icy/vids/rec/$1"
33 ''