-
-
Save BusterNeece/5dbfb4dbc1846055c9ab07a7c685899c to your computer and use it in GitHub Desktop.
# What is This Script? | |
# This script allows you to broadcast your AzuraCast radio signal to a remote video stream, using a | |
# static video file that loops in the background and dynamically writing the currently playing track | |
# on top of that video file. | |
# | |
# This script replaces the previous "radio-video-stream" project, allowing you to manage files directly from | |
# within AzuraCast and not requiring any changes to your Docker configuration at all. | |
# | |
# To use this script, you must be running at least AzuraCast 0.19.0 or a later Rolling Release version. | |
# | |
# Before Using This Script: | |
# - Upload a video file to a folder under your station's media library (in the example below, named "videostream") | |
# - Choose a font to display Now Playing data and upload a TTF version of that font to the same folder | |
# | |
# How to Use This Script | |
# - Copy the section below. | |
# - Visit your station's "Edit Liquidsoap Configuration" section (under "Broadcasting" in newer versions) | |
# - Paste the code into the bottom-most configuration section | |
# - Customize as necessary with your station's media directory and font specifications | |
# - Click "Save Changes" and then "Restart Broadcasting" | |
# - Enjoy! | |
# | |
# VIDEO STREAM | |
# | |
# Edit This: Station Base Directory | |
station_base_dir = "/var/azuracast/stations/station_name" | |
# Edit This: YouTube Stream Key | |
youtube_key = "abcd-1234-abcd-1234" | |
# Path to the video file that will loop behind the Now Playing text (you have to provide this) | |
video_file = station_base_dir ^ "/media/videostream/video.mp4" | |
# Path to a font (TTF) file that will be used to draw the Now Playing text (you have to provide this) | |
font_file = station_base_dir ^ "/media/videostream/font.ttf" | |
# A static file auto-generated by AzuraCast in the "config" dir. | |
nowplaying_file = station_base_dir ^ "/config/nowplaying.txt" | |
# Align text | |
font_size = "50" | |
font_x = "340" | |
font_y = "990" | |
font_color = "white" | |
# Method to overlay now playing text | |
def add_nowplaying_text(s) = | |
def mkfilter(graph) | |
let {video = video_track} = source.tracks(s) | |
video_track = ffmpeg.filter.video.input(graph, video_track) | |
video_track = ffmpeg.filter.drawtext(fontfile=font_file,fontsize=font_size,x=font_x,y=font_y,fontcolor=font_color,textfile=nowplaying_file,reload=5,graph,video_track) | |
video_track = ffmpeg.filter.video.output(graph, video_track) | |
source({ | |
video = video_track | |
}) | |
end | |
ffmpeg.filter.create(mkfilter) | |
end | |
videostream = single(video_file) | |
videostream = add_nowplaying_text(videostream) | |
videostream = source.mux.video(video=videostream, radio) | |
# Output to YouTube | |
enc = %ffmpeg( | |
format="mpegts", | |
%video.raw(codec="libx264", pixel_format="yuv420p", b="300k", preset="superfast", r=25, g=50), | |
%audio( | |
codec="aac", | |
samplerate=44100, | |
channels=2, | |
b="96k", | |
profile="aac_low" | |
) | |
) | |
output.youtube.live.hls(key=youtube_key, fallible=true, encoder=enc, videostream) |
Hi. I have a 1080p video, however, but the stream is 720p. I tried adding height and width, so this is a fix for the stream, but when trying to download it, the 1080p is not available, so will download the 720p. How do I change from 720 to 1080?
I fixed my issue with the size of video by adding the following lines above "# Output to YouTube":
set("frame.video.width", 640)
set("frame.video.height", 360)
Change the values to whatever you want and it should be ok.
I fixed my issue with the size of video by adding the following lines above "# Output to YouTube":
set("frame.video.width", 640) set("frame.video.height", 360)
Change the values to whatever you want and it should be ok.
Thank you, I will try this
Where do I place this file in the docker container?
Hello. Where can I override the youtube method to change the link to the rtmp server ? I need to stream to twitch or another server. Thank you.
Won't work on Azuracast v0.18.5, and also can you add the RTMP server output for own rtmp server such nginx?
Hello, how i can change font color?
The code is working great for me! Thank you! Except I have a few issues. I copied and edited the code exactly as instructed, but my text always says "station offline" what am I doing wrong? Also, I can't get it to recognize my loaded font (Roboto in this instance). Lastly, if I can get the now playing text to work, I'd love to have the text in the top left corner, which x and y numbers coincide with that location?
Can I use a 4k looping .mov?
can anyone confirm this still works in v0.19.4 Stable ? since we updated it no longer works for us.
it work with v0.19.4 Stable for youtube
i try to stream to Owncast .. how can i change the url ?
it work with v0.19.4 Stable for youtube
i try to stream to Owncast .. how can i change the url ?
url = "owncast url here"
output.url(fallible=true, url=url, enc, videostream)
you can try adding this
it work with v0.19.4 Stable for youtube
i try to stream to Owncast .. how can i change the url ?url = "owncast url here" output.url(fallible=true, url=url, enc, videostream)
you can try adding this
this is very helpful thanks .. just i edited and in it work .. now i am facing other problem from OwnCast side ..
---- transcoding error. look at data/logs/transcoder.log to help debug. your copy of ffmpeg may not support your selected codec of libx264 https://owncast.online/docs/codecs/ ---
i will see how to edit this ..
Thank you alot
VIDEO STREAM
Edit This: Station Base Directory
station_base_dir = "/var/azuracast/stations/YOUR-STATION"
Edit This: Stream RTMP Adress
stream_key = "rtmp://YOUR RTMP URL/STREAM-KEY"
Fetch and encode video
video_file = station_base_dir ^ "/media/videostream/video.mp4"
Write now playing to the video file
font_file = station_base_dir ^ "/media/videostream/font.ttf"
A static file auto-generated by AzuraCast in the "config" dir.
nowplaying_file = station_base_dir ^ "/config/nowplaying.txt"
Align text
font_size = "50"
font_x = "340"
font_y = "990"
Method to overlay now playing text
def add_nowplaying_text(s) =
def mkfilter(graph)
let {video = video_track} = source.tracks(s)
video_track = ffmpeg.filter.video.input(graph, video_track)
video_track = ffmpeg.filter.drawtext(font=font_file,fontsize=font_size,x=font_x,y=font_y,textfile=nowplaying_file,graph,video_track)
video_track = ffmpeg.filter.video.output(graph, video_track)
source({
video = video_track
})
end
ffmpeg.filter.create(mkfilter)
end
videostream = single(video_file)
videostream = add_nowplaying_text(videostream)
videostream = source.mux.video(video=videostream, radio)
Output to Twitch
enc = %ffmpeg(
format="flv",
%video.raw(codec="libx264", pixel_format="yuv420p", b="300k", preset="superfast", r=25, g=50),
%audio(
codec="aac",
samplerate=44100,
channels=2,
b="96k",
profile="aac_low"
)
)
output.url(url=stream_key, enc, fallible=true, vid
can i add channel LOGO ?
Thanks for this! I will definitely check it out and us it.
How about putting video files into rotation and/or taking an inbound live/live video feed?
Cheers,
jb
Do I have to use ffmpeg for youtube output?
Also, I am running on Azuracast on a Snology NAS so is there a clean way to install ffmpeg on the NAS?
Finally what is basic setup for ffmpeg to get your script to work?
The AzuraCast Docker image comes with ffmpeg installed and running in it, and can be used by Liquidsoap (and this script) with no changes.
what is the script for just a looping video no text and my HLS playlist to stream on youtube since i cant get restreamer to work currently
help set up broadcasting on telegram something is not working and why not build this function of broadcasting to video services in azuracast in the Remote Broadcast menu.
I'm trying to add the cover being played into the stream without any success
It could be a php page being added to the video stream or even a png being refreshed periodically, but can't manage to do it. Is there a way to do that? Thank you
Oof, I'm scratching my head on how to add a custom RTMP output to this.
This works perfect for me. But getting bit rate issue (Warning
The stream's current bitrate (597.48 Kbps) is lower than the recommended bitrate. We recommend that you use a stream bitrate of 2500 Kbps.) How can I set bit rate?
dude do you know how F* great is this ? thx so much for the script
@aryanbt... you see the b=300k? thats the video bitrate, and the audio is the b=96k... this is what I am using right now
Output to YouTube
enc = %ffmpeg(
format="mpegts",
%video.raw(codec="libx264", pixel_format="yuv420p", b="2000k", preset="superfast", r=25, g=50),
%audio(
codec="aac",
samplerate=44100,
channels=2,
b="192k",
profile="aac_low"
)
)
Hope it helps
@aryanbt... you see the b=300k? thats the video bitrate, and the audio is the b=96k... this is what I am using right now
Output to YouTube
enc = %ffmpeg( format="mpegts", %video.raw(codec="libx264", pixel_format="yuv420p", b="2000k", preset="superfast", r=25, g=50), %audio( codec="aac", samplerate=44100, channels=2, b="192k", profile="aac_low" ) )
Hope it helps
Thanks a lot it works great.
Can someone please share a link to a live example? I'm planning to implement that this year some time.. Thanks.
How to change the video size?