calamari__

somagic-record

Apr 12th, 2012
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.60 KB | None | 0 0
  1. #!/bin/sh
  2. # somagic-record -- Record video from the Somagic EasyCAP and encode to H.264 format
  3. # Written by Jeffry Johnston, 2012. Released to the public domain.
  4. # First run somagic-init, then run this script as root.
  5. # To end recording: killall x264 (or pkill x264).
  6.  
  7. # TV standard: ntsc or pal
  8. STANDARD=ntsc
  9.  
  10. # somagic-capture options:
  11. # S-VIDEO: -s
  12. # CVBS (sharpen): --luminance=2 --lum-aperture=3
  13. # Old sync: --sync=1
  14. SOMAGICOPTS="--sync=1 -s"
  15.  
  16. # x264 video bitrate in kb/s (adjust for space/quality tradeoff):
  17. BITRATE=2000
  18.  
  19. # x264 options (adjust for speed/quality tradeoff):
  20. # --preset: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
  21. # --threads auto: Use optimum number of threads
  22. X264OPTS="--preset=veryfast --threads auto"
  23.  
  24. # mplayer options:
  25. # Deinterlace: -vf yadif
  26. MPLAYEROPTS="-vf yadif"
  27.  
  28. # Default video and log file prefix:
  29. NAME="video"
  30.  
  31. # Shouldn't need to change below
  32. if [ $# -eq 1  ] ; then
  33.   NAME=$1
  34. elif [ $# -ne 0  ] ; then
  35.   echo "Usage: $0 [VIDEO_PREFIX]"
  36.   exit 1
  37. fi
  38. if [ ntsc = "$STANDARD" ] ; then
  39.   FPS="30000/1001"
  40.   TV="-n"
  41. elif [ pal = "$STANDARD" ] ; then
  42.   FPS="25"
  43.   TV=""
  44. else
  45.   echo "Unknown TV standard: '$STANDARD', must be 'ntsc' or 'pal'."
  46.   exit 1
  47. fi
  48. mkfifo stream.yuv >/dev/null 2>&1
  49. ln -s stream.yuv pipe.y4m >/dev/null 2>&1
  50. x264 $X264OPTS --bitrate "$BITRATE" -o "$NAME.264" pipe.y4m >"$NAME.xlog" 2>&1 &
  51. somagic-capture $TV $SOMAGICOPTS 2>"$NAME.slog" | mplayer -benchmark -nosound -vo yuv4mpeg $MPLAYEROPTS -demuxer rawvideo -rawvideo "$STANDARD:format=uyvy:fps=$FPS" -aspect 4:3 - >"$NAME.mlog" 2>&1 &
Advertisement
Add Comment
Please, Sign In to add comment