Locked History Actions

Diff for "streamer.sh"

Differences between revisions 1 and 2
Revision 1 as of 2011-04-07 01:04:22
Size: 3323
Editor: barbanegra
Comment:
Revision 2 as of 2011-04-07 01:06:08
Size: 3555
Editor: barbanegra
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
#
#
Line 6: Line 8:
Line 7: Line 10:
#
#
Line 9: Line 14:
Line 10: Line 16:
Line 11: Line 18:
Line 12: Line 20:
#
#
Line 14: Line 24:
Line 15: Line 26:
Line 16: Line 28:
Line 17: Line 30:
#
#
Line 19: Line 34:
Line 20: Line 36:
#
#
Line 24: Line 42:



Line 25: Line 47:
Line 26: Line 49:
Line 27: Line 51:
Line 28: Line 53:
Line 29: Line 55:
Line 31: Line 58:

Line 32: Line 61:
Line 33: Line 63:
Line 34: Line 65:
Line 35: Line 67:
Line 37: Line 70:

Line 38: Line 73:
Line 40: Line 76:

Line 41: Line 79:
Line 42: Line 81:
Line 43: Line 83:
Line 44: Line 85:
Line 46: Line 88:

Line 47: Line 91:
Line 49: Line 94:

Line 50: Line 97:
Line 51: Line 99:
Line 52: Line 101:
Line 53: Line 103:
Line 54: Line 105:
Line 55: Line 107:
Line 56: Line 109:
Line 57: Line 111:
Line 58: Line 113:
Line 59: Line 115:
Line 60: Line 117:
Line 62: Line 120:

Line 63: Line 123:
Line 64: Line 125:
Line 65: Line 127:
Line 67: Line 130:

Line 68: Line 133:
Line 69: Line 135:
Line 70: Line 137:
Line 71: Line 139:
Line 72: Line 141:
Line 73: Line 143:
Line 74: Line 145:
Line 75: Line 147:
Line 76: Line 149:
Line 77: Line 151:
Line 78: Line 153:
Line 79: Line 155:
Line 80: Line 157:
Line 81: Line 159:
Line 83: Line 162:

Line 84: Line 165:
Line 85: Line 167:
Line 86: Line 169:
Line 87: Line 171:
Line 88: Line 173:
Line 90: Line 176:

Line 92: Line 180:

Line 93: Line 183:
Line 94: Line 185:
Line 95: Line 187:
Line 96: Line 189:
Line 97: Line 191:
Line 98: Line 193:
  queue ! \
queue ! \
Line 100: Line 197:
Line 101: Line 199:
Line 102: Line 201:
Line 103: Line 203:
Line 104: Line 205:
Line 105: Line 207:
  queue ! \
queue ! \
Line 107: Line 211:
  queue ! \
queue ! \
Line 109: Line 215:
  queue ! \
queue ! \
Line 111: Line 219:
Line 112: Line 221:
  queue ! \
queue ! \
Line 114: Line 225:
Line 116: Line 228:

Line 117: Line 231:
Line 118: Line 233:

#

# streamer: Just a simple script to stream video w/audio to icecast

# Copyright (C) 2011 Gente anónima pro software libre - flisol

#

# This program is free software: you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by

# the Free Software Foundation, either version 3 of the License, or

# (at your option) any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program. If not, see <http://www.gnu.org/licenses/>.

#

V4LDEV=/dev/video0

XRES=320

YRES=240

FPS=15/2

VQUALITY=24

AQUALITY=0.1

# USESCALE allows specifying custom XRES,YRES. If you enable this option, you

# must set XCAMERARES,YCAMERARES to some value supported by your camera.

#USESCALE=1

#XCAMERARES=640

#YCAMERARES=480

#OUTFILE=stream-date +%Y%m%d-%H%M.ogg

OUTFILE=/dev/null

# settings for the icecast/giss/rooteala/whatever server:

SERVER=giss.tv

PORT=8000

MOUNTPOINT=flisol_fixme.ogg

PASSWORD=fixme

# external file for user-settings:

[ -r ~/.streamer.sh ] && . .streamer.sh

showhelp() {

  • cat <<EOF

Usage: $0 [options]

  • -v4ldev /dev/... -res X Y -fps P/Q -quality VQUAL AQUAL -outfile output_file -server server -port port -mountpoint mp -password pwd

See the content of this script to view the default values. The allowed values are

documented in the specifications of each plugin/sink/etc at gstreamer.

EOF

}

while [ $# -gt 0 ]

do

  • case "$1" in
    • -v4ldev) V4LDEV=$2; shift 2;; -res) XRES=$2; YRES=$3; shift 3;; -fps) FPS=$2; shift 2;; -quality) VQUALITY=$2; AQUALITY=$3; shift 3;; -outfile) OUTFILE=$2; shift 2;; -server) SERVER=$2; shift 2;; -port) PORT=$2; shift 2;; -mountpoint) MOUNTPOINT=$2; shift 2;; -password) PASSWORD=$2; shift 2;;
    • ) showhelp; exit;;
    esac

done

if [ "${USESCALE:-0}" -eq 1 ]

then

  • scaleparm="video/x-raw-yuv,width=$XCAMERARES,height=$YCAMERARES ! queue ! videoscale !"

else

  • scaleparm=""

fi

echo Using mountpoint: "$MOUNTPOINT"

gst-launch v4l2src device="$V4LDEV" ! $scaleparm \

  • video/x-raw-yuv,width="$XRES",height="$YRES" ! \ queue ! \ videorate ! \ video/x-raw-yuv,framerate="$FPS" ! \ tee name=tscreen ! \
    • queue ! \ xvimagesink sync=false tscreen. ! \
    theoraenc quality="$VQUALITY" ! \ queue ! \ mux. \
    • alsasrc ! \ audio/x-raw-int,rate=48000,channels=2,depth=16 ! \ queue ! \ audioconvert ! \ queue ! \ vorbisenc quality="$AQUALITY" ! \ queue ! \
    mux. oggmux name=mux ! \ tee name=tfile ! \
    • queue ! \ filesink location="$OUTFILE" tfile. ! \
    queue ! fdsink | oggfwd "$SERVER" "$PORT" "$PASSWORD" "/$MOUNTPOINT"

# This was used instead of fdsink/oggfwd, but has a serious race conditions,

# it stalls when for some reason some frames are lost:

# shout2send ip="$SERVER" port="$PORT" mount="$MOUNTPOINT" password="$PASSWORD"