Remake broadcast-screen
This commit is contained in:
parent
1bc3b15b60
commit
5db6970447
|
@ -1,52 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
cd "$(dirname "$(realpath "$BASH_SOURCE")")"
|
||||
function getValue() {
|
||||
var="$1"
|
||||
if ! [ "${!var}" == "" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$3" == "fail" ]; then
|
||||
echo "ERROR: $1 is not defined."
|
||||
exit 1
|
||||
fi
|
||||
declare -g "$1"="$2"
|
||||
sys_python="python3"
|
||||
function setUser() {
|
||||
export fstream_arg_user="user"
|
||||
export fstream_arg_user_password="123"
|
||||
}
|
||||
function setChannel() {
|
||||
export fstream_arg_channel="default"
|
||||
export fstream_arg_channel_password="456"
|
||||
}
|
||||
|
||||
# USER SETTINGS
|
||||
getValue fstream_profile "profile_broadcast-screen.sh"
|
||||
source "$fstream_profile"
|
||||
getValue fstream_resolution "480"
|
||||
getValue fstream_framerate "15"
|
||||
getValue fstream_bitrate "1M"
|
||||
getValue fstream_264profile "ultrafast"
|
||||
export fstream_arg_bufsize="4096"
|
||||
aes_password="789"
|
||||
|
||||
getValue fstream_ip "fier.me:61920" fail
|
||||
getValue fstream_user "user" fail
|
||||
getValue fstream_password "123" fail
|
||||
getValue fstream_channel "default"
|
||||
getValue fstream_channelpass ""
|
||||
getValue fstream_python "python3"
|
||||
enc_resolution="480"
|
||||
enc_framerate="15"
|
||||
enc_bitrate="1M"
|
||||
enc_preset="ultrafast"
|
||||
|
||||
getValue fstream_aespass ""
|
||||
getValue fstream_aesbuffer "4096"
|
||||
getValue fstream_buffer "$((fstream_aesbuffer + 16))"
|
||||
|
||||
getValue fstream_ssl "0"
|
||||
getValue fstream_ssl_ignoreCert "0"
|
||||
|
||||
fstream_encodercmd=(
|
||||
enc_cmd=(
|
||||
ffmpeg
|
||||
|
||||
# INPUT
|
||||
-strict experimental -avioflags direct -thread_queue_size 1 -hwaccel auto -probesize 32 -fflags nobuffer -flags low_delay -flags2 fast # delay hack
|
||||
-f x11grab -framerate "$fstream_framerate" -i "$DISPLAY" # linux
|
||||
#-f gdigrab -framerate "$fstream_framerate" -i desktop # windows
|
||||
-vf scale=-2:$fstream_resolution
|
||||
-f x11grab -framerate "$enc_framerate" -i "$DISPLAY" # linux
|
||||
#-f gdigrab -framerate "$enc_framerate" -i desktop # windows
|
||||
-vf "scale=-2:$enc_resolution"
|
||||
|
||||
# ENCODING
|
||||
-max_probe_packets 0 -max_delay 0 -flags2 fast # delay hack
|
||||
-c:v libx264 -pix_fmt yuv420p -preset $fstream_264profile -tune zerolatency -x264-params "nal-hrd=cbr" -b:v $fstream_bitrate -minrate $fstream_bitrate -maxrate $fstream_bitrate -bufsize $fstream_bitrate*2
|
||||
-c:v libx264 -pix_fmt yuv420p -preset "$enc_preset" -tune zerolatency -x264-params "nal-hrd=cbr" -b:v "$enc_bitrate" -minrate "$enc_bitrate" -maxrate "$enc_bitrate" -bufsize "${enc_bitrate}*2"
|
||||
-x264opts intra-refresh=1 # delay hack
|
||||
|
||||
# OUTPUT
|
||||
|
@ -56,20 +39,32 @@ ffmpeg
|
|||
-
|
||||
)
|
||||
|
||||
fstream_clientarg="broadcast,user=$fstream_user,user-password=$fstream_password,channel=$fstream_channel,channel-password=$fstream_channelpass"
|
||||
|
||||
if [ "$fstream_buffer" -gt "0" ]; then
|
||||
fstream_clientarg="$fstream_clientarg,bufsize=$fstream_buffer"
|
||||
if [ "$fstream_arg_bufsize" == "" ] || [ "$fstream_arg_bufsize" == "0" ]; then
|
||||
unset fstream_arg_bufsize
|
||||
fi
|
||||
|
||||
fstream_clientcmd=(
|
||||
"$fstream_python" fstream.py
|
||||
"$fstream_ip"
|
||||
"$fstream_clientarg"
|
||||
)
|
||||
|
||||
if [ "$fstream_aespass" == "" ]; then
|
||||
"${fstream_encodercmd[@]}" | "${fstream_clientcmd[@]}"
|
||||
else
|
||||
"${fstream_encodercmd[@]}" | fstream_aespass="$fstream_aespass" fstream_aesbuffer="$fstream_aesbuffer" "$fstream_python" fstream-util-pipe_to_aes.py | "${fstream_clientcmd[@]}"
|
||||
fi
|
||||
export fstream_arg_token=""
|
||||
setChannel
|
||||
while :; do
|
||||
# Get token
|
||||
export fstream_ssl="1"
|
||||
export fstream_ssl_ignoreCert="1"
|
||||
setUser
|
||||
unset fstream_arg_token
|
||||
unset fstream_arg_channel
|
||||
unset fstream_arg_channel_password
|
||||
export fstream_arg_token="$("$sys_python" fstream.py "fier.me:61921" token)"
|
||||
unset fstream_arg_user_password
|
||||
|
||||
# Broadcast
|
||||
unset fstream_ssl
|
||||
unset fstream_ssl_ignoreCert
|
||||
setChannel
|
||||
|
||||
if ! [ "$fstream_aespass" == "" ]; then
|
||||
"${enc_cmd[@]}" | fstream_aespass="$aes_password" fstream_aesbuffer="$(($fstream_arg_bufsize - 16))" "$sys_python" fstream-util-pipe_to_aes.py | "$sys_python" fstream.py "fier.me:61920" broadcast
|
||||
else
|
||||
"${enc_cmd[@]}" | "$sys_python" fstream.py "fier.me:61920" broadcast
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
fstream_python="python3"
|
||||
|
||||
fstream_ip="fier.me:61920"
|
||||
#fstream_ssl="0"
|
||||
#fstream_ssl_ignoreCert="0"
|
||||
|
||||
fstream_user="user"
|
||||
fstream_password="123"
|
||||
fstream_channel="default"
|
||||
fstream_channelpass=""
|
||||
|
||||
fstream_resolution="480"
|
||||
fstream_framerate="15"
|
||||
fstream_bitrate="1M"
|
||||
fstream_profile="ultrafast"
|
||||
|
||||
fstream_aespass=""
|
||||
fstream_aesbuffer="4096"
|
||||
fstream_buffer="$((fstream_aesbuffer + 16))"
|
Loading…
Reference in New Issue