NoniDOTio / LiveStreamRadio

Lightweight 24/7 Twitch and YouTube Music Radio using FFMPEG
https://noni.io
MIT License
42 stars 17 forks source link

Wont stream to youtube #2

Open christophersaebo opened 2 years ago

christophersaebo commented 2 years ago

Hey, ive done every step it said, it wont stream to youtube doe, this is the code for the stream.sh

#! /bin/bash

. ./config.sh

VBR="1500k"
FPS="24"
QUAL="superfast"

tee_muxer_output=""
i=0

for platform in "${PLATFORMS[@]}"
do
    if (( $i > 0 )); then
        tee_muxer_output+="|"
    fi
    tee_muxer_output+="[f=fifo:fifo_format=flv:queue_size=120:drop_pkts_on_overflow=1:attempt_recovery=1:recovery_wait_time=10:max_recovery_attempts=0:restart_with_keyframe=1]${platform}"
    i=$((i+1))
done

while true :
do
    ffmpeg -threads "${THREAD_COUNT}" -loglevel warning \
        -fflags "+autobsf+genpts+discardcorrupt" -avoid_negative_ts "make_zero" -copytb 1 \
        -re -stream_loop -1 -i "${BACKGROUND}" \
        -f alsa -ac 2 -thread_queue_size 1024 -i hw:Loopback,1,0 -c:v copy -c:a aac -filter:a "volume=${VOLUME}" -map 0:v -map 1:a \
        -f tee "${tee_muxer_output}"
    -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
    -acodec libmp3lame -ar 44100 -threads 6 -qscale:v 3 -b:a 320000 -bufsize 512k \
    -f flv "rtmp://a.rtmp.youtube.com/live2/xxxx"
     echo "[ERROR] `date '+%Y-%m-%d %H:%M:%S'` Stream crashed. Restarting..." >> ${SCRIPT_DIR}/event.log
     on_stream_restart
done
NoniDOTio commented 2 years ago

Hi there, never post your rtmp url publicly, it contains your streaming key. I removed it from your message.

That's not the intended way of using the script. If you're not using tee muxer, you should at the very least remove -f tee "${tee_muxer_output}" from your ffmpeg command. What error are you getting?

christophersaebo commented 2 years ago

I'm getting: cannot open audio device hw:Loopback, 1, 0 (no such device), using a oracle cloud vps with ubuntu

NoniDOTio commented 2 years ago

Please make sure you have done all of the below:

Does it work when you revert stream.sh to its original state and add your rtmp url to config.sh instead?

christophersaebo commented 2 years ago

I'll try when I get home

christophersaebo commented 2 years ago

Im getting this now:

root@yt-streams:/home/ubuntu/LiveStreamRadio# sh ./lsr.sh --start ./lsr.sh: 4: ./config.sh: Bad substitution ./lsr.sh: 29: ./config.sh: Syntax error: "(" unexpected

christophersaebo commented 2 years ago

Got the errors away, but this the only things that display: image

I have the ffmpeg version: 4.2.4

NoniDOTio commented 2 years ago

You are actually meant to run the script using ./lsr.sh --start. That way the audio player and ffmpeg are started in different screens and able to run simultaneously.

christophersaebo commented 2 years ago

Still, it wont send out

christophersaebo commented 2 years ago

image image

christophersaebo commented 2 years ago

So did i do something wrong?

NoniDOTio commented 2 years ago

Can you please try to enter the streams' screen using screen -rS lsr_stream and see whether there is any error? To leave the screen, use Ctrl + A, Ctrl + D

christophersaebo commented 2 years ago

Ima try

christophersaebo commented 2 years ago

There is no screen to be resumed matching lsr_stream.

christophersaebo commented 2 years ago

same happens with lsr_player

christophersaebo commented 2 years ago

Ive tried redoing the lsr.sh file, still nothing, it wont start up the screens

NoniDOTio commented 2 years ago

Can you please make a backup of your files and try with freshly cloned files. As a first step, add your youtube rtmp url to PLATFORMS=() in config.sh and remove all other rtmp urls. Then try to execute the script in the way it's intended and see if it throws any errors.

christophersaebo commented 2 years ago

It wont open a screen, so it wont work, and ive tried with dooing what u said it wont start ffmpeg too

christophersaebo commented 2 years ago

image


#
# Absolute path of the dictory the script is in. Don't touch this unless you know what you're doing
#
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

#
# Filter to adjust music volume. Put "1.0" to keep the original volumes
#
VOLUME="0.8"

#
# How many threads FFMPEG will use. Set to "0" to let FFMPEG decide
#
THREAD_COUNT="0"

#
# Absolute path of the directory your music is stored in
#
MUSIC_DIR="${SCRIPT_DIR}/media/music"

#
# Filepath of your background video. Must be a streamable MKV, FLV or MP4 file
#
BACKGROUND="${SCRIPT_DIR}/media/sample_background.mkv"

#
# RTMP urls you wish to stream to
#
PLATFORMS=(
        "rtmp://a.rtmp.youtube.com/live2/KEY WAS HERE"
    )

#
# Executed before the next song in the playlist starts playing
# Arguments:
#   ${1} File name (String, eg. "Billie_Eilish_-_Ocean_Eyes.mp3")
#   ${2} Cleaned up file name (String, eg. "Billie Eilish - Ocean Eyes")
# Returns:
#   None
#
function on_next_track() {
  # Your custom code goes here
  # The following line writes the currently playing song to a text file.
  # You can safely remove it if you don't need this feature
  echo "${2}" > ${SCRIPT_DIR}/now_playing.txt

  :
}

#
# Executed after the playlist has been reshuffled
# Arguments:
#   None
# Returns:
#   None
#
function on_playlist_reshuffle() {
  # Your custom code goes here

  :
}

#
# Executed when the stream is restarting (e.g. after a crash)
# Arguments:
#   None
# Returns:
#   None
#
function on_stream_restart() {
  # Your custom code goes here

  :
}
christophersaebo commented 2 years ago

Thats the config

NoniDOTio commented 2 years ago

That's odd. With the same basic setup, could you please try to run ./lsr.sh --start player (make sure it's working properly by going into the screen) and then run ./stream.sh and let me know what error comes up?

christophersaebo commented 2 years ago

Trying now

christophersaebo commented 2 years ago

There is no screen to be resumed image

NoniDOTio commented 2 years ago

Oh so the player isn't running either. What do you get when running ./player.sh?

christophersaebo commented 2 years ago

it runs then, but not trough ./lsr.sh --start player only on bash ./player.sh

christophersaebo commented 2 years ago

image