Archive for the ‘Streaming’ Category

A Tidy Little OpenRC (Gentoo) init Script for TeamSpeak3

I recently set up a TeamSpeak3 server for the YI Minecraft users. Due to a crazy high-load-but-low-CPU-utlization problem I have decided to ditch ts3 and try Mumble.

Before I remove it, here’s the qick and clean init script I made (assumes ts3 was installed to /opt/ts3/ and a non-privileged user called ts3 has been made):

#!/sbin/runscript
# Copyright (c) 2013 http://foxpa.ws
# All rights released

description="Runs TeamSpeak3 on Gentoo"

depend()
{
        need net
}

start()
{
        ebegin "Starting TeamSpeak3"
        start-stop-daemon --start --quiet --user=ts3 --background --chdir=/opt/ts3/ --exec "/opt/ts3/ts3server_startscript.sh" -- start
        eend ${?}
}

stop()
{
        ebegin "Stopping TeamSpeak3"
        cd /opt/ts3/
        start-stop-daemon --stop --quiet --exec "/opt/ts3/ts3server_startscript.sh" -- stop
        /opt/ts3/ts3server_startscript.sh stop &> /dev/null
        eend ${?}
}

Rotate Red5 Logs Without logrotate

If you are capturing log output from Red5 via stdout and stdin as I had configured in this init script you will not be able to use logrotate and reliably preserve data as the active files are not replaced until the daemon has been restarted, losing anything that happened between then and the last rotation. Logging this way also suffers from a lack of timestamping. Fortunately, red5 has the capacity to rotate log files itself. Disable logging from stdout/stdin and replace the following portion of /opt/red5/conf/logback.xml:

        <appender name="FILE" class="ch.qos.logback.core.FileAppender">
                <File>log/red5.log</File>
                <Append>false</Append>
                <encoder>
                        <pattern>%d{ISO8601} [%thread] %-5level %logger{35} - %msg%n</pattern>
                </encoder>
        </appender>
        <appender name="ERRORFILE" class="ch.qos.logback.core.FileAppender">
                <File>log/error.log</File>
                <Append>false</Append>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
                <level>WARN</level>
        </filter>
                <encoder>
                        <pattern>%d{ISO8601} [%thread] %-5level %logger{35} - %msg%n</pattern>
                </encoder>
        </appender>

with:

        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <File>/var/log/red5/red5.log</File>
          
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
              <FileNamePattern>log/red5.%d{yyyy-MM-dd}.log</FileNamePattern>
              <!-- keep 30 days worth of history -->
              <MaxHistory>30</MaxHistory>
            </rollingPolicy>

            <layout class="ch.qos.logback.classic.PatternLayout">
              <Pattern>%d{ISO8601} [%thread] %-5level %logger{35} - %msg%n</Pattern>
            </layout>
          </appender>
          <appender name="ERRORFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <File>/var/log/red5/error.log</File>

            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
              <FileNamePattern>log/error.%d{yyyy-MM-dd}.log</FileNamePattern>
              <!-- keep 30 days worth of history -->
              <MaxHistory>30</MaxHistory>
            </rollingPolicy>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
                <level>WARN</level>
        </filter>
            <layout class="ch.qos.logback.classic.PatternLayout">
              <Pattern>%d{ISO8601} [%thread] %-5level %logger{35} - %msg%n</Pattern>
            </layout>
          </appender>

Thank you to the bigbluebutton staff.

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 http://webcamstudio.googlecode.com/svn/trunk/ 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:

init:
Deleting: /usr/src/wcs/webcamstudio-read-only/trunk/build/built-jar.properties
deps-jar:
Updating property file: /usr/src/wcs/webcamstudio-read-only/trunk/build/built-jar.properties
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
compile:
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"
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 libwebcamstudio.so:

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': libwebcamstudio.so: cannot open shared object file: No such file or directory
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:164)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:237)
        at com.sun.jna.Library$Handler.(Library.java:140)
        at com.sun.jna.Native.loadLibrary(Native.java:374)
        at com.sun.jna.Native.loadLibrary(Native.java:359)
        at webcamstudio.exporter.vloopback.V4L2Loopback$CV4l2.(V4L2Loopback.java:75)
        at webcamstudio.exporter.vloopback.V4L2Loopback.open(V4L2Loopback.java:31)
        at webcamstudio.Main.selectOutputDevice(Main.java:221)
        at webcamstudio.Main.cboVideoOutputsActionPerformed(Main.java:1824)
        at webcamstudio.Main.access$700(Main.java:48)
        at webcamstudio.Main$5.actionPerformed(Main.java:794)
        at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1240)
        at javax.swing.JComboBox.setSelectedItem(JComboBox.java:567)
        at webcamstudio.Main.initVideoDevices(Main.java:192)
        at webcamstudio.Main.(Main.java:92)
        at webcamstudio.Main.main(Main.java:1901)

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.so.1.0.1  libwebcamstudio.o
# cp libwebcamstudio.so.1.0.1 /usr/lib64/
# ln -s /usr/lib64/libwebcamstudio.so.1.0.1 /usr/lib64/libwebcamstudio.so

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

$ java -jar "/opt/webcamstudio/WebcamStudio.jar"
Return top
foxpa.ws
Online Marketing Toplist
Internet
Technology Blogs - Blog Rankings

Internet Blogs - BlogCatalog Blog Directory

Technology blogs
Bad Karma Networks

Please Donate!


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