aboutsummaryrefslogtreecommitdiff
path: root/scripts/record.nix
blob: d5bfff5f6d7a8a64ab3cba5c6bab427185061c8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{ pkgs, ...}:

let
  name = "record";
  slop = "${pkgs.slop}/bin/slop";
  ffmpeg = "${pkgs.ffmpeg}/bin/ffmpeg";
in
  pkgs.writeScriptBin name
  ''
    echo starting recording ...
    coords=$(${slop} -f "%x %y %w %h %g %i") || exit 1
    read -r X Y W H G ID < <(echo $coords)
    ${ffmpeg} \
      -f x11grab \
      -s "$W"x"$H" \
      -i :0.0+$X,$Y  \
      -f alsa \
      -thread_queue_size 512 \
      -ac 2 \
      -ar 48000 \
      -i hw:0 \
      -framerate 60 \
      -vcodec libx264 \
      -threads 4 \
      -y \
      /home/np/tmp/x.mkv

    ${ffmpeg} \
      -i /home/np/tmp/x.mkv \
      -pix_fmt yuv420p \
      -vf scale=-2:1080 \
      "/home/np/vids/rec/$1"
  ''