Statistics
| Branch: | Tag: | Revision:

streamers-build / scripts / start_chunker_unitn.sh @ 09bb9d06

History | View | Annotate | Download (2.15 KB)

1
#!/bin/bash
2

    
3
#default values
4
FILE=/dev/stdin
5

    
6
VIDEO_BPS=500000
7
AUDIO_BPS=64000
8
VIDEO_CODEC=mpeg4
9
AUDIO_CODEC=libmp3lame
10
IPC_IP="127.0.0.1"
11
IPC_PORT=7777
12
PORT=6676
13
AUDIO=1
14
VIDEO=1
15
# Usage: set paramters in this script (after the usage function), then run it with the command line option below
16
function usage () {
17
   echo "Usage: $0 [options]"
18
   echo "  options (and default values)"
19
   echo "  -f file: media file to stream ($FILE)"
20
   echo "  -v rate: video encoding rate in bps ($VIDEO_BPS)"
21
   echo "  -a rate: audio encoding rate in bps ($AUDIO_BPS)"
22
   echo "  -V codec: video encoder ($VIDEO_CODEC)"
23
   echo "  -A codec: audio encoder ($AUDIO_CODEC)"
24
   echo "  -l : the stream is a live source with its own timing"
25
   echo "  -p port: UDP port used by the streamer ($PORT)"
26
   echo "  -c capture video: Video device to capture /dev/video$VIDEO"
27
   echo "  -d capture audio: Audio device to capture $AUDIO"
28
   echo "  -I ip: IPC ip ($IPC_IP)"
29
   echo "  -P port: IPC port ($IPC_PORT)"
30
   exit $1
31
}
32

    
33
while getopts "f:v:a:V:A:lp:I:P:c:d:h" opt; do
34
   case $opt in
35

    
36
   f )  FILE=$OPTARG ;;
37
   v )  VIDEO_BPS=$OPTARG ;;
38
   a )  AUDIO_BPS=$OPTARG ;;
39
   V )  VIDEO_CODEC=$OPTARG ;;
40
   A )  AUDIO_CODEC=$OPTARG ;;
41
   l )  CHUNKER_XTRA+=" -l" ;;
42
   p )  PORT=$OPTARG ;;
43
   I )  IPC_IP=$OPTARG ;;
44
   P )  IPC_PORT=$OPTARG ;;
45
   c )  VIDEO=$OPTARG ;;
46
   d )  AUDIO=$OPTARG ;;
47
   h )  usage 0 ;;
48
   \?)  usage 1 ;;
49
   esac
50
done
51

    
52

    
53
# start the chunker
54
echo "./chunker_streamer -i $FILE -a $AUDIO_BPS -v $VIDEO_BPS -A $AUDIO_CODEC -V $VIDEO_CODEC -F tcp://${IPC_IP}:$IPC_PORT $CHUNKER_XTRA  2>chunker_streamer.err 1>chunker_streamer.log &"
55
~/Streamers-build/THIRDPARTY-LIBS/ffmpeg/ffmpeg -f video4linux2 -i /dev/video1 -f alsa -ac 2 -i hw:1,0 -vcodec mpeg4 -b 20M -g 1 -acodec mp2 -f nut - 2>ffmpeg.err | \
56
./chunker_streamer -i $FILE -a $AUDIO_BPS -v $VIDEO_BPS -A $AUDIO_CODEC -V $VIDEO_CODEC -F tcp://${IPC_IP}:$IPC_PORT $CHUNKER_XTRA  2>chunker_streamer.err 1>chunker_streamer.log &
57

    
58
sleep 1 && ~/v4l-utils/utils/v4l2-ctl/v4l2-ctl -d /dev/video1 -i $VIDEO --verbose  --set-audio-input=$AUDIO &
59
sleep 5 && ~/v4l-utils/utils/v4l2-ctl/v4l2-ctl -d /dev/video1 -i $VIDEO --verbose  --set-audio-input=$AUDIO &