streamp2p.sh 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. SNOWMIX=/usr/local/lib/Snowmix-0.5.1
  3. vbitrate=4000
  4. vbitrate=1000
  5. vbitrate=700
  6. abitrate=64000
  7. feed_id=1
  8. audio_feed_id=1
  9. audio_sink_id=1
  10. . $SNOWMIX/scripts/gstreamer-settings
  11. . $SNOWMIX/scripts/snowmix-settings
  12. width=$feed_width
  13. height=$feed_height
  14. framerate=$(echo "$framerate" | cut -f 1 -d.) #this is getting populated with 25.000 which x264enc doesn't like
  15. audiorate=$feed_rate
  16. channels=$feed_channels
  17. #width=1024
  18. #height=768
  19. #framerate=25
  20. #audiorate=44100
  21. #channels=2
  22. ###################### Settings ########################
  23. ########################################################
  24. # THe following settings should not be changed
  25. h264_level=4.1
  26. h264_profile=high
  27. h264_bframes=0
  28. keyint=$(echo "2 * $framerate" |bc)
  29. VIDEOCONVERT="videoconvert"
  30. #VIDEOCONVERT="video/x-raw, width=800, height=600 ! videoconvert"
  31. # VIDEO=video/x-raw-yuv
  32. afid="format=(string)S16LE, "
  33. ENCAUDIOFORMAT='aacparse ! audio/mpeg,mpegversion=4,stream-format=raw'
  34. videoencoder="x264enc bitrate=$vbitrate key-int-max=$keyint bframes=$h264_bframes byte-stream=false aud=true" #speed-preset=1"
  35. videoencoder="x264enc bitrate=$vbitrate key-int-max=$keyint bframes=$h264_bframes byte-stream=false aud=true speed-preset=4"
  36. videoencoder="x264enc bitrate=$vbitrate key-int-max=$keyint bframes=$h264_bframes byte-stream=false aud=true speed-preset=4"
  37. #default=6=medium, 5=fast, 4=faster...0=none
  38. audioencoder="faac bitrate=$abitrate"
  39. audioencoder="voaacenc bitrate=$abitrate" #FIXME I changed faac to voaacenc as faac is not on my machine
  40. serverurl='rtmp://curso.especificosba.com.ar/src/movie'
  41. serverurl='rtmp://localhost/rpi/movie'
  42. serverurl='rtmp://localhost/rpi2/movie'
  43. location=$serverurl
  44. framerate="$framerate/1" #Fraction
  45. ENCVIDEOFORMAT='h264parse ! video/x-h264,level=(string)'$h264_level',profile='$h264_profile
  46. ENCVIDEOFORMAT="h264parse ! video/x-h264,level=(string)$h264_level,profile=$h264_profile"
  47. VIDEO='video/x-raw, format=(string)BGRA, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive'
  48. VIDEOFORMAT=$VIDEO', framerate='$framerate', width='$width', height='$height
  49. AUDIO=audio/x-raw
  50. AUDIOFORMAT=$AUDIO', '$afid' endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)'$audiorate', channels=(int)'$channels
  51. # ctrsocket must match system socket in running Snowmix
  52. ctrsocket=/tmp/mixer1
  53. # audiosink must match audio sink in running Snowmix
  54. audiosink=1
  55. VIDEOSRC='shmsrc socket-path='$ctrsocket' do-timestamp=true is-live=true'
  56. AUDIOSRC="fdsrc fd=0 do-timestamp=true"
  57. ( echo "audio sink ctr isaudio $audiosink" ) | \
  58. /bin/nc -q -1 127.0.0.1 9999 | \
  59. (head -1
  60. gst-launch-1.0 -q -e \
  61. $VIDEOSRC !\
  62. $VIDEOFORMAT !\
  63. queue !\
  64. $VIDEOCONVERT !\
  65. $videoencoder !\
  66. $ENCVIDEOFORMAT !\
  67. queue !\
  68. mux. $AUDIOSRC !\
  69. $AUDIOFORMAT !\
  70. queue !\
  71. $audioencoder !\
  72. $ENCAUDIOFORMAT !\
  73. queue !\
  74. flvmux streamable=true name=mux !\
  75. queue !\
  76. fdsink
  77. )
  78. exit