xbmc minified as a server?

  Thread Rating:
  • 8 Votes - 3.88 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Bootlegninja Offline
Member
Posts: 99
Joined: May 2011
Reputation: 0
Post: #286
Just compiled beta 3 without issue.

Here's the xbmc-server.cpp, make_xbmc-server, make_xbmcVideoLibraryScan, and xbmcVideoLibraryScan.cpp from various posts in this thread. I believe all of it being vicbitter's work.

http://bootleg.sksapps.com/files/xbmc-se...bmc-server
http://bootleg.sksapps.com/files/xbmc-se...ibraryScan
http://bootleg.sksapps.com/files/xbmc-se...server.cpp
http://bootleg.sksapps.com/files/xbmc-se...ryScan.cpp

Hell, I've been meaning to post the exact process I use on my Debian Squeeze system so that others can benefit form the work all the devs here have done. All credit in this goes to vicbitter, Odin, joelones, manxam, and probably some others that I'm forgetting. I take no credit in this. Just organizing and throwing it in a single post so that others won't have to hunt for it.

My process: (anything in a code box is a command in your Linux terminal.) And this is from a scratch Debian Squeeze system and I'm logged in as root.

I found a way to install Java a bit easier. You need to be able to add Launchpad PPA's in Squeeze. I'm also adding any Launchpad PPA as Ubuntu Precise.
Code:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4631BBEA

Add the Java JRE 7 PPA in your /etc/apt/sources.list

Code:
nano /etc/apt/sources.list

add at the bottom:
Code:
deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main
And save it.

Now add the keyring for it.
Code:
gpg --keyserver pgpkeys.mit.edu --recv-key  c2518248eea14886
gpg -a --export c2518248eea14886 | sudo apt-key add -

Install all packages needed to compile xbmc within Squeeze
Code:
sudo apt-get update && sudo apt-get -y install git-core build-essential gawk pmount libtool nasm yasm automake cmake gperf zip unzip bison libsdl-dev libsdl-image1.2-dev libsdl-gfx1.2-dev libsdl-mixer1.2-dev libfribidi-dev liblzo2-dev libfreetype6-dev libsqlite3-dev libogg-dev libasound2-dev python-sqlite libglew-dev libcurl3 libcurl4-gnutls-dev libxrandr-dev libxrender-dev libmad0-dev libogg-dev libvorbisenc2 libsmbclient-dev libmysqlclient-dev libpcre3-dev libdbus-1-dev libhal-dev libhal-storage-dev libjasper-dev libfontconfig-dev libbz2-dev libboost-dev libenca-dev libxt-dev libxmu-dev libpng-dev libjpeg-dev libpulse-dev mesa-utils libcdio-dev libsamplerate-dev libmpeg3-dev libflac-dev libiso9660-dev libass-dev libssl-dev fp-compiler gdc libmpeg2-4-dev libmicrohttpd-dev libmodplug-dev libssh-dev gettext cvs python-dev libyajl-dev libboost-thread-dev libplist-dev libusb-dev libudev-dev libtinyxml-dev libcap-dev autopoint libltdl-dev swig libgtk2.0-bin doxygen oracle-java7-installer

Install taglib as per Odin's post

Code:
wget https://github.com/downloads/taglib/taglib/taglib-1.8.tar.gz
tar xzf taglib-1.8.tar.gz
cd taglib-1.8
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_RELEASE_TYPE=Release .
make
make install
rm /usr/local/lib/libtag*.a

Clone the XBMC GIT repository
Code:
git clone git://github.com/xbmc/xbmc.git

At this point, I place vicbitter's sources in ~/xbmc/xbmc. Since I'm logged in as root, and I'm in the /root folder, my path for that would be /root/xbmc/xbmc.

Code:
cd /root/xbmc/xbmc
wget http://bootleg.sksapps.com/files/xbmc-server/make_xbmc-server
wget http://bootleg.sksapps.com/files/xbmc-server/make_xbmcVideoLibraryScan
wget http://bootleg.sksapps.com/files/xbmc-server/xbmc-server.cpp
wget http://bootleg.sksapps.com/files/xbmc-server/xbmcVideoLibraryScan.cpp

Change directories to /root/xbmc and build it.
Code:
cd /root/xbmc
./bootstrap
./configure --enable-shared-lib
make

I had to make xbmc-xrandr so that I could install xbmc properly.
Code:
make xbmc-xrandr

Copy libxbmc.so to /lib
Code:
cp libxbmc.so /lib

Now install xbmc
Code:
make install

Change directories to /root/xbmc/xbmc and build xbmc-server and xbmcVideoLibraryScan. Then copy it to the correct location
Code:
cd /root/xmbc/xbmc
make -f make_xbmcVideoLibraryScan
make -f make_xbmc-server
cp xbmc-server /usr/local/lib/xbmc/xbmc-server.bin
cp xbmcVideoLibraryScan /usr/local/lib/xbmc/

You're done if you don't want it to start up with your NAS. If you do, continue on.

Download the init script in the right place and make it executable and install it.
Code:
cd /etc/init.d
wget http://bootleg.sksapps.com/files/xbmc-server/xbmc
chmod 744 xbmc
update-rc.d xbmc defaults

Just start it and you're done

Code:
/etc/init.d/xbmc start

It' should start on boot every time now.
(This post was last modified: 2012-12-10 17:18 by Bootlegninja.)
find quote
alexandergoll Offline
Member
Posts: 60
Joined: Oct 2010
Reputation: 0
Post: #287
Thank you for this!!
Will retry this whole thing later today.
Hope it doesn't segfault on me again.
find quote
XBL. Offline
Senior Member
Posts: 105
Joined: Aug 2006
Reputation: 0
Post: #288
(2012-12-10 09:30)Bootlegninja Wrote:  Now install xbmc
Code:
make install
Nice post Smile. One comment though, but I believe that it's not necessary to do a make install. All you're doing is compiling XBMC for the libxbmc.so, after which moving this file to /lib (or whatever directory stores your libraries) is all that's necessary to use it. Make install will just scatter a lot of unused files through your system. So instead of doing make install, I'd recommend moving libxbmc.so from the compile directory to /lib and then continue with your guide.
(This post was last modified: 2012-12-10 13:03 by XBL..)
find quote
KRavEN Offline
Junior Member
Posts: 26
Joined: Jan 2009
Reputation: 2
Post: #289
Nice writeup! Thanks!

I believe
make_xbmcVideoLibraryScan == make_xbmc-server
and
xbmcVideoLibraryScan.cpp == xbmc-server.cpp

The xbmc-server version are newer and renamed to make things less confusing.

The make install is necessary if you're running from /usr/local/lib/xbmc/. If you're running from /opt/xbmc-server there is are some additional steps and edited init script, but the make install is not necessary. I can do a writeup for that process later today.

Whats still missing is setting up portable_data/userdata xml files to scan your library. From what I see sources.xml is ignored when using a mysql. There are some sql statements to run. I'll post those as well.
(This post was last modified: 2012-12-10 14:33 by KRavEN.)
find quote
vicbitter Offline
Donor
Posts: 253
Joined: Jan 2011
Reputation: 3
Post: #290
(2012-12-10 14:30)KRavEN Wrote:  Nice writeup! Thanks!

I believe
make_xbmcVideoLibraryScan == make_xbmc-server
and
xbmcVideoLibraryScan.cpp == xbmc-server.cpp

The xbmc-server version are newer and renamed to make things less confusing.

The make install is necessary if you're running from /usr/local/lib/xbmc/. If you're running from /opt/xbmc-server there is are some additional steps and edited init script, but the make install is not necessary. I can do a writeup for that process later today.

Whats still missing is setting up portable_data/userdata xml files to scan your library. From what I see sources.xml is ignored when using a mysql. There are some sql statements to run. I'll post those as well.

Not quite...

xbmc-server is based on xbmcVideoLibraryScan and has been modified (removing a few lines of code) to allow it to run as a server process that can then be controlled via JSON-RPC, etc whereas xbmcVideoLibraryScan performs a Video Library Scan then exits.
find quote
Steini Offline
Senior Member
Posts: 121
Joined: Mar 2010
Reputation: 0
Post: #291
Hey guys I built again using the beta 3 code and it works beautifully, except that i´m stuck in debug log mode.

I have <loglevel hide="false">0</loglevel> in my advancedsettnings.xml

When i check the log file I can see this line:
NOTICE: Log level changed to 0

But i still get all the debug messages, for example:
DEBUG: trying to set locale to en_US.UTF-8

Am I missing something? Could not see anything in guisettings and since it´s headless I cant really go to the menu and turn it off Smile

Thanks
(This post was last modified: 2012-12-10 15:31 by Steini.)
find quote
manxam Offline
Senior Member
Posts: 163
Joined: Jan 2005
Reputation: 3
Post: #292
(2012-12-10 09:30)Bootlegninja Wrote:  
Code:
cd /root/xbmc
./bootstrap
./configure --enable-shared-lib
make

I had to make xbmc-xrandr so that I could install xbmc properly.
Code:
make xbmc-xrandr

In order to minimize the size and dependencies of the lib and, in order to prevent the requirement of xrandr, use the following ./configure:

Code:
./configure --enable-shared-lib --disable-vdpau --disable-crystalhd --disable-vd
adecoder --disable-vtbdecoder --disable-openmax --disable-rtmp --disable-airplay
--disable-airtunes --disable-libusb --disable-libcec --disable-libmp3lame --dis
able-libcap --disable-joystick --disable-xrandr --disable-rsxs --disable-project
m --disable-dvdcss
find quote
KRavEN Offline
Junior Member
Posts: 26
Joined: Jan 2009
Reputation: 2
Post: #293
Here's what I did on ubuntu 12.10 minimal install using mini.iso. The only option I chose during install was secure shell server.

Install add-apt-repository to make ppa's easier
Code:
sudo apt-get install python-software-properties

Install Java 7
Code:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Install all other packages needed to compile xbmc
Code:
sudo apt-get -y install git-core build-essential gawk pmount libtool nasm yasm automake cmake gperf zip unzip bison libsdl-dev libsdl-image1.2-dev libsdl-gfx1.2-dev libsdl-mixer1.2-dev libfribidi-dev liblzo2-dev libfreetype6-dev libsqlite3-dev libogg-dev libasound2-dev python-sqlite libglew-dev curl libcurl3 libcurl4-gnutls-dev libxrandr-dev libxrender-dev libmad0-dev libogg-dev libvorbisenc2 libsmbclient-dev libmysqlclient-dev libpcre3-dev libdbus-1-dev libhal-dev libhal-storage-dev libjasper-dev libfontconfig-dev libbz2-dev libboost-dev libenca-dev libxt-dev libxmu-dev libpng-dev libjpeg-dev libpulse-dev mesa-utils libcdio-dev libsamplerate-dev libmpeg3-dev libflac-dev libiso9660-dev libass-dev libssl-dev fp-compiler gdc libmpeg2-4-dev libmicrohttpd-dev libmodplug-dev libssh-dev gettext cvs python-dev libyajl-dev libboost-thread-dev libplist-dev libusb-dev libudev-dev libtinyxml-dev libcap-dev autopoint libltdl-dev swig libgtk2.0-bin doxygen libtag1-dev

Ubuntu 12.10 taglib didn't give me any problems so no need to compile it.

Clone the XBMC GIT repository and build everything
Code:
git clone git://github.com/xbmc/xbmc.git
cd ./xbmc/xbmc
wget http://bootleg.sksapps.com/files/xbmc-server/make_xbmc-server
wget http://bootleg.sksapps.com/files/xbmc-server/xbmc-server.cpp
cd ..
./bootstrap

./configure  --enable-shared-lib  --disable-debug --disable-vdpau  --disable-vaapi --disable-crystalhd  --disable-vdadecoder  --disable-vtbdecoder  --disable-openmax  --disable-joystick --disable-xrandr  --disable-rsxs  --disable-projectm --disable-rtmp  --disable-airplay --disable-airtunes --disable-dvdcss --disable-optical-drive  --disable-libbluray --disable-libusb  --disable-libcec  --disable-libmp3lame  --disable-libcap

make -j2
sudo cp libxbmc.so /lib
sudo ldconfig
cd ./xbmc
make -f make_xbmc-server all

Install everything into /opt/xbmc-server.
Code:
sudo mkdir /opt/xbmc-server
sudo cp xbmc-server /opt/xbmc-server
cd ..
sudo cp -R addons /opt/xbmc-server/
sudo cp -R language /opt/xbmc-server/
sudo cp -R media /opt/xbmc-server/
sudo cp -R sounds /opt/xbmc-server/
sudo cp -R system /opt/xbmc-server/
sudo cp -R userdata /opt/xbmc-server/

Download the init script, make it executable, and run on boot.
Code:
cd /etc/init.d
sudo wget https://dl.dropbox.com/u/20980813/xbmc-server
sudo chmod 744 xbmc-server
sudo update-rc.d xbmc-server defaults

Now start xbmc-server to get our /opt/xbmc-server/portable_data created.
Code:
sudo service xbmc-server start

Count to 10 and then stop
Code:
sudo service xbmc-server stop

Enable the web gui, change the port, set password
Code:
sudo sed -i -e 's~false</webserver>~true</webserver>~g' /opt/xbmc-server/portable_data/userdata/guisettings.xml

sudo sed -i -e 's~80</webserverport>~8585</webserverport>~g' /opt/xbmc-server/portable_data/userdata/guisettings.xml

sudo sed -i -e 's~></webserverpassword>~>password</webserverpassword>~g' /opt/xbmc-server/portable_data/userdata/guisettings.xml

Enable scan on startup if you want
Code:
sudo sed -i -e ':a;N;$!ba;s~false</updateonstartup>\n    </musiclibrary>~true</updateonstartup>\n    </musiclibrary>~g' /opt/xbmc-server/portable_data/userdata/guisettings.xml

sudo sed -i -e ':a;N;$!ba;s~false</updateonstartup>\n    </videolibrary>~true</updateonstartup>\n    </videolibrary>~g' /opt/xbmc-server/portable_data/userdata/guisettings.xml

Now edit /opt/xbmc-server/portable_data/userdata/advancedsettings.xml to add backgroundupdate to your libraries and configure the mysql database settings.

Use the name tag to create a new database otherwise omit it. Name must be unique to music and video or you'll have strange issues. I found this out the hard way.

See here for more info.
Code:
<advancedsettings>
  
  <videolibrary>
    <backgroundupdate>true</backgroundupdate>
  </videolibrary>
  
  <musiclibrary>
    <backgroundupdate>true</backgroundupdate>
  </musiclibrary>
  
  <videodatabase>
    <type>mysql</type>
    <host>localhost</host>
    <port>3306</port>
    <user>xbmc</user>
    <pass>xbmc</pass>
    <name>xbmcserver_video</name>
  </videodatabase>
  
  <musicdatabase>
    <type>mysql</type>
    <host>localhost</host>
    <port>3306</port>
    <user>xbmc</user>
    <pass>xbmc</pass>
    <name>xbmcserver_music</name>
  </musicdatabase>
  
</advancedsettings>

Now start xbmc-server again
Code:
sudo service xbmc-server start

If you're starting with a fresh database you'll need to run a couple of queries to add your video sources.

Each query must increment the idPath value. strContent value is the direct path of the source or if it's remote use something like:
Code:
smb://username:password@servername/movies/

You can look at the 'path' table in an existing database to get your scraper settings if you're doing something special.

Here's what I added to my xbmcserver_video75 database.

TV Source
Code:
insert into `path` (`idPath`, `strPath`, `strContent`, `strScraper`, `strHash`, `scanRecursive`, `useFolderNames`, `strSettings`, `noUpdate`, `exclude`, `dateAdded`) values (1, '/media/whs/Recorded TV/', 'tvshows', 'metadata.tvdb.com', null, 0, false, '<settings><setting id="absolutenumber" value="false" /><setting id="dvdorder" value="false" /><setting id="fanart" value="true" /><setting id="language" value="en" /><setting id="posters" value="false" /></settings>', false, false, null);

Movie Source
Code:
insert into `path` (`idPath`, `strPath`, `strContent`, `strScraper`, `strHash`, `scanRecursive`, `useFolderNames`, `strSettings`, `noUpdate`, `exclude`, `dateAdded`) values (2, '/media/whs/Movies/', 'movies', 'metadata.themoviedb.org', null, 2147483647, true, '<settings><setting id="TrailerQ" value="No" /><setting id="fanart" value="true" /><setting id="imdbrating" value="false" /><setting id="keeporiginaltitle" value="false" /><setting id="language" value="en" /><setting id="trailer" value="true" /></settings>', false, false, null);

You also need to add a source record to the xbmcserver_music32 database. Here's what mine looks like
Code:
insert into `path` (`idPath`, `strPath`, `strHash`) values (1, '/media/whs/Music/', null)

Finally issue the library update commands to start scanning
Code:
curl -s -d '{"jsonrpc":"2.0","method":"VideoLibrary.Scan","id":1}' -H 'content-type: application/json;' http://127.0.0.1:8585/jsonrpc?VideoLibrary.Scan

curl -s -d '{"jsonrpc":"2.0","method":"AudioLibrary.Scan","id":1}' -H 'content-type: application/json;' http://127.0.0.1:8585/jsonrpc?AudioLibrary.Scan
(This post was last modified: 2012-12-10 23:09 by KRavEN.)
find quote
KRavEN Offline
Junior Member
Posts: 26
Joined: Jan 2009
Reputation: 2
Post: #294
(2012-12-10 19:27)manxam Wrote:  
(2012-12-10 09:30)Bootlegninja Wrote:  
Code:
cd /root/xbmc
./bootstrap
./configure --enable-shared-lib
make

I had to make xbmc-xrandr so that I could install xbmc properly.
Code:
make xbmc-xrandr

In order to minimize the size and dependencies of the lib and, in order to prevent the requirement of xrandr, use the following ./configure:

Code:
./configure --enable-shared-lib --disable-vdpau --disable-crystalhd --disable-vd
adecoder --disable-vtbdecoder --disable-openmax --disable-rtmp --disable-airplay
--disable-airtunes --disable-libusb --disable-libcec --disable-libmp3lame --dis
able-libcap --disable-joystick --disable-xrandr --disable-rsxs --disable-project
m --disable-dvdcss

Looks good. I also added a few:
Code:
./configure  --enable-shared-lib  --disable-debug --disable-vdpau  --disable-vaapi --disable-crystalhd  --disable-vdadecoder  --disable-vtbdecoder  --disable-openmax  --disable-joystick --disable-xrandr  --disable-rsxs  --disable-projectm --disable-rtmp  --disable-airplay --disable-airtunes --disable-dvdcss --disable-optical-drive  --disable-libbluray --disable-libusb  --disable-libcec  --disable-libmp3lame  --disable-libcap

How about these?
Code:
--disable-neon
--disable-gl
--disable-gles
--disable-sdl
--disable-x11
--disable-alsa
--disable-asap-codec
I had added them and tried to build but it didn't finish.
find quote
alexandergoll Offline
Member
Posts: 60
Joined: Oct 2010
Reputation: 0
Post: #295
With beta3 I get an immediate segfault although everything compiled fine.
find quote
Robotica Offline
Banned
Posts: 1,202
Joined: Aug 2010
Post: #296
@Kraven: Great step-by-step tutorial!! Could you also share some statistics: Mem usage, CPU usage, MB on HD?

(2012-12-10 22:09)KRavEN Wrote:  In order to minimize the size and dependencies of the lib and, in order to prevent the requirement of xrandr, use the following ./configure:

Code:
./configure --enable-shared-lib --disable-vdpau --disable-crystalhd --disable-vd
adecoder --disable-vtbdecoder --disable-openmax --disable-rtmp --disable-airplay
--disable-airtunes --disable-libusb --disable-libcec --disable-libmp3lame --dis
able-libcap --disable-joystick --disable-xrandr --disable-rsxs --disable-project
m --disable-dvdcss

Looks good. I also added a few:
Code:
./configure  --enable-shared-lib  --disable-debug --disable-vdpau  --disable-vaapi --disable-crystalhd  --disable-vdadecoder  --disable-vtbdecoder  --disable-openmax  --disable-joystick --disable-xrandr  --disable-rsxs  --disable-projectm --disable-rtmp  --disable-airplay --disable-airtunes --disable-dvdcss --disable-optical-drive  --disable-libbluray --disable-libusb  --disable-libcec  --disable-libmp3lame  --disable-libcap

I would keep debug for now...

(2012-12-10 22:09)KRavEN Wrote:  How about these?
Code:
--disable-neon
--disable-gl
--disable-gles
--disable-sdl
--disable-x11
--disable-alsa
--disable-asap-codec
I had added them and tried to build but it didn't finish.

I guess those are bugs then...
(This post was last modified: 2012-12-11 13:30 by Robotica.)
find quote
manxam Offline
Senior Member
Posts: 163
Joined: Jan 2005
Reputation: 3
Post: #297
(2012-12-10 22:09)KRavEN Wrote:  
Code:
--disable-neon
--disable-gl
--disable-gles
--disable-sdl
--disable-x11
--disable-alsa
--disable-asap-codec
I had added them and tried to build but it didn't finish.

These are all requirements for a linux build as they're needed for things like screensavers and other visuals which are hard codes. Even though we're technically building headless the rest of XBMC doesn't know about these changes and still requires these dependencies.
find quote
XBL. Offline
Senior Member
Posts: 105
Joined: Aug 2006
Reputation: 0
Post: #298
Nice work KRavEN! Should help a lot of people get this running.
find quote
KRavEN Offline
Junior Member
Posts: 26
Joined: Jan 2009
Reputation: 2
Post: #299
(2012-12-11 13:27)Robotica Wrote:  @Kraven: Great step-by-step tutorial!! Could you also share some statistics: Mem usage, CPU usage, MB on HD?
Seems to be more than it should. xbmc-server has 10 processes and 2 are always between 7% and 20% cpu even when doing nothing that I can see. Each process also consumes 152M.

My libxbmc.so size is 19211222
find quote
manxam Offline
Senior Member
Posts: 163
Joined: Jan 2005
Reputation: 3
Post: #300
Hrmm.. My so is about the same size +/- a few MB but my general CPU usage is 2% on a quad core 3.2 Ghz AMD. It goes to about 7% when updating content in a MySQL database and the content is served locally but accessed via an exported NFS share.

I've temporarily made the switch to a windows box though as sharing content via UPNP while scanning and/or cleaning crashes the xbmc process due to a libpthread crash that I can't track down.. Sad
find quote
Post Reply