30 December, 2009

Create ISO Image From Directory

Occasionally it's useful to create a CD/DVD ISO image from a list of files contained in a directory. For instance, if you're interested in archiving a bunch of files to be later burned to a CD/DVD.

This can be done by using the mkisofs command which stands for 'make ISO filesystem'.

If you have a list of directories like the following:

user@debian:/media/ehd/tmp$ ls -l
total 2802468
drwxr-xr-x 3 root root 4096 2009-12-29 13:01 disc01
drwxr-xr-x 3 root root 4096 2009-12-29 13:01 disc02
drwxr-xr-x 3 root root 4096 2009-12-29 13:02 disc03
drwxr-xr-x 3 root root 4096 2009-12-29 13:03 disc04
drwxr-xr-x 3 root root 4096 2009-12-29 13:05 disc05
drwxr-xr-x 3 root root 4096 2009-12-29 13:06 disc06
drwxr-xr-x 3 root root 4096 2009-12-29 13:08 disc07
drwxr-xr-x 3 root root 4096 2009-12-29 13:09 disc08
drwxr-xr-x 3 root root 4096 2009-12-29 13:10 disc09
drwxr-xr-x 3 root root 4096 2009-12-29 13:10 disc10
drwxr-xr-x 3 root root 4096 2009-12-29 13:12 disc11

You can create individual ISO images for each directory by issuing the following command:

$ mkisofs -o disc02.iso -J disc02

The ISO image will preserve the directory structures and file names found under disc02.


27 December, 2009

Embedded MPlayer in Tk

Ok, something a bit more interesting.

I've been using mplayer since 'bout 94 (near as I can recall), it's has been and continues to be my video player of choice. In spite of that, I still learn things now and again. Today was an instance of learning a little something about it I didn't know before.

Mplayer supports a slave mode, this was news to me. In that mode it is geared to receive commands to manipulate the player. The intention is to allow the creation of front-ends which are plentiful for that reason. I found this especially useful in embedding Mplayer into a Tk window and binding Tk controls to the player.

Below is a rough sampling of how it can be done.

package require Tk

proc Exit { } {

proc Play { } {
upvar #0 playerId playerId
puts $playerId "pause"

proc ReadPipe {chan} {
upvar #0 playerId playerId
set d [read $chan]
foreach line [split $d \n] {
set line [string trim $line]
if {[regexp {^\*\*\* screenshot '(.*?)' \*\*\*} $line -> filename]} {
# delay to permit the file to appear
after 250 [list OnScreenshot $filename]
if {[eof $chan]} {
fileevent $chan readable {}
close $chan
set playerId ""

proc EmbedPlayer { w } {
upvar #0 fileList fileList
upvar #0 playerId playerId
set cmd mplayer
lappend cmd -slave -vf scale=1540:1050 -wid [winfo id $w] -idle

set pipe [open |$cmd r+]
fconfigure $pipe -blocking 0 -buffering line
fileevent $pipe readable [list ReadPipe $pipe]
set playerId $pipe

puts $playerId "load [lindex $fileList 0]"
set fileList [lrange $fileList 1 end]

proc main { { fileList [list]} } {
wm title . "User Interface"
wm protocol . WM_DELETE_WINDOW [list Exit]
wm withdraw .

frame .video -width 1540 -height 800
grid .video -sticky news

frame .controls -width 1540 -height 100
button .play -text "Play" -command Play
grid .play -sticky news

grid rowconfigure . 0 -weight 1
grid columnconfigure . 0 -weight 1

option add *tearOff false
. configure -menu [menu .menu]
.menu add cascade -label File -menu [menu .menu.file]
.menu.file add command -label Exit -command Exit
bind .video {
bind %W
EmbedPlayer %W
wm deiconify .

set fileList $argv

I stripped this segment out of a more involved utility I'm working on so it isn't as clean as it could be.

Issue ./mplayerUi and Bobs Your Uncle.

Playing Video On Desktop

I've been screwing around with MPlayer for a bit today. Specifically, I was trying to configure it to display on the desktop rather than a movable window.

I found a couple things worth noting:
1) if you don't have hw support you won't be able to apply it to your background nor scale it. Check for xv support by issuing the 'xvinfo' command. I found I didn't have the proper driver configured and therefore had to tweak my xorg.conf
2) The required command to scale the video up (in my case) isn't intuitive.

I had success with the following command:

$ mplayer -vf scale=1024:720 -rootwin DesiresAndDiversions.mpg


Diamond Radeon HD 3450 X Configuration

Spent some time today playing with Mplayer. Got stuck applying the video to the root window because I didn't have xv support enabled. As a result, did some Googlin' and had to reconfig my xorg.conf; attached.

$ cat /etc/X11/xorg.conf
Section "Monitor"
Identifier "Configured Monitor"

Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 24

Section "Module"
Load "glx"
Disable "dri2"

Section "Device"
Identifier "Configured Video Device"
Driver "fglrx"

Section "DRI"
Mode 0666

Section "Extensions"
Option "Composite" "Enable"

26 December, 2009


It's been quite some time since I've authored a post. Been busy at work and haven't found too much time to find new things to play with.

I did however take a little time over Christmas to rattle on the keyboard. I found a text-to-speech utility that proves promising to play with.

# apt-get install espeak

Then, simply run it.

$ espeak "hello, how are you doing?"

Easy, peezy.