How to Stream Movies to your iPhone or iPad

I have just found a way to successfully stream movies (avi, mkv, mp4, etc) to my iPhone. It’s via an app called AirPlayer.

First, set up a media server on your home network (for example, PS3 Media Server, like what I have explained in my previous post, “How To Share Media Between PlayStation 3 and Linux”). Then, just access your movies through the AirPlayer app. Everything just works, without much setting or config changes.

Create Your Own Web App to Execute Linux Command

Let say you need to run a command (which you use frequently) on your headless Linux box, such as, copying files, start/stop services, reboot, etc. However too lazy to go to the physical machine or open a ssh command from another pc.
Would it be nice if we have a web application that can easily be accessed through a web browser (even from a mobile web browser), to execute those commands. All we have to to is type the url (http://my-server-ip-address:myportnumber), and click on a link.
All these could easily be achieved using very simple service using Python.

1. Create a simple Python script. The Python script will be using WSGI to serve HTTP request/response.

vi mypythonscript.py

2. A sample of the Python script below:

import os
from cgi import parse_qs, escape

def hello_world(environ, start_response):
    parameters = parse_qs(environ.get('QUERY_STRING', ''))
    if 'type' in parameters:
        mycommand = escape(parameters['command'][0])
    else:
        mycommand = ''
    start_response('200 OK', [('Content-Type', 'text/html')])

    if mycommand == 'copyfile1':
	#your linux command here. Example below
	os.system('cp myfile1.txt mynewfile.txt')
    elif mycommand == 'copyfile2':
	os.system('cp myfile2.txt mynewfile.txt')

    return ['''Command to execute:  %(mycommand)s 
    <a href='?command=copyfile1'>Copy file 1</a>
    <a href='?command=copyfile2'>Copy file 2</a>
    ''' % {'mycommand': mycommand}]

if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    #put your own server ip address and port here
    srv = make_server('127.0.0.1',81, hello_world)
    srv.serve_forever()

3. Make the Python script run on every startup. Create a bash script for this:
vi myserver

4. Here’s the script for the bash file:

#! /bin/sh
# /etc/init.d/myserver
#

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting myserver "
    python /home/username/mypythonscript.py&
    echo "[OK]"
    ;;
  stop)
    echo "Stopping myserver "
    kill -9 `pidof python`
    echo "[OK]"
    ;;
  *)
    echo "Usage: /etc/init.d/myserver {start|stop}"
    exit 1
    ;;
esac

exit 0

5. make the bash script executable.
chmod +x myserver

6. copy myserver script to /etc/init.d
sudo cp /wherever/you/saved/myserver /etc/init.d/myserver

7. update the startup folders to include the new script.
sudo update-rc.d myserver defaults

8. To test your Python web app, open a web browser, and type:
http://my-server-ip-address:81

How To Share Media Between PlayStation 3 and Linux

A while ago I have posted on How To Share Media Between XBOX 360 and Linux. It also can be as easy with PlayStation 3 and Linux, with PS3 Media Server. Below are the steps that diablo 2 items suggests which can let you achieve that.

Install necessary codex or media player:
sudo apt-get install vlc ffmpeg mencoder mplayer

Install Sun Java:
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

Download PS3 Media Server. Then extract the downloaded tar to any location:
tar xzf pms-generic-linux-unix-1.20.412.tgz

Go to the folder that you have just extracted:
cd pms-linux-1.20.412/

Run the PS3 Media Server simply by:
./PMS.sh
Command above will open the PlayStation 3 Media Server user interface.

Movie Subtitles on Ubuntu 10.10
The yesgamers is the d2 store points out that the subtitle broke for Ubuntu 10.10. This is due to Mplayer needs to know the location of a TrueType Font to show movie subtitles. Command below will fix it:
sudo apt-get install ttf-bitstream-vera

ln -sv /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf ~/.mplayer/subfont.ttf

Disable ASS/SSA subtitles:
1. Go to PS3 Media Server user interface. Go to “Transcoding Settings” tab.
2. Uncheck ASS/SSA subtitles checkbox.

Playing 1080p Video in Ubuntu Without Lag

I have not-so-bad specs for my laptop:
– Dell XPS M1530
– Intel Code 2 Duo CPU 2.40GHz
– 4GB RAM
– Running Ubuntu Karmic Koala 9.10

I have no problem running 720p .mkv HD video files. No lagging, no dropped frames whatsover. However, when running 1080p .mkv files, especially those big sizes full-HD Blue Ray medias, I have:
– Lagging,
– Dropped frames,
– 100% CPU utilizations.

It doesn’t matter if I’m using VLC, or Totem Movie Player, it will always have those problem above. From what I’ve read, this is probably due to FFMpeg codecs for H.264 decoding.

However, I have a solution, found from http://ubuntuforums.org/showthread.php?t=1037625

Below are the steps:
1. Install mplayer:
sudo apt-get install mplayer-nogui

2. Run your 1080p .mkv files with it:
mplayer -vo vdpau -vc ffh264vdpau /path/to/the/mkv/file

Now the HD movies playing in my Ubuntu laptop are smooth as it can be.
Try it out. Cheers.

How to Check for Open Ports in Ubuntu

There are various ways to view for open ports on your local Ubuntu/Linux machine. However, I particularly prefer two methods/command below, since it is simple, and without any third-party application.

Open your command prompt, and type:
netstat -an | grep "LISTEN "

Or, another method:
sudo netstat --tcp --udp --listening --program

It will list all ports that your machine are listening to. The latter method will even shows the program name associated to it.

Enjoy.