Bubble UPNP server on RPI B+
Installation of Bubble UPNP on RPI, allows RPI to transcode videos to Chromecast. Casting the mobile screen to Chromecast looks good, but the power of the mobile drains out quickly. To avoid this, the media file has to be fed to Chromecast it its own way(transcoding from another HW), and the transcoding process has to controlled via mobile - just like a remote.
Required Hardware components
- Raspberry pi(I'm using B+ model)
- Chromecast
- Raspbian OS
- Minidlna
- AAC library
- ffmpeg
- Bubbleupnp server
- Android app to control bubble UPNP server
Currently I'm using an older version
lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.11 (wheezy)
Release: 7.11
Codename: wheezy
Pre-requistes
Execute the below commands which will install the required packages
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get -y install autoconf automake build-essential libass-dev libgpac-dev libtool pkg-config texi2html zlib1g-dev libmp3lame-dev libx264-dev
Minidlna
It is a server that handles the media files. Clear installation steps are provided in this link. In case of any permission issues check this link.
AAC library
This library is used for Audio transcoding to Chromecast. The final library will be linked with 'ffmpeg' tool. Execute the below commands to download and install the library.
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master
unzip fdk-aac.zip
cd mstorsjo-fdk-aac*
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
sudo make
sudo make install
ffmpeg
It is a tool that is used to convert a media file as per the target requirements. In our case, it is required to do the main transcoding work. Even though, ffmpeg can be installed using 'apt', I prefer to download the source code and compile it, as I can configure it with extra features.
cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --disable-ffplay --enable-libx264 --enable-nonfree
sudo make
sudo make install
sudo cp ~/bin/* /usr/bin/
The compilation may take up to 4 hours on RPI B+.Bubbleupnp server
The main server that handles the request from mobile to do the actual transcoding via ffmpeg.
mkdir ~/bubbleupnp_server
cd bubbleupnp_server/
wget http://www.bubblesoftapps.com/bubbleupnpserver/BubbleUPnPServer-distrib.zip
unzip BubbleUPnPServer*.zip
Test the Bubble UPNP server cd bubbleupnp_server/
chmod +x launch.sh
./launch.sh
In case of any issues related to permission, try it with 'sudo'. On successful execution of the script, the below output should be seen on the console. Jun 20, 2018 1:58:37 AM com.bubblesoft.bubbleupnpserver.server.Main initDataDir
INFO: data directory: /home/rpi_home/bubbleupnp_server
Jun 20, 2018 1:58:37 AM com.bubblesoft.bubbleupnpserver.server.Main run
INFO: starting BubbleUPnP Server 0.9-update30...
Jun 20, 2018 1:59:03 AM com.bubblesoft.bubbleupnpserver.server.Options load
INFO: loaded configuration file: /home/rpi_home/bubbleupnp_server/configuration.xml
logging to file enabled
[main (1) ] INFO - 0:00:00.182 - Main : starting BubbleUPnP Server 0.9-update30...
[main (1) ] INFO - 0:00:00.285 - Main : os.arch: arm, x86: false
[main (1) ] INFO - 0:00:00.306 - Main : os.name: Linux
[main (1) ] INFO - 0:00:00.317 - Main : os.version: 4.1.19+
[main (1) ] INFO - 0:00:00.328 - Main : java.home: /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre
[main (1) ] INFO - 0:00:00.351 - Main : java.vendor: Oracle Corporation
[main (1) ] INFO - 0:00:00.365 - Main : java.version: 1.8.0
[main (1) ] INFO - 0:00:00.386 - Main : java.class.path: BubbleUPnPServerLauncher.jar
[main (1) ] INFO - 0:00:01.76 - Main : md5sum: eef2e74dc64efd1698ba45ff1d6aac76
[main (1) ] INFO - 0:00:01.87 - Main : restart_count: 0
[main (1) ] INFO - 0:00:01.109 - Main : file.encoding: UTF-8
[main (1) ] INFO - 0:00:01.121 - Main : default charset: UTF-8
[main (1) ] INFO - 0:00:01.131 - Main : bin dir: /home/rpi_home/bubbleupnp_server
[main (1) ] INFO - 0:00:04.411 - d : >>> Starting UPnP service...
[main (1) ] INFO - 0:00:04.421 - d : Using configuration: com.bubblesoft.bubbleupnpserver.server.Main$b
[main (1) ] INFO - 0:00:04.675 - b : Creating Router: org.fourthline.cling.e.b
[main (1) ] INFO - 0:00:05.40 - r : Created server (for receiving TCP streams) on: /:50528
[main (1) ] INFO - 0:00:05.66 - h : Creating wildcard socket (for receiving multicast datagrams) on port: 1900
[main (1) ] INFO - 0:00:05.131 - h : Joining multicast group: /239.255.255.250:1900 on network interface: eth0
[main (1) ] INFO - 0:00:05.150 - a : Creating bound socket (for datagram input/output) on: /
[main (1) ] INFO - 0:00:05.210 - d : <<< UPnP service started successfully
[main (1) ] INFO - 0:00:05.237 - i : Display name: eth0
[main (1) ] INFO - 0:00:05.247 - i : Name: eth0
[main (1) ] INFO - 0:00:05.257 - i : InetAddress: /
[main (1) ] INFO - 0:00:05.268 - i : Interface Address
[main (1) ] INFO - 0:00:05.278 - i : Address: /
[main (1) ] INFO - 0:00:05.288 - i : Broadcast: /
[main (1) ] INFO - 0:00:05.298 - i : Prefix length: 24
[main (1) ] INFO - 0:00:05.311 - i : Up? true
[main (1) ] INFO - 0:00:05.321 - i : Loopback? false
[main (1) ] INFO - 0:00:05.332 - i : PointToPoint? false
[main (1) ] INFO - 0:00:05.342 - i : Supports multicast? true
[main (1) ] INFO - 0:00:05.352 - i : Virtual? false
[main (1) ] INFO - 0:00:05.367 - i : Hardware address: [-72, 39, -21, 82, -10, 83]
[main (1) ] INFO - 0:00:05.383 - i : MTU: 1500
[main (1) ] INFO - 0:00:05.436 - Main : started monitor network changes task, interval=30
[main (1) ] INFO - 0:00:05.726 - Main : waiting for IGD...
[cling-6 (17) ] INFO - 0:00:06.66 - f : Sending device descriptor retrieval message: (c) GET http://192.168.0.1:5431/igdevicedesc.xml
[main (1) ] INFO - 0:00:10.470 - Main : IGD connection service found
[main (1) ] INFO - 0:00:10.583 - Main : default route: gateway: 192.168.0.1, network interface: eth0
[main (1) ] INFO - 0:00:10.610 - Main : using bind address from network interface list
[main (1) ] INFO - 0:00:10.660 - ae : failed to add iptables rule 'iptables -I INPUT -d -p tcp --dport 58050 -j ACCEPT' (code: 3)
[main (1) ] INFO - 0:00:10.716 - ae : failed to add iptables rule 'iptables -I INPUT -d -p tcp --dport 58051 -j ACCEPT' (code: 3)
[main (1) ] INFO - 0:00:10.732 - Main : bind interface: ip: , netmask: 255.255.255.0
[main (1) ] INFO - 0:00:10.744 - Main$a : canUseQSVHwAccel: false
[main (1) ] INFO - 0:00:10.755 - Main : using ffmpeg binaries from: system PATH
[main (1) ] INFO - 0:00:10.977 - Main : ffmpeg version N-91321-ge85c608 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.6 (Debian 4.6.3-14+rpi1)
configuration: --prefix=/home/rpi_home/ffmpeg_build --extra-cflags=-I/home/rpi_home/ffmpeg_build/include --extra-ldflags=-L/home/rpi_home/ffmpeg_build/lib --bindir=/home/rpi_home/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --disable-ffplay --enable-libx264 --enable-nonfree
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 20.102 / 58. 20.102
libavformat 58. 17.100 / 58. 17.100
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 25.100 / 7. 25.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
[main (1) ] INFO - 0:00:11.3 - Main : ffmpeg does not support SoX resampler
[main (1) ] INFO - 0:00:11.129 - Main : ffmpeg supports mp3 encoding (libmp3lame)
[main (1) ] INFO - 0:00:11.139 - Main : ffmpeg doesn't support libvorbis encoder
[main (1) ] INFO - 0:00:11.156 - Main : ffmpeg doesn't support libopus encoder
[main (1) ] INFO - 0:00:11.165 - Main : ffmpeg supports flac encoder
[main (1) ] INFO - 0:00:11.174 - Main : ffmpeg supports libx264 software encoder
[main (1) ] INFO - 0:00:11.184 - Main : ffmpeg doesn't support h264_nvenc hardware encoder
[main (1) ] INFO - 0:00:11.194 - Main : ffmpeg doesn't support h264_qsv hardware encoder
[main (1) ] INFO - 0:00:11.203 - Main : ffmpeg supports high quality aac encoding (libfdk_aac)
[main (1) ] INFO - 0:00:11.334 - Main : ffmpeg doesn't support cuvid hardware decoders
[main (1) ] INFO - 0:00:11.346 - Main : ffmpeg doesn't support qsv hardware decoders
[main (1) ] INFO - 0:00:11.398 - Main : ffmpeg doesn't support cuvid hardware accel
[main (1) ] INFO - 0:00:11.407 - Main : ffmpeg doesn't support qsv hardware accel
[main (1) ] INFO - 0:00:11.548 - Main : ffmpeg supports matroska encoding
[main (1) ] INFO - 0:00:11.557 - Main : ffmpeg supports mpegts encoding
[main (1) ] INFO - 0:00:12.217 - Main : ffmpeg supports -id3v2_version option
[main (1) ] INFO - 0:00:12.235 - Main : ffmpeg supports the -seekable option
[main (1) ] INFO - 0:00:12.244 - Main : ffmpeg supports the -codec option
[main (1) ] INFO - 0:00:12.262 - Main : ffmpeg supports the -ignore_unknown option
[main (1) ] INFO - 0:00:12.311 - Main : ffmpeg supports the scale video filter
[main (1) ] INFO - 0:00:12.379 - Main : ffmpeg supports the aac_adtstoasc bitstream filter
[main (1) ] INFO - 0:00:12.419 - Main : ffprobe found
[cling-6 (17) ] INFO - 0:00:13.74 - b$3 : Added port mapping: TCP/58051
[cling-4 (15) ] INFO - 0:00:13.79 - b$3 : Added port mapping: TCP/58050
[main (1) ] INFO - 0:00:13.599 - Options : successfully got WAN IP Address
[main (1) ] INFO - 0:00:13.636 - Options : gateway: 183.83.48.109 (183.83.48.109)
[main (1) ] INFO - 0:00:14.949 - b : created Super Media Server local device
[main (1) ] INFO - 0:00:15.203 - b : created BubbleUPnP Server local device
[cling-4 (15) ] INFO - 0:00:16.30 - c :
Manufacturer: Bubblesoft
Manufacturer URL: http://forum.xda-developers.com/showthread.php?t=1118891
Model name: BubbleUPnP Server
Model description: BubbleUPnP Server
Model number: 0.9-update30
UDN: c0dc5d74-6ffb-a2ae-ffff-ffff8732071a
[cling-6 (17) ] INFO - 0:00:16.27 - c :
Manufacturer: Bubblesoft
Manufacturer URL: http://bubblesoftapps.com/bubbleupnpserver/
Model name: BubbleUPnP Server Services
Model description: BubbleUPnP Server Services
Model number: 0.9-update30
UDN: c0dc5d74-6ffb-a2ae-ffff-ffffc893b8c3
[main (1) ] INFO - 0:00:16.207 - b : started Google Cast device discovery on network interface: /
[main (1) ] INFO - 0:00:16.719 - e : stream request idle time: 10800 seconds
[main (1) ] INFO - 0:00:18.469 - i : HV000001: Hibernate Validator 4.3.2.Final
[main (1) ] INFO - 0:00:21.190 - e : media access log is disabled
2018-06-20 01:59:26.765:INFO:oejs.u:jetty-7.6.21.v20160908
[main (1) ] INFO - 0:00:23.472 - b : started c.b.b.s.d{/SuperMediaServer,null}
[main (1) ] INFO - 0:00:23.686 - b : started c.b.b.s.d{/dev,null}
[main (1) ] INFO - 0:00:23.717 - b : started c.b.b.s.d{/res,null}
[main (1) ] INFO - 0:00:25.924 - b : started o.e.j.s.ServletContextHandler{/chromecast,null}
[main (1) ] INFO - 0:00:25.945 - b : started o.e.j.s.ServletContextHandler{/ffmpegpcmdecode,null}
[main (1) ] WARNING - 0:00:25.963 - b : !RequestLog
[main (1) ] INFO - 0:00:26.68 - b : started o.e.j.s.ServletContextHandler{/stream,file:/home/rpi_home/bubbleupnp_server/}
[main (1) ] INFO - 0:00:26.169 - b : started o.e.j.s.ServletContextHandler{/proxy,null}
[main (1) ] INFO - 0:00:26.227 - b : started c.b.b.s.d{/,jar:file:BubbleUPnPServer.jar!/}
[main (1) ] INFO - 0:00:26.789 - b : Creating Jetty7 async servlet handler for server jetty/7.6.21.v20160908
[main (1) ] INFO - 0:00:26.909 - b : Started a@:58050
[main (1) ] INFO - 0:00:26.922 - e : started Jetty connector on :58050
[main (1) ] INFO - 0:00:35.74 - b : Enabled Protocols [SSLv2Hello, SSLv3, TLSv1, TLSv1.1, TLSv1.2] of [SSLv2Hello, SSLv3, TLSv1, TLSv1.1, TLSv1.2]
[main (1) ] INFO - 0:00:35.159 - b : Started d@:58051
[main (1) ] INFO - 0:00:35.175 - e : started Jetty connector on :58051
[main (1) ] INFO - 0:00:35.208 - b : Started a@127.0.0.1:58050
[main (1) ] INFO - 0:00:35.230 - e : started Jetty connector on 127.0.0.1:58050
[main (1) ] INFO - 0:00:35.309 - b : Started d@127.0.0.1:58051
[main (1) ] INFO - 0:00:35.317 - e : started Jetty connector on 127.0.0.1:58051
[main (1) ] INFO - 0:00:35.335 - d : started discovery maintenance task, interval=300
[main (1) ] INFO - 0:00:35.450 - Main : initial update check scheduled in 2h 0 min
[cling-15 (78) ] INFO - 0:00:35.520 - f : Sending device descriptor retrieval message: (c) GET http://:8200/rootDesc.xml
[cling-31 (95) ] INFO - 0:00:36.51 - c :
Manufacturer: Justin Maggard
Manufacturer URL: http://www.debian.org/
Model name: Windows Media Connect compatible (MiniDLNA)
Model description: MiniDLNA on Debian
Model number: 1
Model URL: http://www.debian.org/
Presentation URL: /
Serial number: 12345678
UDN: 4d696e69-444c-164e-9d41-b827eb52f653
[main (1) ] INFO - 0:00:36.128 - d : server: root: added interceptor
[qtp32948830-65 (65) ] INFO - 0:01:07.457 - b : com.bubblesoft.bubbleupnpserver.server.servlets.f-7145c: g
[qtp32948830-65 (65) ] INFO - 0:01:07.653 - d : added comet session: hegc6rf15bzhtbmpj8pf3lmm
[qtp32948830-65 (65) ] INFO - 0:01:07.672 - d : comet session already added: hegc6rf15bzhtbmpj8pf3lmm
[qtp32948830-106 (106) ] INFO - 0:01:26.413 - b : connection test to http://183.83.48.109:58050/res/connectiontest => Cannot connect. Check that the public host name is valid and that port 58050 is opened on your router
[qtp32948830-106 (106) ] SEVERE - 0:01:26.423 - b : connection test to http://183.83.48.109:58050/res/connectiontest failed: Cannot connect. Check that the public host name is valid and that port 58050 is opened on your router
[qtp32948830-66 (66) ] INFO - 0:01:27.405 - b : connection test to https://183.83.48.109:58051/res/connectiontest => Cannot connect. Check that the public host name is valid and that port 58051 is opened on your router
[qtp32948830-66 (66) ] SEVERE - 0:01:27.413 - b : connection test to https://183.83.48.109:58051/res/connectiontest failed: Cannot connect. Check that the public host name is valid and that port 58051 is opened on your router
Also check whether the server is accessible via browser http://<rpi-ip>:58050/. The status tab should display as shown below
Now, this script can be added as a service. Copy the .jar files to /var folder.
mkdir /var/www/bubbleupnp/
sudo cp ~/bubbleupnp_server/*.jar /var/www/bubbleupnp/ -v
Open the file "/etc/init.d/BubbleUPnPServer" with sudo permissions and copy the below code. #!/bin/bash
### BEGIN INIT INFO
# Provides: BubbleServer
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: BubbleUPnP Server Background Service Management
# Description: Used to ensure BubbleUPnP starts/stops etc
### END INIT INFO
DAEMON_PATH="/var/www/bubbleupnp"
DAEMON="java -Xss256k -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -jar BubbleUPnPServerLauncher.jar"
DAEMONOPTS=""
NAME=BubbleUPnPServer
DESC="Runs BubbleUPnPServer"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
case "$1" in
start)
printf "%-50s" "Starting $NAME..."
cd $DAEMON_PATH
PID=`$DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $!`
#echo "Saving PID" $PID " to " $PIDFILE
if [ -z $PID ]; then
printf "%sn" "Fail"
else
echo $PID > $PIDFILE
printf "%sn" "Ok"
fi
;;
status)
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
printf "%sn" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%sn" "Service not running"
fi
;;
stop)
printf "%-50s" "Stopping $NAME"
PID=`cat $PIDFILE`
cd $DAEMON_PATH
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%sn" "Ok"
rm -f $PIDFILE
else
printf "%sn" "pidfile not found"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac
Set the permissions appropriately. sudo chmod 755 /etc/init.d/BubbleUPnPServer
I prefer not to add it as default service, as it consumes more CPU usage. Please refer this link for more infoAndroid app to control bubble UPNP server
In this BubbleUPNP app under "settings" add the "RPI IP" and port number to access
Thanks to codeformatter.blogspot.com that enabled to put the code in this blog easily.
Thanks for the guide.
ReplyDeleteI managed to compile ffmpeg and ffprobe then copied them to the bubbleupnp server folder located in /home/ and restarted the server, but in the server settings it still says that GPU transcoding not possible because FFmpeg is not compiled.
Any advice would be much appreciated.