Guest User

Phyrne's HD PVR Capture Script

a guest
Sep 18th, 2012
260
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/sh
  2.  
  3. ### Phyrne's HD PVR capture script ###
  4.  
  5. # Set an alias for the device
  6. HDPVR=/dev/video0
  7.  
  8. # Set an alias for the filename
  9. DT=$(date +"%H %M %a %d-%b")
  10.  
  11. # Check for the external drive
  12.  
  13. DRV=`lsusb | grep "JMicron"`
  14.     if [ "x${DRV}x" != "xx" ]; then
  15.         sudo mount -t vfat /dev/sdb1 ~/Captures && echo "Capture drive mounted!"
  16.     else
  17.         echo "Please insert the capture drive and re-run the script" && exit
  18.     fi
  19.  
  20. # Load the hdpvr module if necessary
  21.  
  22. PVR=`lsmod | grep "hdpvr"`
  23.     if [ "x${PVR}x" != "xx" ]; then
  24.         echo "HD PVR module is already loaded :)"
  25.     else
  26.         echo "Loading HD PVR module..." && sudo modprobe hdpvr && echo "Done!"
  27.     fi
  28.  
  29. sudo /usr/bin/v4l2-ctl --verbose -d $HDPVR -c video_bitrate_mode=0
  30. sudo /usr/bin/v4l2-ctl --verbose -d $HDPVR -c video_bitrate=13500000
  31. sudo /usr/bin/v4l2-ctl --verbose -d $HDPVR -c video_peak_bitrate=20200000
  32. sudo /usr/bin/v4l2-ctl --verbose -d $HDPVR --set-ctrl brightness=125 --set-ctrl contrast=60 --set-ctrl hue=15 --set-ctrl saturation=85 --set-ctrl sharpness=130
  33.  
  34.  
  35. # Capture footage to the capture drive
  36.  
  37.     # Check the HD PVR is plugged in and active
  38.  
  39. ACT=`ls /dev/ | grep "video0"`
  40.     if [ "x${ACT}x" != "xx" ]; then
  41.         #sudo cat $HDPVR > ~/Captures/$DT.ts
  42.         sudo ffmpeg -i $HDPVR -vcodec copy -acodec ac3 -ab 128k -f matroska /tmp/capture.mkv && sudo mv /tmp/capture.mkv ~/Captures/"$DT".mkv
  43.     else
  44.         echo "The HD PVR is not active :( Make sure you're sending a video signal to it!" && sudo umount -l ~/Captures && sudo rmmod hdpvr
  45.     fi
RAW Paste Data