Locked History Actions

Diff for "streamer.sh"

Differences between revisions 2 and 3
Revision 2 as of 2011-04-07 01:06:08
Size: 3555
Editor: barbanegra
Comment:
Revision 3 as of 2014-03-04 02:54:37
Size: 3368
Editor: FelipeWiel
Comment: Adjusting format
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#FORMAT plain
Line 2: Line 4:
Line 6: Line 7:
Line 8: Line 8:
Line 10: Line 9:
Line 14: Line 12:
Line 16: Line 13:
Line 18: Line 14:
Line 22: Line 17:
Line 24: Line 18:
Line 26: Line 19:
Line 28: Line 20:
Line 32: Line 23:
Line 34: Line 24:
Line 36: Line 25:
Line 41: Line 29:




Line 47: Line 30:
Line 49: Line 31:
Line 51: Line 32:
Line 53: Line 33:
Line 55: Line 34:
Line 59: Line 37:
Line 61: Line 38:
Line 63: Line 39:
Line 67: Line 42:
Line 70: Line 44:

Line 73: Line 45:
Line 77: Line 48:
Line 79: Line 49:
Line 81: Line 50:
Line 83: Line 51:
Line 85: Line 52:
Line 89: Line 55:
Line 91: Line 56:
Line 95: Line 59:
Line 97: Line 60:
Line 101: Line 63:
Line 103: Line 64:
Line 105: Line 65:
Line 107: Line 66:
Line 109: Line 67:
Line 111: Line 68:
Line 113: Line 69:
Line 115: Line 70:
Line 117: Line 71:
Line 120: Line 73:

Line 123: Line 74:
Line 125: Line 75:
Line 131: Line 80:
Line 133: Line 81:
Line 135: Line 82:
Line 137: Line 83:
Line 139: Line 84:
Line 141: Line 85:
Line 143: Line 86:
Line 145: Line 87:
Line 147: Line 88:
Line 149: Line 89:
Line 151: Line 90:
Line 153: Line 91:
Line 155: Line 92:
Line 157: Line 93:
Line 159: Line 94:
Line 163: Line 97:
Line 165: Line 98:
Line 167: Line 99:
Line 169: Line 100:
Line 171: Line 101:
Line 173: Line 102:
Line 175: Line 103:
Line 180: Line 107:

Line 183: Line 108:
Line 185: Line 109:
Line 187: Line 110:
Line 189: Line 111:
Line 191: Line 112:
Line 193: Line 113:
Line 195: Line 114:
Line 197: Line 115:
Line 199: Line 116:
Line 201: Line 117:
Line 203: Line 118:
Line 205: Line 119:
Line 207: Line 120:
Line 209: Line 121:
Line 211: Line 122:
Line 213: Line 123:
Line 215: Line 124:
Line 217: Line 125:
Line 219: Line 126:
Line 221: Line 127:
Line 223: Line 128:
Line 225: Line 129:
Line 229: Line 132:
Line 231: Line 133:
Line 233: Line 134:

#!/bin/sh
#######################################################################

#
# 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"