PS2 Eyetoy Webcam on Xubuntu 10.10 Recording and Playback

More fun to be had with your PS2 eyetoy as webcam. This all was tested using the silver eyetoy, but I see no reason why the black one won’t function just the same.
(Remember this is without pulseaudio!)
(a copy of the post I made on Ubuntuforums)
Recording Sound:

Continue reading

Mp3 playlist script – for current directory and sub folders

Making mp3 playlists, a “simple” script

#!/bin/bash

touch ${PWD##*/}.m3u
export IFS=$’n’
for i in $(find $1 -name “*.mp3″ -type f)
do
echo “$i” |sed ’s/..(.*)/1/’ >> ${PWD##*/}.m3u
done

shuf ${PWD##*/}.m3u > ${PWD##*/}2.m3u
shuf ${PWD##*/}2.m3u > ${PWD##*/}.m3u
rm ${PWD##*/}2.m3u

You can leave out the last three lines if you don’t want to shuffle the list.

There is probably improved/easier code than this but it works for me.

To use, simply copy the code into a text file, save with a name of your choice, and make the file script executable. Put the file in your path, and then run in the directory you want to make a playlist from. it will work on all sub directories of that folder.

Video Tearing Fixed – Xubuntu 9.10 – Nvidia ION

I use mplayer as my default video player, and have always had video tearing of some sort on my main PC. Having recently updated my PC to an Asus EB1012 net-top with the Nvidia ION graphics chip I found that enabling the vdpau options with mplayer gave me tear free playback. So I set out to resolve it for other file types (e.g. mp4 / avi)

I run Xubuntu by preference and normally use the Compositor to add transparency and shadows, and the default output plugin for mplayer is xv.

1. Turn off the compositor

2. This should produce tear free playback in totem and vlc

3. Open up nvidia-settings and ensure Sync to Vblank is ticked in  X Server XVideo Settings, and Sync to VBlank and Allow Flipping is ticked in Open GL Settings

4. edit the ~/.mplayer/config file

I grabbed the config file from GeexBox, as this served as a useful template to set up profiles for various file types.

For h264 / vdpau files (mkv) that use the GPU to process

[extension.mkv]
profile-desc=”Profile for Matroska files”
profile=lang
vo=vdpau
vc=ffh264vdpau

For HD Files (mp4)

[extension.mp4]
profile-desc=”Profile for HD mp4 files”
vo=gl
vfm=ffmpeg
lavdopts=lowres=0:fast=1:skiploopfilter=all
autosync=30
cache=32768

For “normal” (avi) files

[extension.avi]
profile-desc=”Profile for deinterlacing avi files”
vo=gl
vf=pp=lb/hb/vb/dr

The default section looks like this:

[default]
vo=vdpau,xv,gl
ontop=yes
double=yes
dr=yes
framedrop=yes
cache=8192
lirc=no
alang=en
slang=en

I have to make sure I check encoded options and rename the extension accordingly, but 95% of the time, this configuration works fine for me

Here is the entire ~/.mplayer/config file:

[deinterlace]
profile-desc=”Profile for picture de-interlacing”
vf-add=pp=fd

[dvd]
profile-desc=”Profile for DVD playback”
profile=deinterlace
dvd-speed=4
cache=8192

[lang]
profile-desc=”Profile for language”
alang=en

[protocol.dvd]
profile-desc=”Profile for dvd:// streams”
profile=dvd
profile=lang

[protocol.dvdnav]
profile-desc=”Profile for dvdnav:// streams”
profile=dvd
profile=lang
nocache=yes

[protocol.cdda]
profile-desc=”Profile for cdda:// streams”
cdda=speed=2

[protocol.tv]
profile-desc=”Profile for tv:// streams”
profile=deinterlace

[extension.mkv]
profile-desc=”Profile for Matroska files”
profile=lang
vo=vdpau
vc=ffh264vdpau

[extension.mp4]
profile-desc=”Profile for HD mp4 files”
vo=gl
vfm=ffmpeg
lavdopts=lowres=0:fast=1:skiploopfilter=all
autosync=30
cache=32768

[extension.avi]
profile-desc=”Profile for deinterlacing avi files”
vo=gl
vf=pp=lb/hb/vb/dr

[default]
vo=vdpau,xv,gl
ontop=yes
double=yes
dr=yes
framedrop=yes
cache=8192
lirc=no
alang=en
slang=en

Mplayer – neat and tidy on the CLI

How long have I been using mplayer? Years. Why has it never bothered me to sort this out before? Don’t know. Ageism, autism, or general grumpiness sent me off in search of a solution, and how easy was it.

Every time I have run mplayer from the cli I got three lines written out before the “action”:

mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

The very simple fix to this is to add an entry to your ~/.mplayer/config file

lirc=no

That’s it, no more extra lines. Remember to comment out “lirc=no” if you want to use a remote control, though 🙂

get_iplayer – Command Line Downloader for BBC iplayer

get_iplayer

My favourite program of the moment which exceeds the delivery of the iPlayer on Windows in just about every way!

To get the best out of it, download the latest version (and everything else you need) from here, and also make sure you have the following installed to make the most of the features available:

flvstreamer
ffmpeg
mplayer

(If you must install on Windows, there is an installer which takes care of everything for you)

flvstreamer is especially useful for getting higher quality versions of programmes, but you may have to fiddle about with the location of the file and its permissions to get things working correctly.

Ok, here are the commands I use the most:

get_iplayer
(this gathers a full index of programmes available)

get_iplayer keyword
(gathers index but also finds matches for “keyword” of your choice, e.g. Dr Who or Casualty)

Running the two above will show you the index number for the programme. Use this as follows:

get_iplayer –info 123
(will provide detailed info about the programme, including the various versions and qualities available)

get_iplayer -get 123
(will download the default version, usually iPhone – mov quality)

get_iplayer -get 123 modes=flashhigh flvstreamer=’/usr/bin/flvstreamer’
(will download a higher quality version in mp4 format using flvstreamer, my binary is located in /usr/bin/)

Finally

get_iplayer –update
(simply checks for any updates to get_iplayer and installs them)

Further commands, help and information here

Linux Nirvana – A webcam that actually works on my PC (also with Skype)

It’s been a long time coming, over three and one half years, but I can finally put all the hardware in the house to good use and use my PC (internet wise) as I was using Windows. And using a Sony Playstation Eyetoy to boot!

From my post on ubuntuforums, here is how to get the eyetoy working with Skype:

Close Skype before continuing.

Using K/X/Ubuntu 9.04 +, the gspca module in the kernel will run the eyetoy cam as a webcam, but to use it under Skype, and to prevent the pink and green horizontal lines, you need to edit the config file. This is tucked away in your home directory:

/home/user/.Skype/skype-user/config.xml

where user is your login, and skype-user is your skype login

If you are the cautious type, back up this file first:

cp /home/user/.Skype/skype-user/config.xml /home/user/.Skype/skype-user/config.xml.bak

Open up the config.xml file in your text editor, and browse down through the file, you should find a <Video>…</Video> section.Add the following:

<CaptureHeight>480</CaptureHeight>
<CaptureWidth>640</CaptureWidth>
<RecvPolicy>callpolicy</RecvPolicy>

Mine looks like this:

…..</StatsSender>
<Video>
<AutoSend>1</AutoSend>
<CaptureHeight>480</CaptureHeight>
<CaptureWidth>640</CaptureWidth>
<Device>/dev/video3</Device>
<Disable>0</Disable>
<RecvPolicy>callpolicy</RecvPolicy>
</Video>
<table_insert_history>….

Start up Skype and head for video settings to select and test.

You can also select the Eyetoy Microphone to use, you may need to play around with your main sound settings to get this working. I had to change from Mic2 to Mic1 in Sound Settings / Mixer, and of course chose eyetoy microphone in audio settings in Skype

GeeXBoX playback at fullscreen on LCD TV

This has been an issue for me for quite a while, but I have simply overcome it by using the menu to change the aspect ratio.

It all stems from the perplexing confusion of recording dvb tv for later playback. Watching live TV on the TV, the picture fills the screen. It’s a 16:9 42″ TV (720p). When I record dvb tv using my main pc in its raw .ts state it is 720×576 (16:9). If I play this back using the GeexBox, mplayer squeezes the picture to a display of something like Cinemascope, so a change of aspect ratio to 4:3 usually sorts this out. But it got me thinking, if the original video is 16:9 why doesn’t play as such? The Pc in use to run GeexBox has an nvidia 6200 and is connected to the TV using VGA (DVI/HDMI went “pop” a while ago on the TV!).

First off, I tried all sorts of encoding options, changing the aspect ratio and resolution using mencoder. I got some success if I encoded with aspect=4/3 as an option. but this still didn’t make sense; if I had a 16:9 aspect ratio TV, why the original video didn’t fit.

This is what I did to sort things out. I have a HDD install of GeexBox so can ftp in to edit files. If you use a live cd, then you will need to edit the files before you generate a custom iso.

Boot up the GeexBox

FTP in, and make doubly sure you get into the right place

/mnt/GeexBox-partition/GEEXBOX/etc

Open up tvout in that directory and change the Aspect Ratio line to this:

TVOUT_ASPECT=”16:9″

and save.
By just making this change alone, it squeezed my display horizontally to make a 4:3 image, so more to do

Browse to /mnt/Geexbox-partition/GEEXBOX/etc/mplayer and open up mplayer.conf
In the [default] section, add the following two lines:

monitoraspect=”16:9″

aspect=”16:9″

and save. It may be worth noting that I have vo=vidix,vesa in the default section of mplayer.conf

Log out of the ftp and reboot the GeexBox. The Main Menu and background.avi should be filling the screen.

Now try playing any recorded dvb tv or video that was previously letterboxed, even though it was 16:9 ratio or 720×576 resolution. You should see it playback in full screen.

Caveats: This may not work in your setup, and you may not need to make all the adjustments to get this to work, this is what worked for me.

ts to avi using projectx and mencoder + ffmpeg

I am feeling pretty pleased with myself tonight, having resolved another issue with my encoding of dvb-t streams to avi.

Having sorted out the crashing problem, I was now having a/v sync issues. This is easy enough to deal with by using the +/- keys to adjust a/v sync with mplayer, but annoying for other users.

I have solved the problem by demuxing the stream to its component video and audio parts, using Projectx, Mencoder and ffmpeg.

Projectx is a great java tool that allows you to crop and cut a dvb or mpeg stream and then output either to a ts/ps/m2p a/v stream or to demux the stream. By demuxing you end up with a video m2v file and an audio mp2 file.

It is easy enough to then encode the video using mencoder, then to use ffmpeg to encode the audio, and finally to use mencoder again to mux the video and audio encodes back together, which gives a perfect a/v sync. I put together a script that will encode all m2v/mp2 collections in a directory, so I can leave it running overnight if I have more than one encode to do. Here it is: Mencoder Batch Mux Script

I am using default mencoder libraries and encoders with a two pass approach, but will give h264 a crack later to see if I get better quality for the time and cpu cycles taken. The current script produces eminently watchable video on my 42″ LCD using GeeXBoX so I’m a happy bunny 🙂

If you get stuck or need help, give me a shout….

[Solved] – Mencoder Freezing Computer (my computer!) or Segmentation Faulting

This has been an annoyance for sometime, when encoding anything with mencoder, but specifically ts files from recorded TV. Mencoder would start off fine and then freeze the PC completely or Seg Fault, not necessarily in the same place. Other PCs I have would encode fine using the same settings.

I found the solution today on the mplayerusers email list. About 18 months ago I had overclocked my machine, up from 1.7 to 1.9 mhz and increased the FSB. Apparently mencoder doesn’t like overclocked PCs, even though the writer with the solution said it wasn’t mencoder’s fault! So I put my settings back to “Optimal” / “Auto”, and everything is now rosy in the garden, just a tad slower than before 🙂 I can live with that!

How to remux an avi with the right audio language track using MPlayer/Mencoder

MPlayer and Mencoder to the rescue again!

I downloaded a movie the other night which was advertised as having both Spanish and English soundtracks. I had found films like this before, but English had always been the first audio track, so had never been a problem. On this occasion, Spanish was the first audio track. I didn’t want to have to fiddle around with Geexbox getting the right language playing, so needed to sort this out, so that English was the audio track that played. I wasn’t too bothered about dropping the Spanish soundtrack.

Four “simple” steps.

  1. Confirm the aid number of the English language track. Running the video with mplayer in verbose mode produced enough information to find this easily, as track 2
    • mplayer -v inputvideo.avi
  2. Extract the english audio track from the avifile
    • mplayer -aid 2 -dumpaudio -dumpfile englishaudio.mp3  inputvideo.avi
  3. Copy the video track out without any sound
    • mencoder -ovc copy -nosound -o soundlessvideo.avi  inputvideo.avi
  4. Stick the soundless video and the English audio track back together
    • mencoder -ovc copy soundlessvideo.avi -oac copy -audiofile englishaudio.mp3  -o newvideo.avi

No encoding or transcoding going on, just demuxing and remuxing of the right parts. Apparently the use of -nosound can cause a/v sync issues, but in this case a/v sync was fine all the way through.

Found another way too, as doing the above with ac3 sound doesn’t sync well at all. Simply re-encode the audio and output to a new file:

mencoder -ovc copy  -oac mp3lame aid 2 inputfile.avi -o outputfile.avi

or to simply grab the second audio stream without encoding

mencoder -ovc copy -oac copy aid 2 inputfile.avi -o outputfile.avi