executable_record-window 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. # Origin <https://ask.fedoraproject.org/en/question/10272/how-can-i-capture-a-video-of-my-screen-in-fedora/?answer=38332#post-id-38332>.
  3. NAME=screencast-$(date +%Y%m%d%H%M)
  4. FPS=30
  5. # THREADS=3
  6. tmpfile=screengrab.tmp.$$
  7. trap 'touch $tmpfile; rm -f $tmpfile' 0
  8. xwininfo > $tmpfile 2>/dev/null
  9. left=$(grep 'Absolute upper-left X:' $tmpfile | awk '{print $4}');
  10. top=$(grep 'Absolute upper-left Y:' $tmpfile | awk '{print $4}');
  11. width=$(grep 'Width:' $tmpfile | awk '{print $2}');
  12. height=$(grep 'Height:' $tmpfile | awk '{print $2}');
  13. geom="-geometry ${width}x${height}+${left}+${top}"
  14. echo "Geometry: ${geom}"
  15. size="${width}x${height}"
  16. pos="${left},${top}"
  17. echo "pos=$pos size=$size"
  18. sleep 2
  19. ffmpeg -y \
  20. -f x11grab \
  21. -r $FPS \
  22. -video_size "$size" \
  23. -i "${DISPLAY-0:0}"+"${pos}" \
  24. -c:v ffvhuff \
  25. "$NAME".mkv \
  26. "$@"
  27. # palette="palette.png"
  28. # filters="fps=$FPS,scale=0:-1:flags=lanczos"
  29. # ffmpeg -v warning -i $NAME.mkv -vf "$filters,palettegen" -threads $THREADS -y $palette
  30. # ffmpeg -v warning -i $NAME.mkv -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -threads $THREADS -y $NAME.gif
  31. # rm -f $palette