botsnlinux

avconv stream splitting

Mar 29th, 2013
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. --- Streaming script (run once) ---
  2. #!/bin/bash
  3. # Reads video from the Blackmagic Intensity Pro, and splits in into
  4. # two streams.
  5. # One stream is sent to Justin.tv, the other is sent via RTP to two
  6. # local ports (audio and video), where another thread can read selected
  7. # slices and write them to disk.
  8. #
  9. # Steven Bell <botsnlinux@gmail.com>
  10. # 25 March 2013
  11.  
  12. WEBCAST_SIZE="720x480"
  13. WEBCAST_FPS="20"
  14. WEBCAST_BITRATE="1000k"
  15.  
  16. RECORD_SIZE="1920x1080"
  17. RECORD_FPS="30"
  18.  
  19. # Streaming settings
  20. STREAM_KEY="XXXXXX"
  21. STREAM_URL="rtmp://live.justin.tv/app/$STREAM_KEY"
  22. VIDEO_RTP_PORT=1234
  23. AUDIO_RTP_PORT=1236
  24.  
  25. # Paths
  26. export AVCONV_DATADIR=/home/steven/video/tools/libav/presets/
  27. AVCONV=/home/steven/video/tools/libav/avconv
  28. BMDTOOLS=/home/steven/video/tools/bmdtools
  29.  
  30. $BMDTOOLS/bmdcapture -m 11 -F nut -f pipe:1 | \
  31. $AVCONV -i - \
  32. -f pulse -i default \
  33. -map 0:v \
  34. -map 1:a \
  35. -vcodec libx264 -pre:0.0 libx264-main \
  36. -acodec libmp3lame -ar 44100 -ab 32k \
  37. -r $WEBCAST_FPS -s $WEBCAST_SIZE -b $WEBCAST_BITRATE \
  38. -threads 0 \
  39. -y \
  40. -f flv "$STREAM_URL" \
  41. \
  42. -map 0:v \
  43. -vcodec mpeg4 -vb 15000k \
  44. -threads 0 \
  45. -r $RECORD_FPS -s $RECORD_SIZE \
  46. -f rtp rtp://127.0.0.1:$VIDEO_RTP_PORT \
  47. \
  48. -map 1:a \
  49. -acodec libmp3lame -ar 44100 -ab 32k \
  50. -threads 0 \
  51. -f rtp rtp://127.0.0.1:$AUDIO_RTP_PORT
  52.  
  53. --- Recording command (run many times) ---
  54. #!/bin/bash
  55. FILENAME=$1
  56.  
  57. export AVCONV_DATADIR=/home/steven/video/tools/libav/presets
  58. # My avconv seems to puke on rtp-ed mpeg headers
  59. #AVCONV_PATH=/home/steven/video/tools/libav/avconv
  60. AVCONV_PATH=avconv
  61.  
  62. $AVCONV_PATH -i combined.sdp -vcodec copy -acodec copy -y $FILENAME
  63.  
  64.  
  65. --- SDP file ---
  66. v=0
  67. o=- 0 0 IN IP4 127.0.0.1
  68. s=No Name
  69. t=0 0
  70. a=tool:libavformat 55.0.0
  71. m=video 1234 RTP/AVP 96
  72. c=IN IP4 127.0.0.1
  73. a=rtpmap:96 H264/90000
  74. a=fmtp:96 packetization-mode=1
  75. m=audio 1236 RTP/AVP 14
  76. c=IN IP4 127.0.0.1
  77. b=AS:32
Add Comment
Please, Sign In to add comment