stream.sh 3.2 KB

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