PuigTV: create your own TV channel

per Roger Borrell darrera modificació 2020-03-25T15:18:35+01:00
This is how we made puig TV. It can also serve you as a tutorial of how to make your own TV from scratch.

Our solution is to install a Ubuntu Server and the Flumotion streamer on top.

 

Ubuntu 12.04 Server Installation

 

Downloading the CD

 

First of all we have downloaded Ubuntu 12.04 Server:

$ wget http://releases.ubuntu.com/12.04.4/ubuntu-12.04.4-server-amd64.iso

 

Cheking integrity of the downloaded iso file

 

To make sure that the downloaded iso is equal to real one, and no corruption has been suffered, we compare the hash in the Ubuntu hashes website with the hash we get after the command:

$ md5sum ubuntu-12.04.4-server-amd64.iso

The hash should be: e83adb9af4ec0a039e6a5c6e145a34de

Burning the CD

 

We burned the CD using K3b. If you don't have it in your system:

$ sudo apt-get install k3b

K3b is a really easy and reliable software:

Select the menu tools--> Burn Image

 Captura de 2014-03-19 11:44:43.png

 Select the image:

Captura de 2014-03-19 11:45:07.png

 

Booting from the CD

Once the CD is burned we must set up the bios in order to make the system start from the CD. For this matter usually you have to press F1 or F2 or delete button.

After that the CD will load.

 

Checking integrity of the burned CD

 

Before you install you should check the integrity of the CD in order to assure that the CD has been burned correctly:

49.png

 

Captura de 2014-03-19 12:05:21.png

 

Captura de 2014-03-19 12:03:20.pngython  

System requirements

 

First of all we have to have a look at the system requirememts for the Ubuntu 12.04 Server.

You need a machine that fits this requirements. Our machine has 512MB of RAM and 160GB of hard drive, so our machine fits this requirements. We will use no-desktop environment since is lighter.

Installing Ubuntu 12.04 Server 

 

Choose your language and proceed:

 09.png

46.png

Choose your keyboard:

04.png

 

20.png

38.png

53.png

11.png

 Choose the name of your machine:

 

Choose a user name:

03.png

Don't encrypt your personal data:

33.png

 Choose your time zone:

 48.png

 

Working with graphical enviorenment to this non-desktop system

In order to work with more comfort we will install ssh in the Server:

$ sudo apt-get install ssh

From a regular machine, a desktop machine,with a graphical interface, we can connect to the Server using:

$ ssh user@machine

In my case:

$ ssh rborrell@server

 

Flumotion  as a TV streamer

 

Installing flumotion

 

Since flumotion is a  such a new software we need to install it using his own repository, as it's website says. It's own PPA, flumotion's PPA.

Now we add the flumotion's ppa repositories to sources:

To install the repository the most comfortable way is to use the program add-apt-repository but this program is under the package python-software-repository which is not installed, so first we install the mentioned package:

rborrell@server$ sudo apt-get install python-software-properties

and then we add the repository:

rborrell@server$ sudo add-apt-repository ppa:flumotion-dev/flumotion

We update the repositories software lists:

rborrell@server$ sudo apt-get update

Now we are ready to install flumotion:

rborrell@server$ sudo apt-get install flumotion

Flumotion architecture

 

Flumotion is a very scalable and flexible software that can be used either for a little project or a really big one. That's the reason why they made it scalable and a distributed software, so it can be flexible.

It has:

  • 1 program called manager
  • 1 or more programs called workers (depending how big the project is and depending if you need to spread the jobs among many workers

 

diagram-architecture-with-workers.png

As you can see Flumotion uses an interesting metaphor: planets, rivers(flows) and atmosphere.

Configuration files

folders-1.png

Flumotion has 2 important configuration files:

Manager config file: /etc/flumotion/managers/default/planet.xml

and

Worker config file: /etc/flumotion/workers/default.xml











First example: live-streaming of a test card


Go to the managers file: /etc/flumotion/managers/default/planet.xml

 

rborrell@server$ sudo vim.tiny /etc/flumotion/managers/default/planet.xml

paste the following configuration file:

/etc/flumotion/managers/default/planet.xml example:

<?xml version="1.0" encoding="UTF-8"?>
<planet>

<manager>
    <debug>4</debug>
    <host>localhost</host>
    <port>38673</port>
    <transport>ssl</transport>
    <!-- certificate path can be relative to $sysconfdir/flumotion,
         or absolute -->
    <certificate>/etc/flumotion/default.pem</certificate>
    <component name="manager-bouncer" type="htpasswdcrypt-bouncer">
      <property name="data">user:PSfNpHTkpTx1M</property>
    </component>
  </manager>

<atmosphere>
    <component name="http-server-audio-video"
               type="http-server"
               label="http-server-audio-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="porter-username">UMXlofBioDve</property>
      <property name="mount-point">/ogg-audio-video/html5/</property>
      <property name="hostname">localhost</property>
      <property name="porter-password">XqbeuzuaHJAY</property>
      <property name="type">slave</property>
      <property name="porter-socket-path">flu-sJYvAQ.socket</property>
      <property name="port">8810</property>
      <plugs>
        <plug type="component-html5">
          <property name="width">320</property>
          <property name="stream-url">http://localhost:8810/ogg-audio-video/</property>
          <property name="codecs">vorbis,theora</property>
          <property name="mime-type">video/ogg</property>
          <property name="height">240</property>
        </plug>
      </plugs>
    </component>
    
    <component name="porter-http"
               type="porter"
               label="porter-http"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="username">UMXlofBioDve</property>
      <property name="socket-path">flu-sJYvAQ.socket</property>
      <property name="password">XqbeuzuaHJAY</property>
      <property name="port">8810</property>
    </component>
    
  </atmosphere>
 
  <flow name="default">
    <component name="producer-audio"
               type="audiotest-producer"
               label="producer-audio"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="volume">1.0</property>
      <property name="samplerate">44100</property>
      <property name="frequency">440</property>
      <clock-master>true</clock-master>
    </component>
    
    <component name="producer-video"
               type="videotest-producer"
               label="producer-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="pattern">0</property>
      <property name="height">240</property>
      <property name="framerate">5/1</property>
      <property name="width">320</property>
      <clock-master>false</clock-master>
    </component>
    
    <component name="overlay-video"
               type="overlay-converter"
               label="overlay-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">producer-video:default</feed>
      </eater>
      <property name="show-text">True</property>
      <property name="text">Flumotion</property>
      <property name="xiph-logo">True</property>
      <property name="fluendo-logo">True</property>
      <clock-master>false</clock-master>
    </component>
    
    <component name="encoder-video"
               type="theora-encoder"
               label="encoder-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">overlay-video:default</feed>
      </eater>
      <property name="keyframe-maxdistance">10</property>
      <property name="speed">3</property>
      <property name="bitrate">400000</property>
      <clock-master>false</clock-master>
    </component>
    
    <component name="encoder-audio"
               type="vorbis-encoder"
               label="encoder-audio"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">producer-audio:default</feed>
      </eater>
      <property name="bitrate">64000</property>
      <clock-master>false</clock-master>
    </component>
    
    <component name="muxer-audio-video"
               type="ogg-muxer"
               label="muxer-audio-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">encoder-audio:default</feed>
        <feed alias="default-bis">encoder-video:default</feed>
      </eater>
      <clock-master>false</clock-master>
    </component>
    
    <component name="http-audio-video"
               type="http-streamer"
               label="http-audio-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">muxer-audio-video:default</feed>
      </eater>
      <property name="burst-on-connect">False</property>
      <property name="porter-username">UMXlofBioDve</property>
      <property name="mount-point">/ogg-audio-video/</property>
      <property name="port">8810</property>
      <property name="type">slave</property>
      <property name="porter-socket-path">flu-sJYvAQ.socket</property>
      <property name="porter-password">XqbeuzuaHJAY</property>
      <clock-master>false</clock-master>
      <plugs>
      </plugs>
    </component>
    
  </flow>
</planet>

Go to the workers configuration file:

rborrell@server$ sudo vim.tiny /etc/flumotion/workers/default.xml

And paste the following text:

/etc/flumotion/workers/default.xml example:


<?xml version="1.0" encoding="UTF-8"?>
<worker>

    <debug>4</debug>

  <manager>
    <host>localhost</host>
    <port>38673</port>
  </manager>

  <authentication type="plaintext">
    <username>user</username>
    <password>test</password>
  </authentication>

  <feederports random="True" />

</worker>

 

 Then we restart the services:

rborrell@server$ sudo service flumotion restart

 

In order to be able to see the TV you must put in your browser the IP or the domain-name of your server, in my case server or 192.168.18.130 like this:

http://server:8810/ogg-audio-video/

or


http://192.168.18.130:8810/ogg-audio-video/

And you should see:

28.png

If you have a good server, then, maybe you could improve the streaming experience by making a bigger screen so instead of using the values 320 for width and 240 for the hight, we could changed to:

Width: 640

Hight: 480

There are 2 places in the configuration manager's file where you have to change this settings.

<plug type="component-html5">
          <property name="width">320</property>
          <property name="stream-url">http://localhost:8810/ogg-audio-video/</property>
          <property name="codecs">vorbis,theora</property>
          <property name="mime-type">video/ogg</property>
          <property name="height">240</property>
        </plug>

And:

<component name="producer-video"
               type="videotest-producer"
               label="producer-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="pattern">0</property>
      <property name="height">240</property>
      <property name="framerate">5/1</property>
      <property name="width">320</property>
      <clock-master>false</clock-master>
    </component>

And then don't forget to reload the configuration file:

 

rborrell@server$ sudo service flumotion force-reload


So now we get a bigger screen ;)

50.png

You can also change the name of your TV. Again in the managers configuration file:

 

<property name="text">Flumotion</property>

 to:

<property name="text">PuigTV</property>

And we reload again:

rborrell@server$ sudo service flumotion restart

And we get our TV with our own name PuigTV:

11.png

And now we are going to change the logo of the TV. We are going to put our own logo:

logo_iespuigcastellar.png

We are going to make a trick, the following way:

 

rborrell@server$  cd /usr/share/flumotion/image/36x36/
rborrell@server$ sudo wget http://elpuig.xeill.net/Members/rborrell/puigtv/imatges/logo_iespuigcastellar.png
rborrell@server$ sudo mv xiph.png xiph_old.png
rborrell@server$ sudo mv logo_iespuigcastellar.png xiph.png

 

Remember that you must always reload the flumotion in order to get the changes:

rborrell@server$ sudo service flumotion force-reload


So now we get the Puig logo instead of the fish.


We can also take out the flumotion logo changing:

 

      <property name="fluendo-logo">True</property>

to:

      <property name="fluendo-logo">False</property>

 At the end we get this:

20.png

Security issues


The authentication between the manager and the worker is made using a user and a password. We really encourage you to change it in order to secure the internal communication.

In the worker's config file you can define a user and password:

<authentication type="plaintext">
    <username>user</username>
    <password>test</password>
  </authentication>

Instead of the default user and password we change it to:

 


<authentication type="plaintext">
    <username>roger</username>
    <password>extasis</password>
  </authentication>

But then, you have to make also the proper changes to the manager's file. In the managers file you have to write the output of the following command:

htpasswd -b -d -n <usuario> <contraseña>

rborrell@server$ htpasswd -b -d -n roger extasis

So finally in the managers congfig file we will substitute:     

<property name="data">roger:p9xfJQWlkCgEY</property>

SSL

 

Authentication between the workers and the managers can be made using tcp or ssl. Using ssl option is more secure. This option uses a public-key cryptography method. To get your own private key:

rborrell@server$ openssl req -newkey rsa:1024 -keyout private-key.txt -nodes -x509 -days 365 -out certificate.txt

Then combine the private key and the certificate into one default.pem file:

rborrell@server$ cat private-key.txt &gt;  ${target}
rborrell@server$ echo ""   &gt;&gt; default.pem
rborrell@server$ cat certificate.txt &gt;&gt; default.pem
rborrell@server$ rm -f private-key certificate.txt
rborrell@server$ cp default.pem /etc/flomotion/default.pem


Organizing files: having more than 1 stream


If we have an scenario with multiple streams we can proceed as following:

folders.png


Now we have 2 planets, puigtv and default.













As we want to have an on-demand streamer also we will proceed the following way.

We need a video repository to store the videos we want to stream, we choose /video:

 

rborrell@server$ sudo mkdir /video

Let's make it a flumotion folder:

rborrell@server$ sudo chown flumotion:flumotion /video

Let's give permission to streaming programs to go into the folder and read:

rborrell@server$ sudo chmod o+x /video


Make sure the new configurations files use different ports, for http-streaming and between the manager and the worker:

Create puigtv folder:

 

rborrell@server$ sudo mkdir /etc/flumotion/managers/puigtv

 

rborrell@server$ sudo chown flumotion:flumotion /etc/flumotion/managers/puigtv

Paste it in the maneger's puigtv config file:

 

rborrell@server$ sudo vim.tiny /etc/flumotion/managers/puigtv/planet.xml


/etc/flumotion/managers/puigtv/planet.xml example:

<?xml version="1.0" encoding="UTF-8"?>
<planet name="puigtv">
  <manager>
    <debug>4</debug>
    <host>localhost</host>
    <port>38674</port>
    <transport>ssl</transport>
    <!-- certificate path can be relative to $sysconfdir/flumotion,
         or absolute -->
    <certificate>/etc/flumotion/default.pem</certificate>
    <component name="manager-bouncer" type="htpasswdcrypt-bouncer">
      <property name="data">roger:p9xfJQWlkCgEY</property>
    </component>
  </manager>

  <atmosphere>
    <component name="http-server-ondemand"
               type="http-server"
               label="http-server-ondemand"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="porter-username">tHySIQJHXefz</property>
      <property name="mount-point">/</property>
      <property name="allow-browsing">True</property>
      <property name="type">slave</property>
      <property name="path">/video/</property>
      <property name="porter-socket-path">flu-eWVKpR.socket</property>
      <property name="port">8811</property>
      <property name="porter-password">RVsYUcoaEHCB</property>
      <plugs>
      </plugs>
    </component>
    
    <component name="porter-http"
               type="porter"
               label="porter-http"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="username">tHySIQJHXefz</property>
      <property name="socket-path">flu-eWVKpR.socket</property>
      <property name="password">RVsYUcoaEHCB</property>
      <property name="port">8811</property>
    </component>   
  </atmosphere>
  </planet>

 

Paste it in the worker's puigtv config file:

rborrell@server$ sudo vim.tiny /etc/flumotion/workers/puigtv.xml


/etc/flumotion/workers/puigtv.xml example:

<worker>

    <debug>4</debug>

  <manager>
    <host>localhost</host>
    <port>38674</port>
  </manager>

  <authentication type="plaintext">
    <username>roger</username>
    <password>extasis</password>
  </authentication>

  <feederports random="True" />

</worker>

If I have a video called myvideo.ogv inside your /video folder then the path from the browser is:

 

http://server:8811/myvideo.ogv

 

or


http://192.168.18.130:8811/myvideo.ogv


Let's put a video in the /video folder:

 

rborrell@server$ wget http://upload.wikimedia.org/wikipedia/commons/6/65/Examplevideo.ogv

 

rborrell@server$ sudo mv Examplevideo.ogv /video/

 

rborrell@server$ sudo chown flumotion:flumotion /video/Examplevideo.ogv

Restart the server:

rborrell@server$ sudo service flumotion restart

Then the video will be seen in, with your browser, in:

http://192.168.18.130:8811/Examplevideo.ogv

 

 Loop video

 

Finally we might want to bradcast a video, like a TV, not on-demand.

Then on the last example the manager would look like:

<?xml version="1.0" encoding="UTF-8"?>
<planet name="puigtv">
  <manager>
    <debug>4</debug>
    <host>localhost</host>
    <port>38674</port>
    <transport>ssl</transport>
    <!-- certificate path can be relative to $sysconfdir/flumotion,
         or absolute -->
    <certificate>/etc/flumotion/default.pem</certificate>
    <component name="manager-bouncer" type="htpasswdcrypt-bouncer">
      <property name="data">roger:p9xfJQWlkCgEY</property>
    </component>
  </manager>

 <atmosphere>
    <component name="http-server-audio-video"
               type="http-server"
               label="http-server-audio-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="porter-username">DkCVXsqGlPMz</property>
      <property name="mount-point">/ogg-audio-video/html5/</property>
      <property name="hostname">localhost</property>
      <property name="porter-password">GtygoZeNWmaZ</property>
      <property name="type">slave</property>
      <property name="porter-socket-path">flu-KqHpaL.socket</property>
      <property name="port">8810</property>
      <plugs>
        <plug type="component-html5">
          <property name="width">480</property>
          <property name="stream-url">http://localhost:8810/ogg-audio-video/</property>
          <property name="codecs">vorbis,theora</property>
          <property name="mime-type">video/ogg</property>
          <property name="height">196</property>
        </plug>
      </plugs>
    </component>

    <component name="porter-http"
               type="porter"
               label="porter-http"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="username">DkCVXsqGlPMz</property>
      <property name="socket-path">flu-KqHpaL.socket</property>
      <property name="password">GtygoZeNWmaZ</property>
      <property name="port">8810</property>
    </component>

  </atmosphere>

 <flow name="default">
    <component name="producer-audio-video"
               type="loop-producer"
               label="producer-audio-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <property name="width">480</property>
      <property name="framerate">30/1</property>
      <property name="location">/video/Examplevideo.ogv</property>
      <property name="height">196</property>
      <clock-master>true</clock-master>
    </component>

    <component name="overlay-video"
               type="overlay-converter"
               label="overlay-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">producer-audio-video:video</feed>
      </eater>
      <property name="show-text">True</property>
      <property name="text">PuigTV</property>
      <property name="xiph-logo">True</property>
      <property name="fluendo-logo">False</property>
      <clock-master>false</clock-master>
    </component>

    <component name="encoder-video"
               type="theora-encoder"
               label="encoder-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">overlay-video:default</feed>
      </eater>
      <property name="keyframe-maxdistance">60</property>
      <property name="speed">3</property>
      <property name="bitrate">400000</property>
<clock-master>false</clock-master>
    </component>

    <component name="encoder-audio"
               type="vorbis-encoder"
               label="encoder-audio"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">producer-audio-video:audio</feed>
      </eater>
      <property name="bitrate">64000</property>
      <clock-master>false</clock-master>
    </component>

    <component name="muxer-audio-video"
               type="ogg-muxer"
               label="muxer-audio-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">encoder-audio:default</feed>
        <feed alias="default-bis">encoder-video:default</feed>
      </eater>
      <clock-master>false</clock-master>
    </component>

    <component name="http-audio-video"
               type="http-streamer"
               label="http-audio-video"
               worker="localhost"
               project="flumotion"
               version="0.10.1">
      <eater name="default">
        <feed alias="default">muxer-audio-video:default</feed>
      </eater>
      <property name="burst-on-connect">True</property>
      <property name="porter-username">DkCVXsqGlPMz</property>
<property name="mount-point">/ogg-audio-video/</property>
      <property name="port">8810</property>
      <property name="type">slave</property>
      <property name="porter-socket-path">flu-KqHpaL.socket</property>
      <property name="porter-password">GtygoZeNWmaZ</property>
      <clock-master>false</clock-master>
      <plugs>
      </plugs>
    </component>

  </flow>
  </planet>