Archive for October, 2011

Installing Webcam Studio for GNU/Linux From Source on Gentoo

WebcamStudio For GNU/Linux creates a virtual webcam that can mix several video sources together and can be used for live broadcasting over Bambuser, UStream or Stickam.

Ensure you have netbeans 6.x installed:

# emerge netbeans

Create and change to the directory /usr/src/wcs:

$ mkdir /usr/src/wcs
$ cd /usr/src/wcs

Check the source out of the CVS repository:

$ svn checkout webcamstudio-read-only

JNA should have been installed with netbeans however the symlink in the trunk/libraries/ directory must be adjusted:

$ rm /usr/src/wcs/webcamstudio-read-only/trunk/libraries/jna.jar
$ ln -s /usr/share/jna/lib/jna.jar /usr/src/wcs/webcamstudio-read-only/trunk/libraries/

Start netbeans. Under Gentoo the Subversion plugin will already be installed and activated. Click Open Project under the File menu and navigate to /usr/src/wcs/webcamstudio-read-only/. Select the trunk directory and click Open Project.

Once the project has loaded click Build Project under the Run menu. It will produce output similar to:

Deleting: /usr/src/wcs/webcamstudio-read-only/trunk/build/
Updating property file: /usr/src/wcs/webcamstudio-read-only/trunk/build/
Compiling 545 source files to /usr/src/wcs/webcamstudio-read-only/trunk/build/classes
Copying 178 files to /usr/src/wcs/webcamstudio-read-only/trunk/build/classes
Created dir: /usr/src/wcs/webcamstudio-read-only/trunk/dist
Building jar: /usr/src/wcs/webcamstudio-read-only/trunk/dist/WebcamStudio.jar
Copy libraries to /usr/src/wcs/webcamstudio-read-only/trunk/dist/lib.
To run this application from the command line without Ant, try:
java -jar "/usr/src/wcs/webcamstudio-read-only/trunk/dist/WebcamStudio.jar"
BUILD SUCCESSFUL (total time: 38 seconds)

Make sure the user you are running WebcamStudio as is part of the video group.

$ groups <username>
wheel audio cdrom dialout cdrw usb users portage scanner vboxusers roccat uucp

If the user is not a part of the video group add them:

# usermod -a -G video <username>

Test the application by running:

$ java -jar "/usr/src/wcs/webcamstudio-read-only/trunk/dist/WebcamStudio.jar"

Now build and install the kernel module:

$ cd /usr/src/wcs/webcamstudio-read-only/trunk/vloopback
$ make
# make install
# modprobe webcamstudio

To make the module auto-load on boot append it to conf.d/modules:

# echo "webcamstudio" >> /etc/conf.d/modules

Install the application to /opt/:

# mkdir /opt/webcamstudio
# cp /usr/src/wcs/webcamstudio-read-only/trunk/dist/WebcamStudio.jar /opt/webcamstudio/
# cp -r /usr/src/wcs/webcamstudio-read-only/trunk/dist/lib /opt/webcamstudio/

You may encounter this error if you do not manually build and install

OS is Linux
27-Oct-2011 3:48:06 PM java.util.prefs.FileSystemPreferences$2 run
INFO: Created user preferences directory.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'webcamstudio': cannot open shared object file: No such file or directory
        at com.sun.jna.NativeLibrary.loadLibrary(
        at com.sun.jna.NativeLibrary.getInstance(
        at com.sun.jna.Library$Handler.(
        at com.sun.jna.Native.loadLibrary(
        at com.sun.jna.Native.loadLibrary(
        at webcamstudio.exporter.vloopback.V4L2Loopback$CV4l2.(
        at webcamstudio.Main.selectOutputDevice(
        at webcamstudio.Main.cboVideoOutputsActionPerformed(
        at webcamstudio.Main.access$700(
        at webcamstudio.Main$5.actionPerformed(
        at javax.swing.JComboBox.fireActionEvent(
        at javax.swing.JComboBox.setSelectedItem(
        at webcamstudio.Main.initVideoDevices(
        at webcamstudio.Main.(
        at webcamstudio.Main.main(

Return to /usr/src/wcs/webcamstudio-read-only/trunk/vloopback/:

$ cd /usr/src/wcs/webcamstudio-read-only/trunk/vloopback
$ gcc -c -fPIC libwebcamstudio.c -o libwebcamstudio.o    
$ gcc -shared -Wl -o  libwebcamstudio.o
# cp /usr/lib64/
# ln -s /usr/lib64/ /usr/lib64/

Substitute lib/ for lib64/ on 32-bit systems. Now the application can be run from the command line:

$ java -jar "/opt/webcamstudio/WebcamStudio.jar"

Stream Webcams and Sound in Flash via RTMP with JW Player

WARNING A lot of folks have reported they can’t get the audio working. I dropped this method for and wouldn’t recomment wasting your time with jwplayer. flash-videoio has JavaScript hooks that let you configure most player/recorder settings on-the-fly which has huge potential when mixed with AJAX.

JW Player is a popular extensible flash (now also available in HTML5) video player. Until versions 4.5 and up it supported grabbing video and audio sources locally attached to the client machine and publishing them to a streaming server (like Flash Media Server, Red5 or C++ RTMP Server) via RTMP. This feature was abandoned due to inherent limitations of the built-in encoding capabilities of Flash Player vs. stand-alone encoding software like Flash Live Media Encoder. This situation doesn’t suit everyone however; in a video conferencing scenario users must be able to connect with as little hassle as possible and forcing them to download specialized software presents a significant enough accessibility barrier to warrant swallowing the quality losses associated with Flash Player encoding.

Using version 4.4.198 available at, an RTMP server and the latest version of JW Player (available here) we will make a simple broadcast and view page. Extract the contents of these archives to jwpublisher/ and jwplayer/ respectively.

Let rtmp:// be the URI to your working FMS/Red5/C++ RTMP Server application and livestream be the name of our stream. Create an index.html in jwpublisher/ to reflect:

<html lang="en">
    <script src="swfobject.js"></script>
    <script type="text/javascript">
      var flashvars =
        'streamer':                     'rtmp://',
        'file':                         'livestream',
        'type':                         'camera',
        'controlbar':                   'bottom',
        'stretching':                   'none',
        'frontcolor':                   '86C29D',  // text & icons                  (green)
        'backcolor':                    '849BC1',  // playlist background           (blue)
        'lightcolor':                   'C286BA',  // selected text/track highlight (pink)
        'screencolor':                  'FFFFFF',  // screen background             (black)
        'id':                           'playerID',
        'autostart':                    'true'

      var params =
        'allowfullscreen':              'true',
        'allowscriptaccess':            'always',
        'bgcolor':                      '#FFFFFF'

      var attributes =
        'id':                           'playerID',
        'name':                         'playerID'
      swfobject.embedSWF('player.swf', 'player', '320', '260', '9.0.124', false, flashvars, params, attributes);
    <div id="playercontainer" class="playercontainer"><a id="player" class="player" href="">Get the Adobe Flash Player to see this video.</a></div>

Now create an index.html in jwplayer/:

<script type='text/javascript' src='jwplayer.js'></script>
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>
    'flashplayer': 'player.swf',
    'type': 'rtmp',
    'streamer': 'rtmp://',
    'autostart': 'true',
    'bufferlength': '3,
    'file': 'livestream',
    'controlbar': 'none',
    'width': '320',
    'height': '260'

Load jwpublisher/ in your browser. Flash will ask for access to your webcam if it can find one. Once the video appears load jwplayer/ and allow a few seconds for buffering. If your streaming server works you should now be watching a slightly delayed version of the video being captured from your webcam.

Installing C++ RTMP Server (rtmpd, crtmpdserver) From Source on Gentoo

C++ RTMP Server is a lightweight streaming server that supports multiple streaming protocols and – most importantly – trans-coding between them. I stumbled upon it when I was looking for a solution that would trans-code an RTSP stream from an Axis webcam to a flash-playable RTMP stream. It can also be used as a drop-in replacement for some of Flash Media Server or Red5′s basic stream publishing functions but does not provide support for Flex applications or tomcat servlets, for example.

Download the latest source release at the bottom of and extract it in your /usr/src directory, or download a snapshot from SVN with a blank password:

$ svn co --username anonymous crtmpserver

Now compile the source and install the binaries:

# cd builders/cmake
# make install

Copy /usr/local/etc/crtmpserver.lua.sample to /usr/local/etc/crtmpserver.lua then edit it to reflect:

        -- this node holds all the RTMP applications
                -- this is the root directory of all applications
                -- usually this is relative to the binary execuable

Copy the SSL key and certificate:

# cp /usr/src/crtmpserver-690/builders/cmake/applications/appselector/server.* /usr/local/lib/crtmpserver/applications/appselector/

Create a media directory and link it in the flvplayback application’s folder then copy users.lua:

# mkdir /var/crtmpserver
# mkdir /var/crtmpserver/media
# ln -s /var/crtmpserver/media/ /usr/local/lib/crtmpserver/applications/flvplayback/mediaFolder
# cp /usr/src/crtmpserver-690/builders/cmake/applications/flvplayback/users.lua /usr/local/lib/crtmpserver/applications/flvplayback/

You should now be able to run the binary:

# crtmpserver /usr/local/etc/crtmpserver.lua
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:203 Initialize I/O handlers manager: epoll
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:206 Configure modules
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:84 Module /usr/local/lib/crtmpserver/applications/appselector/ loaded
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:84 Module /usr/local/lib/crtmpserver/applications/flvplayback/ loaded
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:84 Module /usr/local/lib/crtmpserver/applications/samplefactory/ loaded
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:84 Module /usr/local/lib/crtmpserver/applications/vptests/ loaded
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:84 Module /usr/local/lib/crtmpserver/applications/admin/ loaded
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:84 Module /usr/local/lib/crtmpserver/applications/proxypublish/ loaded
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:84 Module /usr/local/lib/crtmpserver/applications/stresstest/ loaded
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:84 Module /usr/local/lib/crtmpserver/applications/applestreamingclient/ loaded
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:212 Plug in the default protocol factory
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:219 Configure factories
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:97 Loaded factory from application samplefactory
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:225 Configure acceptors
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 0->1 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 1->2 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 2->3 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 3->4 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 4->5 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 5->6 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 6->7 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 7->8 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 8->9 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 9->10 IOHT_ACCEPTOR
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:231 Configure instances
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:237 Start I/O handlers manager: epoll
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:240 Configure applications
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:177 Application admin instantiated
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:177 Application applestreamingclient instantiated
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:177 Application appselector instantiated
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:177 Application flvplayback instantiated
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:177 Application proxypublish instantiated
/usr/src/crtmpserver-690/sources/thelib/src/netio/epoll/iohandlermanager.cpp:100 Handlers count changed: 10->11 IOHT_TIMER
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:177 Application samplefactory instantiated
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:177 Application stresstest instantiated
/usr/src/crtmpserver-690/sources/thelib/src/configuration/module.cpp:177 Application vptests instantiated
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:246 Install the quit signal
|                                                                     Services|
| c |      ip       | port|   protocol stack name   |     application name    |
|tcp|| 1112|           inboundJsonCli|                    admin|
|tcp|| 1935|              inboundRtmp|              appselector|
|tcp|| 8081|             inboundRtmps|              appselector|
|tcp|| 8080|             inboundRtmpt|              appselector|
|tcp|| 6666|           inboundLiveFlv|              flvplayback|
|tcp|| 9999|             inboundTcpTs|              flvplayback|
|tcp|| 6665|           inboundLiveFlv|             proxypublish|
|tcp|| 8989|         httpEchoProtocol|            samplefactory|
|tcp|| 8988|             echoProtocol|            samplefactory|
|tcp|| 1111|    inboundHttpXmlVariant|                  vptests|
/usr/src/crtmpserver-690/sources/crtmpserver/src/crtmpserver.cpp:258 GO! GO! GO! (4108)

If it simply returns to the command line ensure you have not configured crtmpserver.lua to daemonize then run it with the following flags:

# crtmpserver --use-implicit-console-appender /usr/local/etc/crtmpserver.lua

Hit Control+C to terminate the process. Now we will create an unprivileged user account for the daemon to run under:

# useradd -d /usr/local -s /sbin/nologin -r rtmpd

Change the permissions of /var/crtmpserver:

# chown rtmpd: /var/crtmpserver -R

Edit /usr/local/etc/crtmpserver.lua to reflect:

        -- if true, the server will run as a daemon.
        -- NOTE: all console appenders will be ignored if this is a daemon

Create a directory for the logs:

# mkdir /var/log/rtmpd
# chown rtmpd: /var/log/rtmpd

Edit /usr/local/etc/crtmpserver.lua to reflect:

                        name="file appender",
                        -- the file where the log messages are going to land

Now create the init script /etc/init.d/rtmpd:

# Copyright (c) 2011
# All rights released

description="Runs C++ RTMP Server on Gentoo"

        need net

        ebegin "Starting C++ RTMP Server"
        /usr/local/sbin/crtmpserver --daemon --gid=`id -g rtmpd` --uid=`id -u rtmpd` /usr/local/etc/crtmpserver.lua
        eend ${?}

        ebegin "Stopping C++ RTMP Server"
        killall crtmpserver
        eend ${?}

Make the script executable and add it to the default runlevel:

# chmod +x /etc/init.d/rtmpd
# rc-update add rtmpd default

You can now start the daemon by running:

# /etc/init.d/rtmpd start
Return top
Online Marketing Toplist
Technology Blogs - Blog Rankings

Internet Blogs - BlogCatalog Blog Directory

Bad Karma Networks

Please Donate!

Made in Canada  •  There's a fox in the Gibson!  •  2010-12