Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sunday, March 24, 2013

Play Freespace 2 natively on Fedora

Was sitting here this snowy Sunday afternoon craving for a bit of good ole space sim action. After a brief flurry of searching the web for something free, recent enough to look cool and immersive and would run under Linux or Wine I was pretty disappointed to find.. not much. (Yes there's Vendetta Online but that's only free for so long). Unfortunately the epic space sim genre is not the vibrant part of the game industry it once was.

I decided to embrace the old school and dig out my copy of Freespace 2 which is meant to run perfectly under Wine according to the Wine AppDB and I remember it very fondly, well after a straight forward Wine install it didn't work on my Fedora 18 installation currently running Wine 1.5.24.
Rather than shuffling towards the drudgery of trying to get FS2 working under Wine or the even worse experience of having to exit what I had running in the background, rebooting into Windows 7 (ugh) and trying to get it working there, I noticed during my search-fest that there's a FreeSpace Source Code Project (FCSP) that is actively developing the open source, multi-platform version of the Freespace 2 binaries called FS2Open! Sometimes life just throws you a bone.

Now it should really end there, I installed the thing, used the old disks to grab the content, had a wail of a time, went and did something else. Erm... no.
As with some open-saucy type projects, the only set of end to end instructions that seems to exist for Linux is a mighty wall of links & text. Their guide is comprehensive but many links and pages are involved and so it becomes a bit of a slog.


Therefore if you're running Fedora and want to begin playing the latest open-source, upgraded FreeSpace 2 the straight forward way then I've documented my simplified, start to finish guide for Fedora 18 for you.

What's required?

To get FS2Open going you need;

The FS2Open engine

This is the open-source Freespace 2 core engine.
Project contributor 'niffiwan' has published some pre-compiled Linux binaries for a range of distros, these are available for download HERE.
You can go ahead and download the appropriate binary for you distro but if you want the latest version of FS2Open you're best just compiling from source as covered in this walkthrough.

A launcher

Launcher software is used to configure and run FS2Open.
The FCSP project's launcher download page gives the option of 3 launcher projects. The official launcher software is called wxLauncher and appears to be the most complete.
For Linux, compilation of wxLauncher from the source code is required. The source comes with build instructions but the Linux section only covers Ubuntu. This gives you little idea of what packages you need to install on Fedora to compile the sofware.

The original game media

Your 3 original Freespace 2 CDs or ISO images.

The FS2Open media enhancements

A lot of work has been done to enhance the original game's content to bring FS2 more up to date. The extra content comes in the form of game mods packaged up in additional VP files
The official download page for the latest MediaVPs is a forum post HERE.
Rather than manually download each file in the browser we'll make things a bit more straight forward later using the command-line.

Let's go..

Firstly open a new terminal.

Install the Fedora packages you'll need

 sudo yum install SDL SDL-devel python python-markdown wxGTK wxGTK-devel openal-soft openal-soft-devel cmake gcc gcc-c++ unshield subversion libvorbis-devel automake autoconf libtheora-devel readline-devel lua-devel libpng-devel libjpeg-devel  

Create game directories under your home directory

 mkdir -p ~/Games/freespace2/temp/mvp  
 mkdir ~/Games/freespace2/temp/src  
 mkdir ~/Games/freespace2/mediavps_3612  

Get the FS2Open source code

 cd ~/Games/freespace2/temp/src  
 svn checkout svn://svn.icculus.org/fs2open/trunk/fs2_open  

Compile & install the FS2Open binaries

Note: we're not doing any optimization here, just the quick and easy get-it-going approach. The full mega-guide is HERE.
 cd fs2_open  
 ./autogen.sh  
 make  
Assuming the compilation went OK copy the binary to your freespace2 directory;
 cp code/fs2_open_* ~/Games/freespace2  


Compile & install wxLauncher

Download

Download the latest source code tarball from the wxLauncher downloads page HERE. Save the file to your Downloads directory.

Unpack

 cd ~/Downloads  
 mkdir -p wxlauncher/build  
 tar -C wxlauncher -xzf wxLauncher-*.tar.gz  

Build

 cd wxlauncher/build  
 cmake -DUSE_OPENAL=1 -DCMAKE_INSTALL_PREFIX=/usr/local ../  

You should see messages confirming a successful build which looks like this;
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yourname/Downloads/wxLauncher-0.9.1/build

Compile

 make  

Install

 sudo make install  


Get the game content.

The next step is to copy the original game content from the FreeSpace 2 CDs (or ISO images if you have them) to the freespace2 directory you created earlier.

Mount the game media

Clearly there are many ways to mount disk and iso images but here's the easy to describe, simple way of doing this. It assumes as you're running Fedora then you'll be running a Gnome 3 desktop, it is the best DE after all.

If you're using CDs, insert the first disk and open it in Gnome 3's file manager 'Files' when prompted.
Alternatively if you have ISO images of the CDs it is just as easy to mount them in Gnome 3, just double-click the ISO file in 'Files' and it will be automatically mounted and appear as a device. You could mount all 3 ISOs at once this way if you wish.

Whether you're using a CD or an ISO file, just hover your mouse cursor over the device to see it's path, this example shows the path of a mounted ISO file;

These paths will be the source of your data extractions.

Extract the data to your game directory

The tool 'unshield' you installed earlier is a tool for extracting files from Microsoft CAB files with InstallShield headers.
With the first disk/ISO mounted unpack data1.cab and put all '.vp' files in your game directory as follows (substituting /path/to/your/cdoriso for the actual mounted disk/ISO path);
 cd /path/to/your/cdoriso  
 unshield -j -d ~/Games/freespace2/temp x data1.cab  
 mv ~/Games/freespace2/temp/*vp ~/Games/freespace2  
For disk/ISO 2 the required vp files are just in the root of the disk, so mount disk/ISO 2 and copy them directly;
 cd /path/to/your/cdoriso  
 cp *vp ~/Games/freespace2  
... and lastly mount CD/ISO 3, like you did with disk 2 copy the vp files directly from it's path to the game directory;
 cd /path/to/your/cdoriso  
 cp *vp ~/Games/freespace2  


Implementing the game enhancements (MediaVPs)

Download the files

The available MediaVPs are packaged up in a number of separate ZIP files.
Download them to your ~/Games/freespace2/temp/mvp directory and unpack them. All together this is a 1.2GB download.
There are cleverer ways to process this list of downloads but the following list of commands requires less explanation here. You can just copy the list of commands and paste into your terminal to perform them in a batch.
 cd ~/Games/freespace2/temp/mvp  
 wget http://mvp.fsmods.net/3612/MediaVPs_3612.zip  
 wget http://mvp.fsmods.net/3612/MV_Root_3612.zip  
 wget http://mvp.fsmods.net/3612/MV_Root_Update.zip  
 wget http://mvp.fsmods.net/3612/MV_Music_3612.zip  
 wget http://mvp.fsmods.net/3612/MV_Assets_3612.zip  
 wget http://mvp.fsmods.net/3612/MV_Assets_Update.zip  
 wget http://mvp.fsmods.net/3612/MV_Effects_3612.zip  
 wget http://mvp.fsmods.net/3612/MV_Effects_Update.zip  
 wget http://mvp.fsmods.net/3612/MV_Advanced_3612.zip  
 wget http://mvp.fsmods.net/3612/MV_AnimGlows_3612.zip  
 wget http://mvp.fsmods.net/3612/MV_RadarIcons_3612.zip  
 wget http://mvp.fsmods.net/3612/MV_CB_ANI_1.zip  
 wget http://mvp.fsmods.net/3612/MV_CB_ANI_2.zip  
A few of these file are optional but we're going full fat here.

Unzip the files

 unzip '*.zip'  

Place the VP files in their own subdirectory which you created earlier.

 mv *vp ~/Games/freespace2/mediavps_3612/  
 mv mediavps_3612/* ~/Games/freespace2/mediavps_3612  
 mv MediaVPS_3612/* ~/Games/freespace2/mediavps_3612  


Running and setting up FS2Open

Now, still in the terminal run wxlauncher;
 wxlauncher  
You'll be presented with something like this;

Nice!

Mods

Select the 'Mods' tab.
Select the MediaVps mod and select the [Activate] button.

Basic Settings

Select the 'Basic Settings' tab.
Select the browse button to set the Game Root Folder to /home/yourname/Games/freespace2.
Select the Refresh button and pick the available FS2 Open executable option.
Once you've picked the executable the video and audio settings should be picked up automatically.
If you have your joystick or gamepad plugged in, select it in the Joystick drop-down.

Advanced Settings

Select the 'Advanced Settings' tab, here's where you can experiment with the many settings available with FS2 Open.
As a starter set the Lighting Presets to 'Baseline Recommended' and the Flag Sets to 'High Memory usage features on'.

Then select/enable the following options;
Graphics section
  • Apply Lighting to Missiles
  • Enable 3D shockwaves
  • Enable Post-processing
  • Enable soft particles
  • Enable FXAA anti-aliasing
HUD section
  • Enable 3D radar
Gameplay section
  • Enable 3D warp
  • Enable flash upon warp
  • Enable 3D models for ship selection
  • Enable 3D models for weapons selection
Audio section
  • Preload mission game sounds






Finally...

There are many user-made mods available that continue the Freespace saga as well as introduce additional stories & universes including Babylon 5 and BSG. Check out the highlights panel on wxlauncher's Welcome tab, the Freespace Wiki and the project's list of user-made campaigns and total conversions list for more details on what's available.

Before you do, don't forget your joystick, hit the Play button and get stuck in...


This should at least see me through until the release of Star Citizen.

Saturday, March 16, 2013

Converting Sony's PlayTV M2TS recordings to Xvid

Recently, I had to replace my PS3 and one of my PS3's main roles for a long time has been as a DVR. The PS3 together with the PlayTV peripheral and the official BD remote does an excellent job of this providing the ability to watch, pause, rewind & record over-the-air TV with a nice HD interface, it even improves image quality due to the PS3's built-in upscaling.

The slow death of my old PS3 together with the timely introduction of Live TV support on XBMC 12 prompted me to take the PlayTV peripheral and stick it in my Linux-based media centre PC running XMBC and setup TVheadend to pull the signal from the PlayTV's tuners. The result of this is the XBMC box has now become our DVR and TV viewing platform as well as all the other media content it serves up, however there was still a lot of decent recordings left on the PS3 that I wanted to keep and having exported them from PlayTV and transferred them from the PS3, I felt that the M2TS files are a little too large to warrant leaving them in that format using all that disk space.

So for any out there who are left with a bunch of these huge M2TS files and want to make them smaller or simply transcode them to a format that is supported by more devices then this post is for you.
Firstly you will need to have ffmpeg installed on your PC together with appropriate Xvid & LAME MP3 libraries.

ffmpeg

As always ffmpeg is my goto toolkit for video convertion and a single MT2S file can be converted to a smaller file without much loss of quality with a one-liner.

Example

 ffmpeg -y -i "awesomeshow.m2ts" \  
 -vcodec libxvid \  
 -b 1200k \  
 -acodec libmp3lame \  
 -ac 2 -ar 44100 -ab 128k \  
 -s 576x460 -threads 2 -deinterlace "awesomeshow.avi"  

In this example the filename of the M2TS file that is being converted (the input file) is 'awesomeshow.m2ts' and I've given the output file the name 'awesomeshow.avi'.

Option tips

-vcodec = video codec

Here I've used the Xvid MPEG4 library to achieve a higher compression ratio than the source file's MPEG2, reducing the size of the output file, also many devices (including the PS3) support Xvid playback.

-b = video bitrate

I've specified a video stream bitrate of 1200 Kbits per second, after lots of tries this seems to be a nice compromise between quality & output file size.

-s = frame size

My PAL TV signal is processed at 576i, the resulting resolution of the original recording is 720x576. In the above example I've used the -s option to reduce the output file resolution to 576x460. This helps to further reduce the output file size.

-acodec = audio codec

MP3 is the common counterpart to the Xvid video codec, it compresses audio well and playback is supported everywhere.
I specified the output audio stream to be a 2 channel stream with a sample rate of 44KHz and a  bitrate of 128Kbps with the -ac, -ar & -ab options.

-deinterlace

As the video source is an interlaced TV signal it will look terrible when played back on a progressive display unless deinterlacing is applied on the transcode or on the player playing the convertion. Therefore I've specified to deinterlace during the conversion with the delinterlace option, this also introduces additional processing on the transcode so ffmpeg will take noticeably longer to complete.

-threads = number of conversion processes

Set this figure to match the number of processor cores on your computer, the more processors you can get to work on the conversion job the quicker it will finish.

Finally, a script...

I had a lot of recordings to convert so naturally, to convert all of them all in one go on my media centre PC which runs a popular Linux distro I wrote a little shell script.
If you want to use this script just save it to your local filesystem (your Downloads directory presumably), pop it in your /usr/bin directory & make it executable;
 cd ~/Downloads  
 chmod +x playtv2xvid  
 sudo mv playtv2xvid /usr/bin  

Then in a terminal 'cd' to the location of your *.m2ts files and run...
 playtv2xvid  

It will show you what M2TS files have been found in the current location, press enter to begin the conversions and all will be logged in a log file for you to review later.

Download the playtv2xvid script here.


Tuesday, November 03, 2009

Auto starting and shutdown of Virtualbox VMs

Just a quickie to document a nice simple way of automatically starting and stopping Virtualbox virtual machines when you login and shutdown your Linux box.

Firstly, what is the name of virtual machine that you want to do this with?
You can list the names of your VMs in a terminal as below
$ VBoxManage list -l vms|grep "Guest OS" -B1
...and choose the name of your virtual machine.

For this example my VM is called 'Windows XP' and my host is running Ubuntu 9.10, other distros running Gnome shouldn't be much different.

To autostart your VM upon login to Gnome...

Launch System > Preference > Startup Applications, select the Add button.
Then enter a name for the program in the Name: field and in the Command field enter;
VBoxManage startvm "Your VM Name"
Replacing the 'Your VM Name' with the name of your VM, if there are spaces in the name your will need the quotes.


Lastly to have your system cleanly stop your running VMs for you when you shut down your Linux box you can edit the vboxdrv init script. To do this you will need root privileges.

You have the choice of 3 methods of stopping the VM, a poweroff, an acpi button emulation or my preference, a savestate shutdown which will stop the VM and preserve it's runtime state, it will then resume the next time it is started.

Edit the init script with the nano text editor, if you have sudo setup or if you're using an Ubuntu/Debian style Linux distribution...
$ sudo nano /etc/init.d/vboxdrv
... and enter your password.

If you don't use sudo, you can su to root before running nano or you can use su as below..
$ su root -c nano /etc/init.d/vboxdrv
... and enter the root account's password.

In nano hit [Ctrl]+[W] to search and enter SHUTDOWN in caps. This will take you line 235.

A few lines down uncomment the appropriate "SHUTDOWN=" line of choice, for example to choose a savestate shutdown edit the line;
# SHUTDOWN=savestate
to read,
SHUTDOWN=savestate
Then hit [Ctrl]+[O] to save the change, then [Ctrl]+[X] to exit nano.


This will ensure that your system when shut down will cleanly stop your running VMs without you having to do so manually.

Wednesday, February 11, 2009

Transcoding to your Playstation 3 with Mediatomb

The Playstation 3 is a brilliant bit of kit, not only is it a cutting edge games console but it is also a excellent media centre.
Not only does it play Blu-Rays, DVDs, CDs, MP3s and DivX/Xvid as standard through proper HDMI & optical audio connections but the rendering quality of compressed video is noticeably better than on a computer or a cheapo DivX/DVD player with richer colours and less artifacts.


The feature that is used a lot at my place is the PS3's ability to stream from a DLNA media server, this does away with the need to use physical media such as optical discs or hard disks if the audio/video files already resides on my server.
Using a streaming server can actually enhance the functionality of your PS3, something I was keen to experiment with when I first bought my PS3 about a year ago.

My DLNA server of choice is Mediatomb, this runs on my desktop machine which is also my home server, this machine currently runs Ubuntu 8.10 64bit.
Mediatomb requires some basic configuration to get the PS3 streaming from it, this entails editing Mediatomb's config file to enable PS3 support. This enables your PS3 to stream MP3s & DivX/Xvid media from your server over your network.

But what if your media is not supported by the PS3? What about ogg, flv and mkv files for instance?

Transcoding 

Mediatomb can be configured to convert certain media types in realtime and stream it to the PS3 in the format it supports, this is called transcoding.
There are many forum discussions about how to get Mediatomb to transcode various formats to PS3s however I have never been able to find a proper guide to setting up Mediatomb to transcode, just a hodge podge of partial solutions.

I managed to use some of these partial solutions as building blocks to setup my Mediatomb properly so that I can play MP3 and OGG audio and DivX/Xvid, FLV & Matroska videos upto resolutions of 1080p on my PS3 across my network. However this took a lot of experimentation and I never managed to document it so here's my chance to remedy that and knock up a guide for setting up Mediatomb on Ubuntu to transcode media to your PS3.

The Guide

Install the required software
Firstly install Mediatomb and the software required for the transcoding process along with any dependencies.

 sudo apt-get install mediatomb vlc ffmpeg ffmpegthumbnailer transcode  

Configure Mediatomb
Backup the original Mediatomb config file...

 cd /etc/mediatomb  
 sudo cp -p config.xml config.orig  
You'll need to create 3 shell scripts in /etc/mediatomb...

Script #1

 sudo nano mediatomb-transcode-audio  
Copy in the following text, save the file and exit nano ([Ctrl]+[x] then [Y])...

   #!/bin/bash  
   INPUT="$1"  
   OUTPUT="$2"  
   AUDIO_CODEC="pcm_s16le"  
   AUDIO_BITRATE="192k"  
   AUDIO_SAMPLERATE="44100"  
   AUDIO_CHANNELS="2"  
   FORMAT="s16le"  
   exec /usr/local/bin/ffmpeg -i "${INPUT}" -acodec ${AUDIO_CODEC} -ab ${AUDIO_BITRATE} -me zero -ar ${AUDIO_SAMPLERATE} -ac ${AUDIO_CHANNELS} -f ${FORMAT} - > "${OUTPUT}" 2>/dev/null  
Script #2


 sudo nano mediatomb-transcode-video  

Copy in the following text, save the file and exit nano ([Ctrl]+[x] then [Y])...



   #!/bin/bash  
   VLC_PATH="/usr/bin/vlc"  
   INPUT="$1"  
   OUTPUT="$2"  
   VIDEO_CODEC="mp2v"  
   VIDEO_BITRATE="4096"  
   VIDEO_FRAMERATE="25"  
   AUDIO_CODEC="mpga"  
   AUDIO_BITRATE="192"  
   AUDIO_SAMPLERATE="44100"  
   AUDIO_CHANNELS="2"  
   FORMAT="ps"  
   SUBTITLE_LANGUAGE="eng"  
   exec "${VLC_PATH}" "${INPUT}" -I dummy --sout "#transcode{vcodec=${VIDEO_CODEC},\ vb=${VIDEO_BITRATE},fps=${VIDEO_FRAMERATE},acodec=${AUDIO_CODEC},ab=${AUDIO_BITRATE},\ samplerate=${AUDIO_SAMPLERATE},channels=${AUDIO_CHANNELS},soverlay,audio-sync}:\ standard{mux=${FORMAT},access=file,dst=${OUTPUT}}" --sub-language=${SUBTITLE_LANGUAGE} \  
   vlc:quit  

Script #3
 sudo nano mediatomb-transcode-video-ffmpeg  

Copy in the following text, save the file and exit nano ([Ctrl]+[x] then [Y])...



   #!/bin/bash  
   INPUT=$1  
   OUTPUT=$2  
   VIDEO_CODEC="mpeg2video"  
   VIDEO_BITRATE="24576k"  
   AUDIO_CODEC="mp2"  
   AUDIO_BITRATE="192k"  
   AUDIO_SAMPLERATE="48000"  
   AUDIO_CHANNELS="2"  
   FORMAT="dvd"  
   exec /usr/bin/ffmpeg -threads 4 -i "${INPUT}" -vcodec ${VIDEO_CODEC} -b ${VIDEO_BITRATE} \  
   -acodec ${AUDIO_CODEC} -ab ${AUDIO_BITRATE} -ar ${AUDIO_SAMPLERATE} -ac ${AUDIO_CHANNELS} \  
   -f ${FORMAT} -copyts - > "${OUTPUT}" 2>/dev/null  

Remove the original config.xml file...

 sudo rm -f config.xml  

Create a new config.xml in nano...

 sudo nano config.xml  

... copy in the following text...



 <?xml version="1.0" encoding="UTF-8"?>  
 <config version="1" xmlns="http://mediatomb.cc/config/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/1 http://mediatomb.cc/config/1.xsd">  
 <server>  
 <ui enabled="yes">  
 <accounts enabled="no" session-timeout="30">  
 <account user="mediatomb" password="mediatomb"/>  
 </accounts>  
 </ui>  
 <name>MediaTomb</name>  
 <udn>uuid:aa8ba7dd-5533-4ec1-b32c-b3b807677f9a</udn>  
 <home>/var/lib/mediatomb</home>  
 <webroot>/usr/share/mediatomb/web</webroot>  
 <storage>  
 <sqlite3 enabled="yes">  
 <database-file>sqlite3.db</database-file>  
 </sqlite3>  
 <mysql enabled="no">  
 <host>localhost</host>  
 <username>mediatomb</username>  
 <database>mediatomb</database>  
 </mysql>  
 </storage>  
 <protocolInfo extend="yes"/><!-- For PS3 support change to "yes" -->  
 <!--  
 Uncomment the lines below to get rid of jerky avi playback on the  
 DSM320 or to enable subtitles support on the DSM units  
 -->  
 <!--  
 <custom-http-headers>  
 <add header="X-User-Agent: redsonic"/>  
 </custom-http-headers>  
 <manufacturerURL>redsonic.com</manufacturerURL>  
 <modelNumber>105</modelNumber>  
 -->  
 <!-- Uncomment the line below if you have a Telegent TG100 -->  
 <!--  
 <upnp-string-limit>101</upnp-string-limit>  
 -->  
 </server>  
 <import hidden-files="no">  
 <scripting script-charset="UTF-8">  
 <common-script>/usr/share/mediatomb/js/common.js</common-script>  
 <playlist-script>/usr/share/mediatomb/js/playlists.js</playlist-script>  
 <virtual-layout type="builtin">  
 <import-script>/usr/share/mediatomb/js/import.js</import-script>  
 </virtual-layout>  
 </scripting>  
 <mappings>  
 <extension-mimetype ignore-unknown="yes">  
 <map from="mp3" to="audio/mpeg"/>  
 <map from="ogg" to="application/ogg"/>  
 <map from="ogv" to="video/oggtheora"/>  
 <map from="asf" to="video/x-ms-asf"/>  
 <map from="asx" to="video/x-ms-asf"/>  
 <map from="wma" to="audio/x-ms-wma"/>  
 <map from="wax" to="audio/x-ms-wax"/>  
 <map from="wmv" to="video/x-ms-wmv"/>  
 <map from="wvx" to="video/x-ms-wvx"/>  
 <map from="wm" to="video/x-ms-wm"/>  
 <map from="wmx" to="video/x-ms-wmx"/>  
 <map from="m3u" to="audio/x-mpegurl"/>  
 <map from="pls" to="audio/x-scpls"/>  
 <map from="flv" to="video/x-flv"/>  
 <map from="avi" to="video/x-divx"/>  
 <map from="divx" to="video/x-divx"/>  
 <map from="mkv" to="video/x-matroska"/>  
 <map from="mov" to="video/quicktime"/>  
 <map from="qt" to="video/quicktime"/>  
 <map from="mpg" to="video/mpeg"/>  
 <map from="mpeg" to="video/mpeg"/>  
 </extension-mimetype>  
 <mimetype-upnpclass>  
 <map from="audio/*" to="object.item.audioItem.musicTrack"/>  
 <map from="video/*" to="object.item.videoItem"/>  
 <map from="image/*" to="object.item.imageItem"/>  
 </mimetype-upnpclass>  
 <mimetype-contenttype>  
 <treat mimetype="audio/mpeg" as="mp3"/>  
 <treat mimetype="application/ogg" as="ogg"/>  
 <treat mimetype="audio/x-flac" as="flac"/>  
 <treat mimetype="image/jpeg" as="jpg"/>  
 <treat mimetype="audio/x-mpegurl" as="playlist"/>  
 <treat mimetype="audio/x-scpls" as="playlist"/>  
 <treat mimetype="audio/x-wav" as="pcm"/>  
 <treat mimetype="audio/L16" as="pcm"/>  
 <treat mimetype="video/x-msvideo" as="avi"/>  
 <treat mimetype="video/mp4" as="mp4"/>  
 <treat mimetype="audio/mp4" as="mp4"/>  
 <treat mimetype="video/x-divx" as="avi"/>  
 </mimetype-contenttype>  
 </mappings>  
 </import>  
 <transcoding enabled="yes">  
 <mimetype-profile-mappings>  
 <transcode mimetype="video/x-flv" using="vlcmpeg"/>  
 <transcode mimetype="application/ogg" using="vlcmpeg"/>  
 <transcode mimetype="application/ogg" using="oggflac2raw"/>  
 <transcode mimetype="audio/x-flac" using="audio-common"/>  
 <transcode mimetype="video/x-divx" using="video-thumbnail"/>  
 <transcode mimetype="video/x-matroska" using="video-common"/>  
 <transcode mimetype="video/quicktime" using="video-common"/>  
 <transcode mimetype="video/oggtheora" using="video-common"/>  
 </mimetype-profile-mappings>  
 <profiles>  
 <profile name="oggflac2raw" enabled="yes" type="external">  
 <mimetype>audio/L16</mimetype>  
 <accept-url>no</accept-url>  
 <first-resource>yes</first-resource>  
 <accept-ogg-theora>no</accept-ogg-theora>  
 <agent command="ogg123" arguments="-d raw -f %out %in"/>  
 <buffer size="1048576" chunk-size="131072" fill-size="262144"/>  
 </profile>  
 <profile name="vlcmpeg" enabled="yes" type="external">  
 <mimetype>video/mpeg</mimetype>  
 <accept-url>yes</accept-url>  
 <first-resource>yes</first-resource>  
 <accept-ogg-theora>yes</accept-ogg-theora>  
 <agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit"/>  
 <buffer size="14400000" chunk-size="512000" fill-size="120000"/>  
 </profile>  
 <profile name="video-thumbnail" enabled="yes" type="external">  
 <mimetype>image/jpeg</mimetype>  
 <accept-url>yes</accept-url>  
 <thumbnail>yes</thumbnail>  
 <resolution>128x128</resolution>  
 <agent command="ffmpegthumbnailer" arguments="-i %in -o %out -s 128"/>  
 <buffer size="524288" chunk-size="512" fill-size="1024"/>  
 </profile>  
 <profile name="audio-common" enabled="yes" type="external">  
 <mimetype>audio/x-wav</mimetype>  
 <accept-url>yes</accept-url>  
 <first-resource>yes</first-resource>  
 <accept-ogg-theora>no</accept-ogg-theora>  
 <agent command="/etc/mediatomb/mediatomb-transcode-audio" arguments="%in %out"/>  
 <buffer size="1048576" chunk-size="131072" fill-size="262144"/>  
 </profile>  
 <profile name="video-common" enabled="yes" type="external">  
 <mimetype>video/mpeg</mimetype>  
 <accept-url>yes</accept-url>  
 <first-resource>yes</first-resource>  
 <accept-ogg-theora>yes</accept-ogg-theora>  
 <agent command="/etc/mediatomb/mediatomb-transcode-video-ffmpeg" arguments="%in %out"/>  
 <buffer size="52428800" chunk-size="524288" fill-size="1048576"/>  
 <!-- <buffer size="26214400" chunk-size="524288" fill-size="1048576"/> -->  
 <!-- <buffer size="14400000" chunk-size="512000" fill-size="120000"/> -->  
 </profile>  
 </profiles>  
 </transcoding>  
 </config>  
...then save the file ([Ctrl]+[x] then [Y]).

Make the 3 scripts you created executeable.
 sudo chmod +x media*  

Lastly restart Mediatomb.

 sudo /etc/init.d/mediatomb restart  

Create some symlinks in your root directory to your media directories.
For example linking my Music, Photos, Videos and Downloads directories within my home directory would go like this...

 sudo ln -s ~/Videos /Videos  
 sudo ln -s ~/Music /Music  
 sudo ln -s ~/Photos /Photo  
 sudo ln -s ~/Download /Downloads  

Share some media

To share some media from Mediatomb, open up a web browser and goto... http://localhost:49152 You'll get the front page as below, select the [Filesystem] link...



Now select one of the symlinks you just created in the filesystem tree on the left /Videos for example, then select the "add autoscan" button.

The 'Add Autoscan' button...





Then select the options...
Scan Mode: Timed
Scan Level: Full
Recursive: ticked

Enter scan interval in seconds.



If the contents of the directory changes often and does not contain a great deal of files you may want to set this to something low like 300 seconds (5 minutes), however if the directory contains a huge amount of files (like my Music directory) you may want Mediatomb to only scan for changes every 21600 or 43200 seconds (6 or 12 hours) you could also reduce the scan level to 'Basic' to speed up scanning a large amount of files.
Once done select the [Set] button, Mediatomb will start to scan the chosen directory.

Select the next symlink in the root directory as required and repeat the process.

Playing your shared media on the PS3
Now on your PS3 run the 'Search for Media Servers' option, once found Mediatomb will show in the media menus and you can browse your shared content, videos and images will also have thumbnail previews...


All works well however you cannot scan back & forward or pause transcoded media on the PS3 as it is effectively a 'live' stream.
The only way to pause is to hit the PS button to back out to the menu, pushing the PS button again will resume playback.

Hardware Limitations
The process of streaming transcoded content to your PS3 can be a good test of your server & network hardware.
My server has a 2.1GHz Intel Core 2 Duo with 6GB of 1066MHz DDR2 RAM along with 3TB of RAIDed SATA storage.
My network hangs off a very reliable but getting old Netgear Wi-Fi G / 100Mbps Ethernet router.

My first tip will be do not bother with wireless networking.
You need some reliable bandwidth between the server and the PS3 so both need to be on a wired network.

Additionally wireless networking is slow even if your wireless network is 108Mbps, that is 108Mbps shared between all connected wireless devices.

Once I started to experiment with streaming/transcoding 8GB 1080p Matroska (.mkv) files I found that there can be limitations even on the 100Mbps wired network
during fast-action high-detail scenes (smashing glass, moving water, flocks of birds).
Pressing [Select] on the PS3 controller when playing these videos shows the video bandwidth on the top right of the screen.



Additionally when I started to test 720p - 1080p Matroska videos the 2.1 GHz Core 2 Duo was not fast enough to transcode in realtime during the fast-action high-detail scenes resulting in choppy video output on the PS3.


After much testing and changing of video bandwidths to find the sweetspot between network bandwidth and CPU load I settled on the bandwidths found in the above 'mediatomb-transcode-video' scripts and a CPU overclocked to 2.9GHz to do the job.
Therefore the suggested hardware requirements are as follows...

DLNA Server Hardware Requirements
Intel Core 2 Duo 2.9GHz or better (for transcoding proper HD videos)
100-1000 Mbps wired LAN


Enjoy!

Saturday, January 10, 2009

Truecrypt 6/7 on CentOS 5

Truecrypt is available as a Red Hat/CentOS package on RPMForge, however I found that it's problematic and only supports FAT disks. I needed to use Truecrypt to encrypt a USB drive that is going to store files larger than 4GB so FAT isn't an option.
There's many conflicting accounts on various forums on how to compile Truecrypt on CentOS 5 however the most helpful was still the README provided in the source package which still required a bit of trial and error to get a working binary at the end.
Therefore here's my walkthrough on the quickest, simplest way to get Truecrypt 6.1 compiled and working on a vanilla CentOS 5 installation.
Switch user to root.
 su -  

** UPDATE - RPMForge was merged into RPMFusion which also requires the EPEL repo on RHEL/CentOS** 
Firstly setup access to the EPEL repositories, download the latest EL5 RPM from their repo. This package just installs the EL5 repo file and the required GPG keys, install it with;
 rpm -i /pathtoyour/epel-release-5??.noarch.rpm  

The RPMFusion repository provides decent packages for fuse and wxwidgets which are required by Truecrypt, this really simplifies the process as I found setting up wxwidgets & fuse from source to be a chore.
Upto date instructions for enabling this repo is at rpmfusion.org/Configuration, the correct command-line for downloading & installing free & nonfree RPMFusion repos at time of writing is;
 rpm -Uvh http://download1.rpmfusion.org/free/el/updates/5/i386/rpmfusion-free-release-5-1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/5/i386/rpmfusion-nonfree-release-5-1.noarch.rpm  

Once RPMFusion is setup then install the following packages and their dependencies;
 yum install gcc gcc-c++ gnome-keyring-devel kernel-devel kernel-headers wxGTK wxGTK-devel fuse fuse-devel fuse-ntfs-3g  

Next download the Mac OSX/Linux source package from the Truecrypt website at http://www.truecrypt.org/downloads2.php and save it somewhere. In this example I've saved it to /tmp.
Now in a terminal goto the location of the archive and unpack it.
 cd /tmp  
 tar xvfz “TrueCrypt 7.1a Source.tar.gz”  

... cd to the new directory containing the extracted source code
 cd truecrypt-7.1a-source  


Download the RSA Cryptoki 2.20 header files required by Truecrypt into the source directory.
 wget ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20/*.h   

Compile Truecrypt.
*UPDATE:  Include the NOASM flag to prevent assembly with nasm*
 make NOASM=1

The compilation process should now breeze through with no errors.
Now copy the compiled binary to /usr/bin
 cp -p Main/truecrypt /usr/bin/  
 chmod +x /usr/bin/truecrypt  

You can now start Truecypt from a root terminal.
 truecrypt  




Swapping encrypted disks between Linux & Windows systems
My requirement for Truecrypt on CentOS was for transporting sensitive data on an encrypted USB hard disk to one of our software suppliers. The guys receiving the data run Windows on their systems whereas we run HP-UX, RHEL & CentOS on our systems, Truecrypt was the only decent open-source cross-platform solution that would enable us to securely transport the encrypted data without it being too technical for the guys receiving it.
However I was a bit disappointed with how different the Windows version was to the Linux version and it became apparent that the project still needs some direction in terms of enhancing the cross-platform nature of Truecrypt.

One area where this was apparent was the filesystem options available in the GUI, the Windows version only had options to create or mount FAT32 & NTFS encrypted filesystems whereas the Linux version only had options for FAT32, Ext3 & Ext2 filesystems.
If you intend to swap an encypted disk with large file support between Linux & Windows platforms, it is not possible to do this by using the Truecrypt GUIs alone.
After some time testing the best solution for this was to use a NTFS filesystem on the USB disk and encrypt the whole filesystem on a Windows platform using the GUI.
When it comes to using the encrypted disk on the Linux platform you have to mount and dismount it with Truecrypt's command-line options as the GUI does not support this.

Examples
To mount the encrypted NTFS volume on Linux;
As root substituting the 'correctpassword', the device path & the mountpoint as appropriate...
 truecrypt -t --filesystem=ntfs-3g -k "" --protect-hidden=no --fs-options=user,users,gid-users,umask=0002 -p correctpassword /dev/sdx1 /pathto/mountpoint  

To unmount the encrypted volume;
As root...
 truecrypt -t -d /dev/sdx1  
or...
 truecrypt -d /pathto/mountpoint  

What doesn't work?
  • Truecrypt on Windows will not mount an encrypted Ext2 or Ext3 filesystem, even with an appropriate Ext filesystem driver installed.
  • Truecrypt on Linux will not mount an encrypted file container, mounting a file residing on an already mounted filesystem seems to be the problem.
  • The Linux Truecrypt GUI cannot gain elevated privileges after entering your sudo password, even if sudo/sudoers is setup correctly, therefore su to root before executing the GUI from a terminal.
  • The Truecrypt GUI on Linux cannot mount encrypted NTFS filesystems

Thursday, September 20, 2007

Running the QW:ET Demo on Fedora 7

Now one really cool thing that I gotta share has pretty much occupied my whole day today, and with damn good reason too.
The Quake Wars: Enemy Territory demo was released recently to much excitement and draining of bandwidth across file repository sites around the globe, I too downloaded the file and eagerly waited for the download to finish.

Now I only use Linux on my computers. I choose to not allow a certain very well known, bloated, overpriced, featureless trojan-horse of an operating system anywhere near them as I prefer my PCs to be fast, secure, stable and also include a lot of cool, leading edge stuff to play with.
There are many other reasons why I use open source software, I'm sure they'll ooze out in future posts but not today.

Therefore I had my fingers crossed hoping that this demo would work on my Fedora desktop.
I first tried Cedega as I pay for the thing (God knows why!) it didn't even install!
I installed Wine from the Fedora repositories, QW:ET installed OK and I sorted out a few other bits and bobs but the demo Didn't run :(
QW:ET came back with something along the lines of a 'Display must support 32bpp colours' message. Damn! X only supports 24bit. I walked away defeated.

Today I stumbled across an brill little how-to on the QW:ET forum which was a little collection of links & tips gathered by stoic_ails over at the forum. The original how-to can be found over at http://community.enemyterritory.com/forums/showthread.php?t=9115.
Therefore I do not take credit for this info, all I have done is correct & expand the odd bit here & there and stick it all in nice bloggy format for all to hail mightily so here goes.

Preparation
Firstly I got rid of my Yum installed Wine (0.9.42) installation as this did not have the patches required to get round the 32bit display message.

UPDATE
Wine 0.9.46 is now in many distro's repositories which works OK with the QW:ET demo without patching.

Therefore if you have Wine 0.9.46 or later from your package manager you don't have to compile Wine yourself anymore and you can skip steps 1-9c and kick off from step 10a.


I logged in as root, entered the root password and removed wine using yum;
su -
yum remove wine

If you are using a different distribution, maybe one of those crazy Debian based affairs, you may want to remove Wine as follows;
sudo apt-get remove wine

Then I was ready to go...
Do everything by the book and you'll be rocking the QW:ET with the rest of us. Until the native Linux version of the full game is released around the end of October.

I already had the Nvidia binary Linux drivers installed on my system and I assume that your system also has 3D acceleration enabled, the process of installing proprietory graphics drivers is not covered here.
If you're expecting to run QW:ET without any 3D acceleration then you are proper silly.


Oh yeah of course, download the QW:ET demo as well. I got it from Filefront.com as the downloads are fast with no queues and no registration required. Download link below.
Enemy Territory: QUAKE Wars PC Demo

The How-To
1. Get the latest wine source; in this case 0.9.44: http://prdownloads.sourceforge.net/w...0.9.44.tar.bz2

2a. In your home directory, make a directory called wine
mkdir ~/wine

2b. Copy the archive to the new directory ~/wine :
cp wine-0.9.44.tar.bz2 ~/wine/

3. Change to that directory:
cd ~/wine/

3. Unpack the archive:
tar xvfj wine-0.9.44.tar.bz2

4a. Open http://bugs.winehq.org/attachment.cg...39&action=view and copy it (ctrl+a & ctrl+c) into a file called patch1.

4b. Open http://bugs.winehq.org/attachment.cg...49&action=view and copy it (ctrl+a & ctrl+c) into a file called patch2.

4c. Change directory to where you've saved the patch1 & patch2 files too, maybe your desktop for example.
cd ~/Desktop

5a. Copy patch1 to the wine source directory:
cp patch1 ~/wine/wine-0.9.44/

5b. Copy patch2 to the wine source directory:
cp patch2 ~/wine/wine-0.9.44/

6. Change to the wine source directory:
cd ~/wine/wine-0.9.44/

6a. Patch the wine source:
patch -p1 < patch1

6b. Patch the wine source:
patch -p1 < patch2

7a. Run configure:
./configure

7b. If configure complains about missing packages, stop here and install the missing packages...
For those using Debian/Ubuntu/Linux Mint/etc. it'd go something like:
sudo apt-get install flex bison fontforge

For those very sensible lot running Fedora/Red Hat type distros:
su -
yum install
fontforge
exit

...and run ./configure again.


7c. Go ahead when configure finished successfully.

8a. Run the following command:
make depend && make

8b. Wait and hope that there's no errors.

8c. Go ahead when make finished successfully.

9a. Change to user root:

su

9b. Run:
make install

9c. When the install has finished, exit from root:
exit

10a. Run:
regedit

10b. Go to HKEY_CURRENT_USER/Software/Wine/

10c. Add the key X11 Driver

10d. Add the string ScreenDepth with the value 32 (Screenshot)

11. Download http://tacticalsites.com/~lorian/fil...stem32.tar.bz2

12. Copy the archive to your wine system32 directory:

cp system32.tar.bz2 ~/.wine/drive_c/windows/system32/

13. Change to that directory:
cd ~/.wine/drive_c/windows/system32/

14a. Unpack the archive:
tar xfvj system32.tar.bz2

15a. Run:
winecfg

15b. Set the windows version to Windows XP (Screenshot)

15c. Go to libraries and set wtsapi32 to Native (Windows) (Screenshot)


16a. Install the ET:QW Demo:
wine ETQuakeWarsDemoSetup.exe

16b. There might be some complaints, just click 'ok' :P

17. Download http://tacticalsites.com/~lorian/fil...st_x86.exe.bz2

18. Unpack it:
bunzip2 vcredist_x86.exe.bz2

19. Run:
wine vcredist_x86.exe

20. Check that msvcr80.dll, Microsoft.VC80.CRT.manifest and Microsoft.Windows.Common-Controls.manifest are neither in the system32, nor in the game directory. If they are, delete them.

21. Change to your ET:QW Demo installation, e.g.:

cd ~/.wine/drive_c/Program\ Files/id\ Software/Enemy\ Territory\ -\ QUAKE\ Wars\ Demo/
(notice any spaces in directory names have to be preceded with a backslash)

22. You can start ET:QW Demo like this:
nice -n19 wineserver && wine etqw.exe
(This way, wineserver won't use too much CPU time)
Or you can be all gung-ho like me and have a launcher icon that runs:
env WINEPREFIX="/home/vin/.wine" wine "C:\Program Files\id Software\Enemy Territory - QUAKE Wars Demo\etqw.exe"

23. Before joining a game, the mouse can behave weird in the menu. But after joining it's just fine, like the whole game.

24. You can now clean up and get rid of the ~/wine directory if you want:
rm -rf ~/wine



The Results
The guy who originally wrote this how-to also pointed out that he found that QW:ET running under Wine on Linux was actually performing better for him that under Windows XP & Windows Vista on a similar spec PC. I don't really find this surprising as I have seen similar comparisons with other games which had similar outcomes, especially against Vista as it's a dog.

When I got round to toying with the graphics settings I found that just sticking the detail on 'High' prevented the level from loading, so I chose the 'Custom' settings and set most of rendering details to "High", the Anti-Aliasing could not be enabled. I'd put that down possibly to the version of the DirectX API under Wine.

Anyway that's not really a problem as it looked fantastic at 1280x1024 resolution and I was seeing frame-rates between 30-40+ FPS on my system during online gameplay with 31 other players together with all the high-end weather, plants, 'soft particle' effects and all that fancy stuff which simply looks fantastic.
Punkbuster doesn't work so I just filtered out the punkbuster servers out of the server list, no biggy.


My system?
Fedora 7
Intel Core 2 Duo 2.33 GHz
1GB DDR2 PC8500+ RAM (1066Mhz)
Nvidia GeForce 7600GS PCIe 16x
Nvidia HD 7.1 sound


Kill ya later...