record.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. function start() {
  3. mkdir -p $VIDEO_PATH
  4. name="$(date '+%d_%m_%Y_%H_%M_%S').mp4"
  5. echo "Start video recording"
  6. ffmpeg -video_size 1599x899 -framerate 15 -f x11grab -i $DISPLAY $VIDEO_PATH/$name -y
  7. }
  8. function stop() {
  9. echo "Stop video recording"
  10. kill $(ps -ef | grep [f]fmpeg | awk '{print $2}')
  11. }
  12. function auto_record() {
  13. echo "Auto record: $AUTO_RECORD"
  14. sleep 6
  15. while [ "$AUTO_RECORD" = true ]; do
  16. # Check if there is test running
  17. no_test=true
  18. while $no_test; do
  19. task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
  20. if [ "$task" = "" ] || [ "$task" = "[]" ]; then
  21. sleep .5
  22. else
  23. start &
  24. no_test=false
  25. fi
  26. done
  27. # Check if test is finished
  28. while [ $no_test = false ]; do
  29. task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
  30. if [ "$task" = "" ] || [ "$task" = "[]" ]; then
  31. stop
  32. no_test=true
  33. else
  34. sleep .5
  35. fi
  36. done
  37. done
  38. echo "Auto recording is disabled!"
  39. }
  40. $@