Thursday, January 19, 2012

The best way to capture, record any sound playback in Oneiric Ubuntu Linux

The best means what the sound architecture designed to be used.  It's lossless - the same digital signal goes to your speaker and to the file.

Any means what you hear is what you get (WYHIWYG).  All you need is any sound card or USB device so you can hear anything.

The problem of Ubuntu forums is that the information isn't update and the obsolete post pull you into it like a magnet. 

In Oneiric, the sound architecture is ALSA and the sound server is Pulseaudio.  I have no clue what it means, but simple things become complicated and many info are obsolete.

Oneiric is bundled with the command pavucontrol, and it has no manual page for it, brilliant.  You can find PulseAudio Volume Control in the dash, or just enter the command in a terminal. It has GUI.  It's not just volume control, but master control of everything.

Now you need to play some sound.  Play a movie file or play a youtube video, with sound of course.  In the Input Device tab of pavucontrol, you should choose to show "monitors" at the bottom.  For each output device, you have a corresponding monitor device as the input that you can record.  Is that simple?  You should see the volume meter moving up and down.

Now you need some recording software.  The only thing that works for me is Audacity.  It's good for many thing else.  You can install it via the Ubuntu software center.  Fire up audacity.  There's typically nothing to set, or it doesn't matter that much.  Just in case, you need to set the 4 selector right above the sound wave area to ALSA, default, default, stereo.  You have to start recording with the red button or nothing will happen.

Now go back to pavucontrol.  At the record tab, you should see the application Audacity.  You just need to set the capture selector to "monitor of whatever sound device you are playing back".  And that is one of the monitors at the Input Device tab.

The settings will be remembered on a per application basis. (I think.)  So you can set the default sound device and settings for each application.  And because of this, without any configurations, it always give me the wrong device during playback.

Thursday, January 5, 2012

Create launcher / shortcut for applications in Ubuntu Oneiric

Everybody have their little scripts for automating anything.  It used to be very easy to create launchers or shortcuts for launching applications in Ubuntu.  It make very little difference if the app is installed software packages or your own little script.  You just right click on the desktop and create a launcher.  You can even move the launcher into your desktop panels for quick launch.

Not anymore.  Ubuntu Oneiric took it all away.  It's still there, and very easy to use.  But it was so simple and transparent that I didn't know the details before.

Basically instead of creating launcher on the desktop, you need to run from a terminal:

#gnome-desktop-item-edit --create-new ~/Desktop

It's the same as before, when you want to create a launcher on your Desktop.  Give it a name, the path to the application or your script, it's done.  Typically for scripts you check the item "it's application in terminals".  Optionally you can change the icon by clicking on it.

You can drag your launcher icon on the desktop into the unity bar to keep it there always.

You can create a script for the above command, create a launcher for it.  So you never need to type the command again.  (It doesn't work without putting it in a script first.)

Basically a launcher is a simple nameXX.desktop text file anywhere.  From the desktop GUI you see this as a launcher.  Inside is just the name of the app, path of application or script, and path of icon.

Sometimes you can't move the launcher icon into the unity bar for various reasons.  Sometimes it turns into a black block in there.  There may be some legacy problems.  There is an icon path where the icons are to be searched.  This include ~/.icons  If your script have the same name with one of the icons, the icon will be automatically loaded, which may not be your intention.  Etc, etc.

Monday, January 2, 2012

Unsolved problem: Playing HD video 720p 1080p on Linux netbooks such as AO722

Netbooks means weak CPU.  Linux means no hardware video acceleration because of open source drivers or incomplete proprietary drivers.  This is the case for Acer Aspire One 722.  Because 720p can fit in the screen, so in theory it's a lot easier than rescaling the 1080p into full screen.

The bundled Movie Player (Totem) doesn't play anything HD, so I thought the AO722 is useless for video.  I used another player and even 1080p can play smoothly with out of sync sound.

I spent some time investigating because, if you are given a HD video, you want to be able to view on the netbook without recoding the whole movie into 480p, which can take hours I think.

The core component of a media player is the codecs.  All the players use more or less the same, such as FFmeg.  The problem is these things have license restrictions, making it a nightmare to distribute.  So often you are not using the best and fastest codecs.  These codecs are available as plugins to overcome the license restrictions.

On the next level there's the video backend, or engine.  There are basically 4, gstreamer, mplayer, vlc, xine.  Gstreamer has a few plugins doing similar things.  Mplayer has different branches.  Xine is basically fading away but still has updates.

There are one to many GUI frontends for each engine.  The default ubuntu, gnome player is Movie Player, which is actually called totem, use gstreamer.  There is the Gnome-mplayer, and smplayer for the mplayer backend.  There's also the mplayer-gui and mplayer can be used in the command line.  Similarly there are a few xine gui's.  The company Videolan makes both the frontend and backend of VLC and not used by any others.

Movie Player (Totem) and VLC don't play any HD on AO722 in any meaningful way by default.  Mplayer and xine plays even 1080p smoothly.  But I can't find ways to sync the audio because the video is lacking far behind.

In a faster but old machine, I discovered that only VLC can sync the audio, in the expense of some noticeable artifacts on the video.

On the AO722, I discovered that I can tweak the preferences to get a lower quality video but with perfect sync of HD 1080p (>900p) such as the Bourne Ultimatum demo clip.  Try low quality, skip frames, etc.

I concluded that you can watch HD on AO722 smoothly, with compromise in quality.  The problem is how to configure the player.

Totem/Gstreamer is most comprehensive.  I can't believe that I couldn't find out how to install and use the ffmpeg plugins, for example.  Not in the official website nor the ubuntu forums.  At least not in the form I understand. 

You should be able to configure a lot of things for mplayer (and xine), but the problem is too many options.  There's no tutorial for crippling the player for slow machines.

I manage to tweak the VLC options to play HD with perfect sync.  But some 1080p are more consuming that others.  So it's not a complete solution.

Video for the browser is another story.  HD on youtube is mostly mp4.  It's better to use a video player to play youtube videos, mp4 or not, than using the crippled flash implementation.  The VLC browser plugin doesn't work.  That left us with the Gnome-player plugin.  Disable other plugins and use FlashVideoReplacer extension for Firefox and you can play youtube videos just like flash, but only on  youtube and a few other sites.  You can play 720p with perfect sync, but not any higher.  That's not a problem because youtube always give you different resolutions from 240 up to 1080p.