I know this is a bit off-topic for this mailing list, but I figured maybe this 
could help.

I run a 24/7 video stream in which the audio is sourced from a Shoutcast 
server. Instead of broadcasting a still image I decided to try and spice things 
up a bit by using filters on a video track that are audio reactive. I also 
wanted to have the title info in the video frame, not just metadata.

Tracks change about once an hour since they are all DJ mix sets. i display the 
current track title and the current number of listeners in the outgoing rtmp 
stream as draw text filters.

The filter reads from a text file. Using the 'reload' option will make ffmpeg 
reload/read said file every frame. So what I do is have one script thats 
executed by cron once a minute that gets the number of listeners and saves to 
count.txt. And the source software I wrote thats broadcasting to shoutcast 
writes the song title into separate file, title.txt every time it changes, 
making sure that its updated atomically so ffmpeg wont partially read the file 
or fail and exit completely. (instead of editing the file directly, I first 
write the information to a temp.txt file, then mv tmp.txt title.txt)

I have a shell script that defines each different filter I use, then I just put 
it all together at the end... here are a few bits from it...

First I define the listener count drawtext.
This puts the count in the bottom right corner of the frame (1920x1080), with a 
little transparency.... count.txt and font.ttf are in the same directory as the 
script, and I'm sure you get what the other settings are for =]


count="drawtext=fontfile=font.ttf:fontsize=72:fontcolor=white:textfile=count.txt:reload=1:x=(w-text_w)-15:y=(h-60):alpha=.5";


Now I define the title drawtext:
This centers the title at the bottom of the frame, will scale the text in the 
event the string is too long to fit within the width of the frame so that the 
text will never get cut off,  and will blink on and off, displaying for 15 
seconds every 60 seconds, and again, a bit of transparency


title="drawtext=fontfile=font.ttf:fix_bounds=true:fontsize=38:textfile=title.txt:fontcolor=white:reload=1:y=(h-text_h)-25:x=(w-text_w)/2:enable=lt(mod(t\,60)\,15):alpha=.5";


The important bit in each is reload=1.

The ffmpeg string could then be written like this


ffmpeg -i /path/to/video.mp4 -i http://shoutcast-server.com:8000 
-filter_complex $count,$title -s 1920x1080 -c:a libfdk_aac -b:a 256k -c:v 
libx264 -b:v 15000k -preset ultrafast -f flv 
rtmp://stream.output.com/app/streamkey

If you'd like to see what this looks like in action you can visit 
https://www.dsfm.tv (should autoplay)

You can read more about the drawtext filter here:

https://ffmpeg.org/ffmpeg-filters.html#drawtext-1


If you have any questions feel free  =]

Cheers,

Alex

> On Mar 21, 2017, at 2:15 35AM, Akos Veres <[email protected]> wrote:
> 
> I'm using FMPEG as well, that works without any issues, I just want to have a 
> dynamic text added to image so it shows the currently playing track together 
> with album art, LS could generate all of that and then continually push the 
> stream to youtube.
> 
> Best regards,
>         Ákos Veres
> 
> On Mon, Mar 20, 2017 at 6:42 PM, John Chewter <[email protected]> 
> wrote:
> By that I mean icecast -> FMPEG -> YouTube.
> 
> I saw no advantage to using LS
> 
> On 20/03/17 18:09, John Chewter wrote:
>> I have done it with FFMPEG
>> 
>> On 20/03/17 16:13, Akos Veres wrote:
>>> Hi everyone,
>>> 
>>> I'm trying to stream to youtube live an icecast source paired with an image.
>>> 
>>> I've followed these resources: 
>>> - http://savonet.sourceforge.net/doc-svn/video-static.html
>>> - http://liquidsoap.fm/doc-svn/video.html
>>> - 
>>> https://www.sk89q.com/2014/05/broadcasting-a-video-playlist-to-nginx-rtmp-module/
>>> 
>>> The current script:
>>> 
>>> #!/usr/bin/liquidsoap
>>> # XTRadio Video
>>> # Standard settings
>>> set("log.stdout",true)
>>> set("log.file",false)
>>> set("log.level",4)
>>> set("server.telnet",false)
>>> set("frame.video.width",640)
>>> set("frame.video.height",480)
>>> set("frame.video.samplerate",12)
>>> # Stream Settings
>>> backup = input.http(id="xtradio","http://xtradio.org:8080/mp3";)
>>> img = single("/xt-hd.png")
>>> img = mksafe(img) 
>>> radio = backup
>>> video = img
>>> radio = buffer(buffer=0.03,mksafe(radio))
>>> source = mux_video(video=video,radio)
>>> source = mksafe(source)
>>> output.gstreamer.audio_video(id="output.youtube",
>>>   video_pipeline=
>>>     "videoconvert ! x264enc bitrate=4000 ! video/x-h264,profile=baseline ! 
>>> queue ! mux.",
>>>   audio_pipeline=
>>>     "audioconvert ! voaacenc bitrate=128000 ! queue ! mux.",
>>>   pipeline=
>>>     "flvmux name=mux ! rtmpsink 
>>> location=\"rtmp://a.rtmp.youtube.com/live2/KEY\"",
>>>   source)
>>> 
>>> Output
>>> 
>>> xtvideo    | 2017/03/19 12:00:17 [replay_metadata_7237:4] Activations 
>>> changed: static=[mksafe:output(dot)youtube:output(dot)youtube], dynamic=[].
>>> xtvideo    | 2017/03/19 12:00:17 [warp_prod_7187:3] Buffer emptied, start 
>>> buffering...
>>> xtvideo    | 2017/03/19 12:00:17 [mksafe:3] Switch to safe_blank with 
>>> transition.
>>> xtvideo    | 2017/03/19 12:00:17 [replay_metadata_7237:4] Activations 
>>> changed: static=[], dynamic=[].
>>> xtvideo    | 2017/03/19 12:00:17 [source:4] Source replay_metadata_7237 
>>> gets down.
>>> xtvideo    | 2017/03/19 12:00:17 [mux_7189:4] Activations changed: 
>>> static=[], dynamic=[mksafe:output(dot)youtube:output(dot)youtube].
>>> xtvideo    | 2017/03/19 12:00:17 [safe_blank:4] Activations changed: 
>>> static=[mksafe:output(dot)youtube:output(dot)youtube], 
>>> dynamic=[mksafe:output(dot)youtube:output(dot)youtube].
>>> xtvideo    | 2017/03/19 12:00:17 [xtradio:3] New metadata chunk: ? -- 
>>> Calvin Harris feat. Ellie Goulding - Outside (Funk LeBlanc Remix) (04:12) 
>>> http://soundcloud.com/funk-leblanc/calvin-harris-feat-ellie-goulding-outside-funk-leblanc-remix
>>>  .
>>> xtvideo    | 2017/03/19 12:00:17 [mksafe:3] Switch to xtradio with 
>>> transition.
>>> xtvideo    | 2017/03/19 12:00:17 [safe_blank:4] Activations changed: 
>>> static=[], dynamic=[mksafe:mksafe:buffer_7186:buffer_7186].
>>> xtvideo    | 2017/03/19 12:00:17 [xtradio:4] Activations changed: 
>>> static=[mksafe:mksafe:buffer_7186:buffer_7186], 
>>> dynamic=[mksafe:mksafe:buffer_7186:buffer_7186].
>>> xtvideo    | 2017/03/19 12:00:17 [source:4] Garbage collected 
>>> replay_metadata_7237.
>>> xtvideo    | 2017/03/19 12:00:18 [xtradio:4] End of track.
>>> 
>>> It looks like nothing is connecting to youtube, on the dashboard I see no 
>>> connection what so ever.
>>> 
>>> Any RTFM or howto is welcome, I'm pretty sure I'm misunderstanding a 
>>> mechanism somewhere. I don't mind if the same can be achieved with ffmpeg.
>>> 
>>> Best regards,
>>>         Ákos Veres
>>> 
>>> 
>>> 
>>> ------------------------------------------------------------
>>> ------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! 
>>> http://sdm.link/slashdot
>>> 
>>> 
>>> ______________________________
>>> _________________
>>> Savonet-users mailing list
>>> 
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/savonet-users
>> 
>> 
>> 
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! 
>> http://sdm.link/slashdot
>> 
>> 
>> ______________________________
>> _________________
>> Savonet-users mailing list
>> 
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/savonet-users
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Savonet-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/savonet-users
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! 
> http://sdm.link/slashdot_______________________________________________
> Savonet-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/savonet-users

Attachment: smime.p7s
Description: S/MIME cryptographic signature

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to