Wednesday, January 26, 2011

Programming QtRuby (2) - Open a Dialog

1. Main program.

# main.rb
require 'rubygems'
require 'Qt'
require 'dialogwindow.rb' 

class QtApp < Qt::Application
 
 include DialogWindowModule
 
 def initialize(argv)
  super(argv)
  d = SimpleDialog.new
  d.show
  self.exec
 end
end

QtApp.new ARGV


2. DialogWindow Module
# dialogwindow.rb
require 'Qt'
module DialogWindowModule

 class SimpleDialog < Qt::Dialog
  def initialize
   super
   self.resize 300,200
   self.setWindowTitle 'Dialog Test'
  end
 end

end
3. Run it to see the result.

Saturday, January 22, 2011

Installing PS3 Media Server on Ubuntu successfully

After being disappointed with MediaTomb, I decided to try PS3 Media Server again. This time I found Leigh Henderson's blog site that gives a step-by-step instruction for installing PS3 Media Server on Ubuntu 10.04.

Here is the site: http://irrationale.com/2010/06/30/ps3-media-server-on-ubuntu-10-04/


See also my notes on my first attempt for PS3 Media Server installation that failed (http://socrateos.blogspot.com/2011/01/installing-ps3-media-server-on-ubuntu.html).

Here is what I did, following Leigh's instruction. (My Ubuntu is 10.10)
It is basically identical to this instruction.

1. Install required softwares: mplayer, mencoder, ffmpeg, and sun-java6-jre. I already had ffmpeg installed on my system. I used GUI tool Synapitc instead of a command line command to install these softwares.

2. Download the latest version of PS3 Media Server from: http://code.google.com/p/ps3mediaserver/downloads/list
I downloaded: pms-generic-linux-unix-1.20.412.tgz (PS3 Media Server for Linux/Unix v1.20.412 BETA )

3. Create a directory and copy the expanded pms folder.
mkdir /opt
mv ~/pms-linux-1.20.412/ /opt/pms
cd /opt/pms
sudo chmod +x PMS.sh
sudo chmod +x linux/tsmuxer

4. Edit PMS.conf file.
thumbnails = true
thumbnail_seek_pos = 300
mencoder_ass = true
folders =/home/(username)/media/
hide_videosettings = true
hide_enginenames = true
audiochannels = 2

5. Install mediainfo in order to stream MP4 from PS3 MediaServer.

Now I found that PS3 Media Server by iteself was not able to stream MP4 that can be played on PS3. Luckily there is an easy way to do this. Just install mediainfo (using PPA, or Private Package Archives).
$ sudo add-apt-repository ppa:shiki/mediainfo  # add a PPA to my Ubuntu
$ sudo apt-get update                          # update Ubuntu package manager
$ sudo apt-get install mediainfo               # install it
See the mediainfo home page at: https://launchpad.net/~shiki/+archive/mediainfo

Wednesday, January 19, 2011

Using MySQL for MediaTomb

1. Create a MySQL user

$ mysql -u root -p
mysql> create user 'mediatomb'@'localhost' identified by 'secret';
mysql> create user 'mediatomb'@'%' identified by 'secret';
mysql> grant all on mediatomb.* to 'mediatomb'@'localhost';
mysql> grant all on mediatomb.* to 'mediatomb'@'%';
mysql> quit

$ mysql -u mediatomb -p
mysql> create database mediatomb;
mysql> quit

$ mysql mediatomb -u mediatomb -p < /usr/share/mediatomb/mysql.sql

$ sudo /etc/init.d/mediatomb restart

Tuesday, January 18, 2011

Installing MySQL (5.1) on Ubuntu

Install MySQL Server

1. Go to Application > Software Center
2. Search for "mysql".
3. Find "MySQL Server" and install.
4. Give a password for the "root" user when prompted.

Check the installation

$ mysql --version
mysql  Ver 14.14 Distrib 5.1.49, for debian-linux-gnu (i686) using readline 6.1 
$ mysqladmin
mysqladmin  Ver 8.42 Distrib 5.1.49, for debian-linux-gnu on i686
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
$ mysql -h localhost -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 51
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql> select version(), current_date;
+-------------------+--------------+
| version()         | current_date |
+-------------------+--------------+
| 5.1.49-1ubuntu8.1 | 2011-01-18   |
+-------------------+--------------+
1 row in set (0.00 sec)


Create a new database and a new user (myself)
mysql> create database testdb;
Query OK, 1 row affected (0.00 sec)

mysql> create user 'socrateos'@'localhost' identified by 'secret';
Query OK, 0 rows affected (0.00 sec)

mysql> create user 'socrateos'@'%' identified by 'secret';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on *.* to 'socrateos'@'local';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on *.* to 'socrateos'@'%';
Query OK, 0 rows affected (0.00 sec)

$ mysql -h localhost -u socrateos -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 52
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

mysql> quit
Bye
$ mysql -h localhost -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 53
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| testdb             |
+--------------------+
3 rows in set (0.00 sec)



6. Documentation fo r5.1 is at: http://dev.mysql.com/doc/refman/5.1/en/index.html

Monday, January 17, 2011

Programming QtRuby (1) - Open a Window

1. Main program.

# main.rb
require 'rubygems'
require 'Qt'
require 'mainwindow.rb' 

class QtApp < Qt::Application
 
 include MainWindowModule
 
 def initialize(argv)
  super(argv)
  w = MainWindow.new
  w.show
  self.exec
 end

end

QtApp.new ARGV


2. MainWindow Module
# mainwindow.rb
require 'Qt'
module MainWindowModule

 class MainWindow < Qt::MainWindow
  def initialize
   super
   self.resize 400,300
   self.setWindowTitle 'Hello from QtRuby'
  end
 end

end


3. Run it to see the result.


wxRuby stopped working but gtk-ruby kept working after upgrading Ubuntu to 10.10

wxRuby suddenly stopped working.
This is perhaps due to my recent Ubuntu upgrade to 10.10.
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'wx'
LoadError: libwx_gtk2u_media-2.8.so.0: cannot open shared object file: No such file or directory - /var/lib/gems/1.8/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so
 from /var/lib/gems/1.8/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so
 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
 from /var/lib/gems/1.8/gems/wxruby-2.0.1-x86-linux/lib/wx.rb:12
 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
 from (irb):2

Gtk-ruby seems working fine.

I will not be going back to wxRuby for a while, perhaps never.
It is not good if app stops working every time users upgrade their OS.

Saturday, January 8, 2011

Setup Automatic Scan for MediaTomb

------------------------------------------------------------------------------------
I did UNDO what I did below. Autoscan for MediaTomb is not working for me. It deletes items from the database.
------------------------------------------------------------------------------------

1. Edit config.xml file


$ sudo gedit /etc/mediatomb/config.xml


Based on suggestions by a few people (see below for references), I have added to the config.xml the following (red part) between </scripting> and <mapping> tags at around line 62.


   </scripting>
    <autoscan use-inotify="auto">
        <directory location="/home/<user>/video" mode="inotify" recursive="yes" hidden-files="no"/>
    </autoscan>
   <mappings>



2. Then restart the server.



$ sudo /etc/init.d/mediatomb restart
 * Restarting upnp media server mediatomb     [OK] 


3. References.


http://ubuntuforums.org/showthread.php?t=842559
http://groups.google.com/group/dealextreme-nas-/web/mediatomb-howto?pli=1                                              

Reset MediaTomb Database

My MediaTomb database seem confused and not displaying files specified by a directory I added. So I decided to reset the database.

Here is the information that I found:
http://sourceforge.net/apps/phpbb/freenas/viewtopic.php?f=27&t=696

Basically, just delete mediatomb.db, and mediatomb will recreate one when restarted.

1. Stop the server.
$ sudo /etc/init.d/mediatomb stop
 * Stopping upnp media server mediatomb                                                                     [ OK ] 

2. Delete the database file.
$ cd /var/lib/mediatomb/
$ ls
mediatomb.db  mediatomb.html
$ sudo mv mediatomb.db mediatomb.db.bak

3. Start the server.
$ sudo /etc/init.d/mediatomb start
 * Starting upnp media server mediatomb                                                                     [ OK ] 
$ ls
mediatomb.db  mediatomb.db-journal  mediatomb.db.bak  mediatomb.html

It created a brand new empty database.

Friday, January 7, 2011

Installing MediaTomb on Ubuntu

I installed MeidaTomb on my Ubuntu (10.10).

1. Search and install MediaTomb in Software Center.

2. Check Synaptic for installation: It displays 3 items as installed.
- mediatomb 0.12.1 UPnP MediaServer (main package)
- meidatomb-daemon 0.12.1 UPnP MediaServer (daemon package)
- mediatomb-common 0.12.1 UPnP MediaServer (base package)

3. Launch MediaTomb from Application > Sound & Video menu.
It opened a web server (port:49152) but displayed the message:
"MediaTomb UI is disabled. Check our configuration"

4. Open /ext/mediatomb/config.xml to change the config.

Line 007: <ui enabled="yes" show-tooltips="yes">
Line 026: <protocolInfo extend="yes"/>      # PS3 support
Line 078: <map from="avi" to="video/divx"/> # PS3 divx support
Line 121: <transcoding enabled="yes">

5. Restart the server.
$ sudo /etc/init.d/mediatomb restart
 * Restarting upnp media server mediatomb                                                             [ OK ] 
$ 
6.  Add files to the database.
Lanunch MediaTomb (or just go to localhost:49152)
Click "Filesystem"
Locate your video folder(s)
Click + to add the folder(s) to the database.
7. Play the video(s) using PS3
Start PS3
Goto Video
Select MediaTomb
Select registered folder and select a video to play.
8. References
http://www.freesoftwaremagazine.com/columns/upnp_mediatomb_ps3_and_me
http://ubuntu-utah.ubuntuforums.org/showthread.php?t=1618859

Installing PS3 Media Server on Ubuntu failed

I've tried to install PS3 Media Server on my Ubuntu (10.10), but it failed.
I was reluctant to install this because it is a Java app, and it is not in Ubuntu repositories.
But I tried anyway because of good reviews.

The installer reported the following warnings and an error:
(1) It failed to install mediainfo, mplayer-mt and mencodeer-mt because I have 'maverick'.
(2) It failed to retrieve a public key.

$ sudo wget -q --no-check-certificate https://svn.paissad.net/misc/stuffs/install_PMS.sh -O /tmp/install_PMS.sh && bash /tmp/install_PMS.sh

+----------------------------------------------------------------------------+
+                     PS3MediaServer (PMS) for Linux ...                     +
+----------------------------------------------------------------------------+

Your distribution is ...: Ubuntu
Your release is ........: maverick
Your architecture is ...: i386
Your hostname is .......: ubuntu-pc


You seem to have a CPU with multithreading support.
It can be interesting to install the multithreaded versions of mlayer & mencoder.
Do you want to install mplayer-mt & mencoder-mt too ?

Enter 'yes' (y|Y) to intall or 'no' (n|N):  y
[sudo] password for socrateos: 

+----------------------------------------------------------------------------+
+ Backup /etc/apt/sources.list to /etc/apt/sources.list.2011-01-07_17:33:17  +
+----------------------------------------------------------------------------+
`/etc/apt/sources.list' -> `/etc/apt/sources.list.2011-01-07_17:33:17'

+----------------------------------------------------------------------------+
+                       Updating /etc/apt/sources.list                       +
+----------------------------------------------------------------------------+

#==================================
# Paissad Repository (pms-linux)  =
#==================================
deb http://deb.paissad.org/ unstable main contrib non-free
deb-src http://deb.paissad.org/ unstable main contrib
Warning: You have 'maverick', but the latest build of mediainfo is for 'lucid'
         We will not install mediainfo !!
         Try to build from source.
         See: http://mediainfo.sourceforge.net/ 

Warning: You have 'maverick', but the latest build for mplayer-mt,mencoder-mt is for 'karmic'
         We will not install mplayer-mt, mencoder-mt.
         Try to build from source.
         See: http://ubuntuforums.org/showthread.php?t=1049449
              http://ps3mediaserver.org/forum/viewtopic.php?f=3&t=8539 

        ANYWAY, you don't have to worrry about the warnings, PS3MediaServer
        (pms-linux) WILL RUN NORMALLY WITHOUT THOSE PACKAGES.

DONE ...

+----------------------------------------------------------------------------+
+                          Downloading public keys                           +
+----------------------------------------------------------------------------+
gpg: 有効なOpenPGPデータが見つかりません。
Error: Cannot retreive public key for http://deb.paissad.org (1) 
 

Sunday, January 2, 2011

Installing Pony, a Ruby Gem

Installing of Pony is simple.
Here it is install for both Ruby 1.8.7 and 1.9.1.
$ sudo gem install pony
Successfully installed pony-1.1
1 gem installed
Installing ri documentation for pony-1.1...
Installing RDoc documentation for pony-1.1...
$ sudo gem1.9.1 install pony
Successfully installed pony-1.1
1 gem installed
Installing ri documentation for pony-1.1...
Installing RDoc documentation for pony-1.1...
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'pony'
=> true
irb(main):003:0> exit
$ irb1.9.1
irb(main):001:0> require 'pony'
=> true
irb(main):002:0>