goicy icon indicating copy to clipboard operation
goicy copied to clipboard

Is it possible to feed live stream with webcam+mic using ffmpeg to facebook and goicy to shoutcast at the same time using same ffmpeg command?

Open shelomito12 opened this issue 4 years ago • 5 comments

I have the following ffmpeg running in linux but, hopefully with your help, I can adapt it for windows and have facebook live (mic+webcam) and shoutcast (audio from mic using the webcam) streaming at the same time.

EXEC="/home/ubuntu/encoder/bin/ffmpeg \
        -re \
        -loop 1 \
        -framerate 5 \
        -i $IMAGE \
        -thread_queue_size 1024 \
        -i $SOURCE \
        -profile:v baseline \
        -preset ultrafast \
        -c:v libx264 \
        -tune stillimage \
        -pix_fmt yuv420p \
        -s $SIZE \
        -b:v 750k \
        -maxrate 750k \
        -bufsize 1500k \
        -crf 31 \
        -r 5 \
        -c:a copy \
        -b:a 128k \
        -ar 44100 \
        -g 10 \
        -strict experimental \
        -f flv \
        $FACEBOOK_URL/$FACEBOOK_KEY"

until $EXEC ; do
        echo "$DATE - restarting ffmpeg facebook_live process..."
        sleep 10
done

I know the dshow parameter on ffmpeg can handle the mic and webcam: https://trac.ffmpeg.org/wiki/DirectShow

shelomito12 avatar Apr 27 '20 05:04 shelomito12

goicy calls ffmpeg directly, and ffmpeg writes adts or mp3 to stdout, which is then written to icecast by goicy. However, you can set up another output from your command, and stream that directly to an icecast server: http://www.streamingmediaglobal.com/Articles/Editorial/Featured-Articles/DIY-Live-Audio-Streaming-Using-Icecast-with-FFmpeg-125665.aspx

MrShoenel avatar May 05 '20 13:05 MrShoenel

Does goicy only support Icecast protocol? What about Shoutcast? I've seen various forum saying that ffmpeg cannot stream directly to Shoutcast using the format of http://password@ip:port/stream

shelomito12 avatar May 06 '20 03:05 shelomito12

goicy supports both protocols. It doesn't look like ffmpeg works with shoutcast directly, though. But icecast works really well and is free, are you in a position where you cannot use it? I am using icecast to stream HE-AAC v2 (and some MP3, too) and the clients use mostly the good old Winamp.

MrShoenel avatar May 06 '20 13:05 MrShoenel

Another option I could think of, that does not involve modifying goicy, is to set up a 2nd output of your live stream, and write it into segmented audio files. Then, you generate a dummy playlist over these chunks and give them to goicy using ffmpeg mode (can be the same list if the names of the chunks are the same). That way it'll be almost live (depends on the segment size etc., but I guess delays <5s should be possible).

MrShoenel avatar May 06 '20 13:05 MrShoenel

Hey guys,

I have an FFMPEG command which was able to send an RTMP live feed to 2 different icecast radio stations:

command 1 (in prod; 1 of 2 failing):

/home/ubuntu/encoder/bin/ffmpeg -i rtmp://127.0.0.1:1935/app/live -vn -c:a mp3 -ac 2 -b:a 64k -ar 44100 -f tee -map 0 "[f=mp3:onfail=ignore]icecast://source:password@liquidsoap:8000/live|[f=mp3:onfail=ignore]icecast://source:[email protected]:80/live"

I would get the following FFMPEG error when running above command 1:

[tee @ 0x562fffd24bc0] Slave '[f=mp3:onfail=ignore]icecast://source:[email protected]:80/live': error opening: End of file
[tee @ 0x562fffd24bc0] Slave muxer #1 failed: End of file, continuing with 1/2 slaves.

It was working fine until these days when one of them (fluoz.zeno.fm:80/live) stopped working and I think Zeno upgraded their Icecast servers from v1 (legacy) to v2. Why? because when I was doing individual testing to the Zeno icecast server, I realized that it worked fine when I added the -legacy_icecast 1 option

command 2 (testing to Zeno only w/ -legacy_icecast 1 option):

/home/ubuntu/encoder/bin/ffmpeg -i rtmp://127.0.0.1:1935/app/live -vn -c:a mp3 -ac 2 -b:a 64k -ar 44100 -legacy_icecast 1 -f mp3 icecast://source:[email protected]:80/live

QUESTION:

How can I use the command 1 above to still send to both icecast servers but having the -legacy_icecast 1 option to only affect the zeno icecast server and not the liquidsoap icecast server? I want to avoid running 2 separate instances of ffmpeg at all cost in order to save system resources and bandwidth.

The reason I ask this question is because I tried adding the -legacy_icecast 1 option to the command 1 (that one that sends to both) by placing it right before the ...-f tee... option, but it still didn't work to send to Zeno icecast server which failed (the liquidsoap icecast server kept running fine). It seems to only work fine when I use command 2 (above) when not using the tee muxer option.

Is there a tricky way to place that -legacy_icecast 1 option within the tee muxer option??

shelomito12 avatar Jun 04 '20 17:06 shelomito12