Skip to content

Instantly share code, notes, and snippets.

@kyv
Last active August 29, 2015 14:06
Show Gist options
  • Save kyv/4d5cea785fc446d18946 to your computer and use it in GitHub Desktop.
Save kyv/4d5cea785fc446d18946 to your computer and use it in GitHub Desktop.
envolutura para dvstream y icecast
#!/bin/bash
# Script facilitador para transmitir video con dvswitch a icecast
# Ejemplo de uso
# vstream -h 127.0.0.1 -p 2000 -d /dev/video1 -i espora.org:8000/vstream.ogg
while [[ $# > 1 ]]
do
key="$1"
shift
case $key in
-h|--host)
DVSWITCHHOST="$1"
shift
;;
-p|--port)
DVSWITCHPORT="$1"
shift
;;
-d|--dev)
DEV="$1"
shift
;;
-i|--icecast)
ICECAST="$1"
shift
;;
-x|--password)
ICECASTPASS="$1"
shift
;;
*)
echo "opción desconocido: $1"
exit
;;
esac
done
ICECASTHOST="$(echo ${ICECAST} |cut -d':' -f1)"
ICECASTPORT="$(echo ${ICECAST} |cut -d':' -f2| cut -d'/' -f1)"
ICECASTMOUNT="$(echo ${ICECAST} |cut -d'/' -f2)"
if [[ -z "$DVSWITCHHOST" ]] ; then
DVSWITCHHOST=127.0.0.1
fi
if [[ -z "$DVSWITCHPORT" ]] ; then
DVSWITCHPORT=2000
fi
if [[ -z "$DEV" ]] ; then
DEV=(/dev/video*)
fi
if [[ -z "$ICECASTHOST" ]] ; then
ICECASTHOST="a.stream.mayfirst.org"
fi
if [[ -z "$ICECASTPORT" ]] ; then
ICECASTPORT=8000
fi
if [[ -z "$ICECASTMOUNT" ]] ; then
ICECASTMOUNT="vstream.ogg"
fi
if [[ -z "$ICECASTPASS" ]] ; then
ICECASTPASS="source"
fi
# mostrar valores
echo -e "\nDEV: $DEV\n"
printf '%-20s | %-10s\n' DVSWITCH ICECAST
printf '%s:%-10s | %s:%s/%s\n' $DVSWITCHHOST $DVSWITCHPORT $ICECASTHOST $ICECASTPORT $ICECASTMOUNT
printf '\n'
# revisar disponibilidad de disponitivo
if [ -c $DEV ]; then
printf '%s\n' "INFO: webcam connectado"
else
printf '%s\n\n' "ERROR: connecta cam e intenta de nuevo"
exit
fi
if fuser -v $DEV > /dev/null 2>&1; then
printf '%s\n\n' "ERROR: $DEV ocpupada"
exit
else
printf '%s\n' "INFO: $DEV"
fi
# inicia dvswitch
dvswitch -h $DVSWITCHHOST -p $DVSWITCHPORT 2>&1 &
# pipe usb cam to dvswitch
avconv -f video4linux2 -i $DEV -target ntsc-dv - \
| dvsource-file /dev/stdin -p $DVSWITCHPORT -h $DVSWITCHHOST 2>&1 &
# a icecast
dvsink-command -h $DVSWITCHHOST -p $DVSWITCHHOST \
| ffmpeg2theora -f dv -F 12:5 --speedlevel 0 -v 4 -a 0 -c 1 -H 9600 -o - \
| oggfwd $ICECASTHOST $ICECASTPORT $ICECASTPASS $ICECASTMOUNT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment