summaryrefslogtreecommitdiff
path: root/dot/local/bin/selfstream
blob: 85b8a8f33cd25f3d14a49b70ffdb101cc29a1e9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash

AUDIO_DEVICE=pulse
VIDEO_DEVICE=/dev/video0

case $(hostname) in
    fifty) outhost=blackbird ;;
    blackbird) outhost=fifty; AUDIO_DEVICE=alsa ;;
    *) outhost=$1
esac

MAX_RECORDING_TIME=00:05:00

# https://trac.ffmpeg.org/wiki/StreamingGuide#Pointtopointstreaming

VIDEO_OPTS='-framerate 30 -video_size 640x480'
VIDEO_OPTS='-framerate 30 -video_size 320x240'
# VIDEO_OPTS='-input_format mjpeg -framerate 30 -video_size 800x600'

record()
{
	local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}"
	ffmpeg -hide_banner -loglevel error -stats \
		$timeout -f video4linux2 ${VIDEO_OPTS} -i "$VIDEO_DEVICE" \
		$timeout -f "$AUDIO_DEVICE" -i default \
		-c:v rawvideo  -pix_fmt yuv420p  -f xv win \
		-c:a mp3 \
		-c:v libxvid \
    -f mpegts \
		"$1"
}

# ffmpeg -i input -f rtsp -rtsp_transport tcp rtsp://localhost:8888/live.sdp
# ffplay -rtsp_flags listen rtsp://localhost:8888/live.sdp?tcp

#OUTPUT=${1:-udp://blackbird:55555}
#INPUT=${2:-ffmpeg://udp://localhost:55555?listen}


OUTPUT=udp://blackbird:55555

silently() { "$@" >/dev/null 2>&1; }

silently amixer-enable-mic
banish

record "$OUTPUT"
# mpv "$INPUT"