Guest User

Untitled

a guest
Dec 1st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. # /bin/sh
  2. # ./record.sh -i 192.168.0.47:554 -v 11 -r 1280x720
  3. # Some sane defaults for the environment.
  4. DATE=`date +%Y-%m-%d`
  5. TIME=`date +%H-%M-%S`
  6. CAMERA_USER='admin'
  7. CAMERA_PASS='admin'
  8. CAMERA_IP='10.10.10.1'
  9. CAMERA_NAME='cam1'
  10.  
  11. # Destination for recordings. Directors
  12. DEST_DIR=$CAMERA
  13.  
  14. # Duration of segments in seconds.
  15. SEGMENT_DURATION='5'
  16.  
  17. # Group of Pictures size.
  18. GOP_SIZE='12'
  19.  
  20. # Output resolution.
  21. RECORDING_RESOLUTION='720x576'
  22.  
  23. # Path to to the camera stream.
  24. VIDEO_PATH='/stream1'
  25.  
  26. # Help printer.
  27.  
  28. function help {
  29. echo "Usage: record.sh [OPTION]"
  30. echo "Launch FFMPEG against the specified RTSP stream and tee the result"
  31. echo "to disk | udp."
  32. echo " "
  33. echo "-u camera username"
  34. echo "-p camera password"
  35. echo "-i camera IP address or hostname"
  36. echo "-n aamera name, used when creating an output"
  37. echo " directory"
  38. echo "-s duration of recorded segments in seconds."
  39. echo "-d top level destination directory. Recordings"
  40. echo " will be placed in a <name> subdirectory."
  41. echo "-v path to the camera RTSP stream. Typically"
  42. echo " /video, /stream, /h264 or similar."
  43. echo "-r recording resolution in the form '640x480'"
  44. echo "-g GOP size used when recording."
  45. echo "-h display this help and exit."
  46. echo "-o seconary output desination"
  47. }
  48.  
  49. # Simple command line argument handling.
  50. while getopts ':u:p:i:n:s:d:v:r:g:h' flag
  51.  
  52. do
  53. case $flag in
  54. u) CAMERA_USER=$OPTARG;;
  55. p) CAMERA_PASS=$OPTARG;;
  56. i) CAMERA_IP=$OPTARG;;
  57. n) CAMERA_NAME=$OPTARG;;
  58. s) SEGMENT_DURATION=$OPTARG;;
  59. d) DEST_DIR=$OPTARG;;
  60. v) VIDEO_PATH=$OPTARG;;
  61. r) RECORDING_RESOLUTION=$OPTARG;;
  62. g) GOP_SIZE=$OPTARG;;
  63. h) help; exit 0;;
  64. \?) help; exit 2;;
  65. esac
  66. done
  67.  
  68. DEST='./'$CAMERA_NAME
  69.  
  70. # make the directories
  71. rm -rf $DEST
  72. mkdir -p $DEST
  73. mkdir -p $DEST/segments
  74.  
  75. [ -d $DEST ] || mkdir -p $DEST
  76.  
  77. echo ${DEST}/${DATE}_${TIME}_%05d.webm
  78. ffmpeg -re -i rtsp://$CAMERA_USER:$CAMERA_PASS@$CAMERA_IP/$VIDEO_PATH \
  79. -profile:v baseline \
  80. -level 5.0 \
  81. -an \
  82. -f hls \
  83. -reset_timestamps 1 \
  84. -movflags faststart \
  85. -s $RECORDING_RESOLUTION \
  86. -start_number 0 -hls_time 10 -hls_list_size 0 \
  87. -use_localtime 1 -hls_segment_filename "${DEST}/segments/%Y%m%d-%s.ts" \
  88. "${DEST}/index.m3u8"
Add Comment
Please, Sign In to add comment