Skip to content

Commit

Permalink
Add fb live url to venue, adjust userdata creation
Browse files Browse the repository at this point in the history
I added the db migration and the schema update. Due to a bug/undocumented behavior of ffmpeg with external images as source, we are saving an image during the build of the image.

I adjusted userdata.sh.erb to render the corrent userdata.sh that spawns a ffmpeg container with the fb live url from of the venue.
  • Loading branch information
joseferben committed Oct 3, 2017
1 parent f397e78 commit 136c98b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
5 changes: 5 additions & 0 deletions db/migrate/20171002092046_add_facebook_live_url_to_venues.rb
@@ -0,0 +1,5 @@
class AddFacebookLiveUrlToVenues < ActiveRecord::Migration
def change
add_column :venues, :facebook_live_url, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170726125056) do
ActiveRecord::Schema.define(version: 20171002092046) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -573,6 +573,7 @@
t.string "device_name", default: "noop"
t.datetime "disconnected_at"
t.datetime "awaiting_stream_at"
t.string "facebook_live_url"
end

add_index "venues", ["device_id"], name: "index_venues_on_device_id", using: :btree
Expand Down
10 changes: 10 additions & 0 deletions lib/ffmpeg/Dockerfile
@@ -0,0 +1,10 @@
FROM jrottenberg/ffmpeg

MAINTAINER Josef Erben "josef@voicerepublic.com"

RUN apt-get install wget -y && \
wget -O /home/image.png https://www.seeklogo.net/wp-content/uploads/2016/06/Facebook-Live-logo.png

CMD ["--help"]
ENTRYPOINT ["ffmpeg"]
ENV LD_LIBRARY_PATH=/usr/local/lib
7 changes: 7 additions & 0 deletions lib/ffmpeg/build.sh
@@ -0,0 +1,7 @@
#!/bin/bash

DIR="$(cd "$(dirname "$0")" && pwd)"

cd $DIR

docker build -t jerben/ffmpeg .
18 changes: 15 additions & 3 deletions lib/userdata/icebox.sh.erb
Expand Up @@ -59,19 +59,31 @@ docker run \
--publish=443:8443 \
--restart=unless-stopped \
--volume=$STORAGE/$PREFIX:/share \
branch14/icecast2
branch14/icecast2

# in dev this helps
#
# docker stop icecast
# docker rm icecast
# docker run \
# -d \
# --name=icecast \
# --network=voicerepublicdev_network \
# --env-file=$ENV_LIST \
# --publish=<%= port %>:8080 \
# --volume=$STORAGE/$PREFIX:/share \
# branch14/icecast2

# branch14/icecast2

<% if facebook_live_url %>
docker stop ffmpeg
docker rm ffmpeg
docker run \
-d \
--name=ffmpeg \
--net=host \
--restart=unless-stopped \
jerben/ffmpeg -stats -loop 1 -i /home/image.png -i http://localhost/.aac -acodec aac -ar 44100 -b:a 128k -s 835x288 -bufsize 6000k -vb 400k -maxrate 1500k -deinterlace -vcodec libx264 -preset fast -g 30 -r 30 -f flv '<%= facebook_live_url %>'
<% end %>

# callback to slack -- for debugging only
# CLIENT_TOKEN=<%= client_token %>
Expand Down

0 comments on commit 136c98b

Please sign in to comment.