27 March, 2010

A Duck Of A Different Feather

Microsoft has been known to do things a bit different from the norm. Sometimes for no reason, sometimes to set themselves apart, sometimes because they're simply idiots.

Case in point, Windows Seven now has a "Performance Information and Tools" that'll rate the performance of your system compared to a benchmark. Below is the benchmark for my puny Acer Aspire one:




A scale from 1.0 .. 7.9......WTF?

04 January, 2010

Mplayer + FFMpeg + /dev/video

I've recently published posts for capturing video from a QuickCam Express using FFMpeg. I also posted how to play live video with MPlayer. That covers storing video or playing live video. Playing or storing video with a camera source seems mutually exclusive.

That said, what if you want to store and play live video simultaneously?

Playing live video while storing the incoming video is do-able using these tools and a first-in-first-out (FIFO).

The trick is to recognize that FFMpeg can support converting a single input file into multiple output files. For instance, you can convert a source video file into two output files as follows:


$ ffmpeg -i source.avi /tmp/output.avi /tmp/output.mpg


This command will take the source file source.avi and generate twin output files /tmp/output.avi and /tmp/output.mpg converting them simultaneously.

Similarly, you can use a video device /dev/video rather than an input video file and generate twin output files by using a similar command:


$ ffmpeg -r 15 -s 352x288 -f video4linux -i /dev/video0 /tmp/output.avi /tmp/output.mpg


While cool and closer, attempting to play the file will eventually reach the file end and terminate. Instead, by using a FIFO as an output file and using this FIFO as the input to Mplayer you've accomplished your goal.


$ mkfifo /tmp/vidPipe
$ ffmpeg -y -f video4linux -r 15 -s 352x288 -i /dev/video0 -f avi -vcodec msmpeg4 /tmp/vidPipe /tmp/output.avi


In another terminal window play the fifo with Mplayer using the following command:

$ mplayer /tmp/vidPipe


I love it when a plan comes together.

03 January, 2010

Playing QuickCam Video Stream with Mplayer

I've been toying with developing a Tk UI for multiple video sources, something like a video surveillance or situational awareness console.

I've made some notable progress embedding mplayer into multiple UI frames using precollected video source files and next needed to integration a 'live' video stream. That required determining the 'secret sauce' of arguments to get mplayer to recognize my QuickCam Express webcam....don't laugh, I've had it for years.

For those of you that are interested, the secret sauce is:

$ mplayer -fps 20 -tv driver=v4l:width=352:height=288:device=/dev/video0:outfmt=bgr24 tv://


Cheers.

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
user@debian:/media/ehd/tmp$


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.

Cheers

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.


#!/usr/bin/tclsh
package require Tk

proc Exit { } {
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 .
}

#---main---
set fileList $argv
main


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


Cheers.

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"
EndSection

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

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

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

Section "DRI"
Mode 0666
EndSection

Section "Extensions"
Option "Composite" "Enable"
EndSection