-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardware-streaming.bash
More file actions
166 lines (144 loc) · 3.79 KB
/
hardware-streaming.bash
File metadata and controls
166 lines (144 loc) · 3.79 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env bash
YOUTUBE_KEY="Super-Secret-Key-123"
TWITCH_KEY="Shhh-Dont-Tell-Anyone-456"
# Use date to generate a filename.
FILE="$(date '+%Y-%m-%d-%H-%M-%S').m4a"
DIRECTORY=~/Music
# pactl list short sources
# The input is mic, output .monitor is the system sound.
A0_INPUT="alsa_input.usb-PreSonus_AudioBox_44_VSL_2256-00.analog-surround-40"
A1_INPUT="alsa_output.usb-PreSonus_AudioBox_44_VSL_2256-00.analog-surround-40.monitor"
# Mono to Stereo.
# Use pan to map channel 0 to channel 0 and 1.
A0_STEREO="pan=stereo|c0=c0|c1=c0"
# High-pass and low-pass filters.
A0_PASS="highpass=f=80, lowpass=f=15000"
# Record a noise profile from start to stop in seconds.
# Set noise floor with nf and noise reduction with nr.
A0_DENOISER="\
asendcmd=0 afftdn sn start,\
asendcmd=1 afftdn sn stop,\
afftdn=nr=20:nf=-55"
# Click remover.
A0_CLICK="adeclick"
A0_DEESSER="deesser"
# FIR Equalizer. entry(frequency,gain);
A0_EQUALIZER="firequalizer=gain_entry='\
entry(100,-1);\
entry(156,-2);\
entry(220,-1);\
entry(311,-3);\
entry(440,-6);\
entry(622,-7);\
entry(880,-5);\
entry(1250,-2);\
entry(1750,-5);\
entry(2500,-2);\
entry(3500,-1);\
entry(5000,0);\
entry(10000,0);\
entry(20000,0)'"
# Compressor and expander. 2 channels attack|attack:release|release in seconds.
# in dB/out dB|in dB/out dB.
A0_COMPRESSOR="compand=0.01|0.01:0.05|0.05:\
-180/-180|\
-54/-90|\
-51/-51|\
-48/-35|\
-42/-18|\
-36/-16|\
-30/-14|\
-24/-12|\
-18/-10|\
-12/-8|\
-6/-6|\
0/-6|\
20/-3"
A0_VOLUME="volume=3dB"
# Limit output in dB. Don't auto level/normalize.
A0_LIMIT="alimiter=level=false:limit=-3dB"
# A comma separated filter chain.
# [0:a] label is the first audio stream from the first file as the input.
# [aout] is a user defined label for the output of the first filter chain.
A0_FILTER="\
[0:a]\
$A0_STEREO,\
$A0_PASS,\
$A0_DENOISER,\
$A0_CLICK,\
$A0_DEESSER,\
$A0_EQUALIZER,\
$A0_COMPRESSOR,\
$A0_LIMIT\
[mic]"
# Mix two labeled audio streams with specified weights.
MIX_AUDIO="amix=inputs=2:weights=0.5 1"
# Resample audio with asynchronous mode.
RESAMPLE="aresample=async=1"
# Second filter chain for additional processing.
A1_FILTER="\
[1:a]\
[mic] $MIX_AUDIO,\
$RESAMPLE\
[aout]"
# Multiple colon separated filter chains.
FILTER_COMPLEX="$A0_FILTER; $A1_FILTER"
VIDEO_FILTERS="\
eq=saturation=1:contrast=1:gamma=1,\
format=nv12:color_ranges=pc,\
hwupload"
#notify-send "FFmpeg Starting" "Streaming Live on Twitch and YouTube."
#ffmpeg \
# -probesize 20M \
# -vaapi_device /dev/dri/renderD128 \
# -f pulse \
# -i "$A0_INPUT" \
# -f pulse \
# -i "$A1_INPUT" \
# -filter_complex "$FILTER_COMPLEX" \
# -f x11grab \
# -s 1920x1080 \
# -r 30 \
# -i :0 \
# -color_range full \
# -color_trc bt709 \
# -color_primaries bt709 \
# -colorspace bt709 \
# -vf "$VIDEO_FILTERS" \
# -map "[aout]" \
# -map 2:v \
# -ac 2 \
# -c:a aac \
# -c:v h264_vaapi \
# -qp 15 \
# -f tee \
#"[f=flv:onfail=ignore]rtmps://live.twitch.tv/app/$TWITCH_KEY|\
#[f=flv:onfail=ignore]rtmps://a.rtmp.youtube.com/live2/$YOUTUBE_KEY|\
#[f=mp4]$DIRECTORY/$FILE"
notify-send "FFmpeg Starting" "Streaming Locally to $FILE."
ffmpeg \
-probesize 20M \
-vaapi_device /dev/dri/renderD128 \
-f pulse \
-i "$A0_INPUT" \
-f pulse \
-i "$A1_INPUT" \
-filter_complex "$FILTER_COMPLEX" \
-f x11grab \
-s 1920x1080 \
-r 30 \
-i :0 \
-color_range full \
-color_trc bt709 \
-color_primaries bt709 \
-colorspace bt709 \
-vf "$VIDEO_FILTERS" \
-map "[aout]" \
-map 2:v \
-ac 2 \
-c:a aac \
-c:v h264_vaapi \
-qp 15 \
-f tee \
"[f=mp4]$DIRECTORY/$FILE"
notify-send "FFmpeg Stopping" "Steam saved to $FILE."