Showing posts with label howto. Show all posts
Showing posts with label howto. Show all posts

Friday, March 7, 2014

How to make Avidemux work under Ubuntu 13.10

Ubuntu 13.10 Saucy Salamander
Avidemux 2.5.4

I was quite disappointed in Ubuntu 13.10, when I first tried it last year. Several apps were broken and many things did not function.

One of those apps was Avidemux, which I am using regularly at home to encode videos. Note that I'm talking about avidemux2-gtk version.

In Ubuntu 13.10, Avidemux would run, but after selecting some menu item which opens a dialogue window and then closing that dialogue would always hang Avidemux.

For example Help / About will open the About window and when you click OK, the window will hang with the button still appearing pressed and after a moment the main window will fade into black-and-white indicating an unresponsive window. Only xkill will help out and put Avidemux out of its misery.


I recently decided to try again. At my workplace I had upgraded to 13.10 a while ago, as I did not need Avidemux in there. A lot of time had passed and I thought perhaps it had been fixed already and Avidemux would now work.

I installed Avidemux and surprise - it worked. No more hangs. But as I had upgraded my machine at work from 13.04 to 13.10, I was not sure as of why it worked. I decided to try it out also in fresh installation into VirtualBox.

I installed a fresh 13.10 64-bit image into a new VM, then, without installing the VirtualBox additions, upgraded the packages and then installed Avidemux. The result - it hung, like before.

I started to look for differences between the two machines. Into my work machine, I had installed a mainline 3.12 kernel - maybe that was the solution? Nope, that did not help, the Avidemux in VirtualBox would still hang.

Then I noticed that the Avidemux in my main machine was displaying its menus inside the window, and not in the global menu bar. I also noticed, that gnome-terminal, for example, was also displaying its menus inside the main window, so I ran dpkg --get-selections|sort in both machines and compared the selections. And there was the answer - my main machine was missing the following packages:

unity-gtk2-module
unity-gtk3-module
unity-gtk-module-common

I removed these packages from my VirtualMachine installation and confirmed that Avidemux would no longer hang. Problem solved.

Tuesday, May 25, 2010

How to remove higher version packages installed from another source in Ubuntu.

Ubuntu 10.04 Lucid Lynx
Linux Mint 9 Isadora

I am currently torn between plain Ubuntu 10.04 Lucid Lynx and Linux Mint 9 Isadora. Previously I have had both Linux Mint 7 Gloria and Linux Mint 8 Helena installed and liked them a lot. The main attraction for me is the MintMenu.

The last one was actually Ubuntu 9.10 with Linux Mint 8 repository set up and the packages from there installed over the Ubuntu packages. The reason for this was technical - I decided to try and set up RAID 0 array with my dual 750GB hard drives and unfortunately only Ubuntu had the so called alternate install available needed to install on RAID while the normal installer in Linux Mint 8 did not recognize this, even if it had been previously created.

Ubuntu 10.04 has made some considerable improvements in many areas over the previous version:
  • My SB Audigy 2 ZS card works fine now even with the 5.1 setup switched on.
  • The 3D desktop with my Radeon HD3870 works also out of the box (though it still recommends the ATI driver, but I have decided not to install it, see the next one for why).
  • The LCD display powerdown works now (saving the backlight) with the automatic Mesa DRI R600 driver.
    Previously the ATI driver broke this LCD powerdown leaving the backlight on and I'm afraid it is still not fixed.
  • The CD/DVD automatic mounting works now with correct volume labels appearing in /media instead of using the cdrom0, cdrom1 and cdrom2 directories previously (yes, I have three drives).
    The volume label automatic creation worked also in prior Ubuntu version but this functionality disappeared mysteriously after I installed Linux Mint packages over Ubuntu ones.
  • The switching between text-mode and graphics is almost instantaneous - I wonder if the kernel graphics mode swithcing is already supported with ATI graphics or is this just very good MESA driver...?
  • The resolution of the text-mode is perfect using the whole 1920x1200 screen with 240x75 characters!
    Previously in Linux Mint 8 or perhaps instead because of the ATI driver, the text-mode was an awful 80x25 and switching back messed up the graphics mode aswell...

After trying out the newly released Linux Mint 9 I felt that it looked and worked very similarly to the previous Linux Mint 8 while the Ubuntu 10.04 was considerable jump forward from 9.10 and therefore I decided to do similar configuration as before (though I'm not using RAID this time) to install Ubuntu 10.04 and then include the MintMenu from the Linux Mint 9 repositories.

What happened, unfortunately, is that I accidentally installed a lot of Linux Mint packages including grub and plymouth related things that affect the booting. I decided to remove these packages but alas, this seemed to be impossible without complete reinstall.
Most of the packages depended on others that depended finally on nearly all of the packages (the list was in hundreds of packages).
While each of these packages had counterpart in Lucid repositories, they all outranked the Lucid ones with higher version numbers.

The apt-get does not provide any way to downgrade nor to use different repository for reinstallation, the dpkg can reinstall any version, including downgrading to an earlier versions, but needs physical .deb files.

The answer was the forgotten aptitude package manager, which has somewhat similar syntax and with simple tasks can be used in place of apt-get, while having considerably more power.

And here is the step-by-step list of how I reverted these packages back to their Lucid Lynx counterpars:
  1. First, in order to know which packages I need to switch back to Ubuntu versions, I listed those packages with dpkg:

    sudo dpkg --list | grep mint

  2. Second, I downloaded the physical .deb files from lucid repository:

    aptitude -t lucid download libplymouth2 plymouth plymouth-label plymouth-theme-ubuntu-logo plymouth-theme-ubuntu-text plymouth-x11 python-software-properties software-properties-gtk

  3. Third, I installed these versions with dpkg:

    sudo dpkg --install *.deb

That's it.

Sunday, November 15, 2009

Quick howto: 32bit Firefox 2 within 64bit openSUSE 11.1

openSUSE 11.1

I am currently in the process of creating myself my very own openSUSE distribution using the excellent SUSE Studio.

As I've written previously, I am still using the old Firefox 2, which allows me to integrate with the KDE's excellent kprinter, something that was killed in the Firefox 3 branch.
Trying the distribution with VirtualBox I stumbled upon a problem with the Firefox 2 which I have actually seen previously. This 32bit Firefox 2 is unable to connect to any website when run from 64bit openSUSE 11.1 (probably in other versions as well).

The solution, however, is an easy one. The openSUSE is remarkably different from for example Ubuntu, as they actually include the 32bit environment out of the box in 64bit systems. This means that some 32bit versions of the various libraries are automatically installed. However, the distribution maintainers in openSUSE have, for some unknown reason, left out one of the necessary 32bit libraries: nss-mdns-32bit. Install this and the 32bit Firefox 2 works!

Saturday, September 26, 2009

Gnome with Compiz and disabling Focus Prevention

Linux Mint 7 "Gloria"

One thing I've always hated about new Gnome after switching from openSuse and KDE is the focus prevention. I'm doing Flex development with Eclipse and whenever I run my application, a Firefox window is opened with the Flex compiled Flash file inside. The Compiz focus prevention, however, makes sure that the Firefox window is opened in the background. Also any and all Flash error dialogs (from the debug Flash player) appear only as the flashing taskbar button. It is ridiculous that I need to click on them to bring them forward.

Notoriously, neither Gnome nor Compiz ever mention the Focus Prevention in their setups. KDE 3.5 allowed the focus prevention settings in great detail to be modified via the KDE control center. Now, however, I've dug a bit deeper and I've found a rather simple solution to the problem.

It seems that all the hidden features are still present in Gnome and accessible via an app called gconf-editor. Just search for "prevention" in there (be sure to check the "Search also in key names" checkbox) and you should find a few matches.

Go to the key /apps/compiz/general/screen0/options/focus_prevention_level and change that value to zero to turn off the focus prevention. It's that simple!

Sunday, September 20, 2009

How to make MPlayer from SVN work with Compiz?

Linux Mint 7 "Gloria"

One of the bigger problems when enabling Compiz for all these fancy UI tricks is the sad fact that video display will become, depending on which video output method your video player uses, either flashy, very slow or just totally unusable.

The root cause for this comes from the video output method. Those video output devices that render the graphics directly to the graphics card usually create a lot of flickering, since they effectively overwrite the rendered 3D graphics which in turn then overwrite the video window. The other video output methods think they render into a window become slow, since compiz will then have to copy the window contents to a 3D texture to be rendered by the video card.

With the Ubuntu 9.04 or (in my case) Linux Mint 7 "Gloria" x64 Edition the graphics driver installation is almost too trivial. At my workplace, with the ATI's Radeon X1650 card, the DRI R300 driver was installed automatically and effects were enabled out of the box with Gloria. At home I have ATI's Radeon HD3870 in which case I only had to confirm the installation of ATI's own Linux Catalyst drivers. The 3D effects along with full Compiz Fusion was already installed and ready to be swithced on.

But now became the real problem, how to make sure that watching video would still be possible with Compiz being active? I had heard a long time ago, at the dawn of Compiz, that there was one video player, which was patched to work with Compiz... I searched for it and was glad to find out that the player in question was MPlayer which is what I've always used in the past.

Since the patch is meant to modify source code, I had compile a patched version of MPlayer.

The compilation, however, blew up with some errors. The first error came from a module called IVTV... whatever that was I did not know. I simply disabled it with --disable-ivtv switch for ./configure script. The web told that there was a patch also to fix this, but I didn't care about that. The next error came from the x264 module which is a far worse thing, as this is one of the cornerstones of free MPEG-4 video. The web tells that this incompatibility of MPlayer 1.0rc2 and x264 is based on the fact that the aformentioned MPlayer source is outdated and does not support the much evolved current x264 version anymore. The only solution would be to compile the newest version of MPlayer, which currently is only available via an anonymous Subversion repository.

And here is the catch -- how to enable the fast Compiz video, yet keep x264 support also? The Compiz video patch is for the old MPlayer source, while the newer source supports the new x264?

I decided that the fortune favors the bold and tried to see if the patch could in any way be adopted to the new MPlayer source. The file in question is libvo/vo_xv.c. Of course there were numerous differences between the old and new versions of this file and this level of C code is well beyond my understanding (I generally dislike C).

Then I decided that it's worth a try to include the patched old vo_xv.c file with the rest of the new source code taken from Subversion. I expected it to blow up at ./configure script right away - it did not. I expected it to at least bail out with errors at compilation - it did not. It surely will crash once run - it does not. It works!

Since the following sources do a superb job at explaining at detail what packages you need to install, how to patch the file and how to compile the MPlayer, I will not copy their explanations, but merely add some remarks:
  • A post in Ubuntu forums describing the original 1.0rc2 patching and compilation. Note that the patch file is no longer available from the link in that post (see below).

  • A post in SmSpillaz with similar contents, but with a working link to the patch file. You can of course always use your friend Google to find alternate links to this file.

  • An MPlayer download page with details how to download the new MPlayer from Subversion.
All you need to do really, is follow the first post up to the point of patching the original libvo/vo_xv.c file, back up the patched file, download the SVN version of MPlayer, copy the patched old file into libvo directory of the new source code overwriting the SVN version and follow the rest of the configuration, compilation and installation instructions from the first post but now within the new source code directory.

There's only one more glitch which needs to be rooted out. The fullscreen mode of MPlayer uses different screen mode which does not work anymore (reliably anyway). The solution is to turn off the special fullscreen mode by setting the property fstype=none. The only downside is that the Gnome panels remain visible that way.

Wednesday, June 3, 2009

A better way to stop ComboBox from resizing itself automatically...

Adobe Flex 3

This is an update to my earlier post about mx:ComboBox which, if set to a percentage width, will by default always take the width of the widest line it contains, widening possibly its container and/or changing the container to be scrollable.

The solution I suggested earlier was not enough for example in case the ComboBox was on a panel which was not visible when it was created. Now I am using a different solution.

Basically you extend the ComboBox and override the protected measure() method to cancel out the setting of minimum width set by the original code which is the cause the ComboBox will force its width upon its container.

The following code has some more changes, like resizing the dropdown list to the width of the longest line it will display and also refusing even programmatic focusing when either disabled or hidden.

Did you know, that if the focus already is on the standard ComboBox, then disabling or even hiding it does not block the keyboard input? For example, the [Down] and [Up] keys still change the items within the invisible ComboBox with all the corresponding events triggering, and [CTRL-Down] will still open the dropdown list even though the ComboBox itself is hidden and disabled?

public class ComboBoxEx extends ComboBox
{
private var initDone:Boolean;
public var preferredDropdownWidth:Number;

public function ComboBoxEx()
{
super();
this.preferredDropdownWidth = NaN;
this.initDone = false;

this.addEventListener("dropdownWidthChanged",
function(event:Event):void { if (!initDone) preferredDropdownWidth = event.target.dropdownWidth; });

this.addEventListener(FlexEvent.INITIALIZE,
function(event:Event):void { initDone = true; });

}

/** A property indicating if the combobox should resize itself to the width of its contents */
[Inspectable(category="General", enumeration="true,false", defaultValue="false")]
public var resizeWidthToContent:Boolean = false;

/**
* A property indicating if the dropdown of the combobox should resize its width to the width of the longest
* label within the combobox'es data, though never below the width of the combobox itself.
* NOTE! that if you leave this property to its default value of true then the property dropdownWidth
* will not be respected if it happens to be smaller than the width of the longest label in the combobox.
*/

[Inspectable(category="General, enumeration="true,false", defaultValue="false")]
public var resizeDropdownWidthToContent:Boolean = true;

/**
* @private
*/

override protected function keyDownHandler(event:KeyboardEvent):void
{
// Handle keyboard only if we are enabled and visible!
if (super.enabled && super.visible)
super.keyDownHandler(event);
}

/**
* @private
*/

override public function setFocus():void
{
// Take focus only if we are enabled and visible!
if (super.enabled && super.visible)
super.setFocus();
}

/**
* The super method determines the measuredWidth and measuredHeight
* properties of the control.
* This version will reset the measuredWidth property to the value of
* UIComponent.DEFAULT_MEASURED_WIDTH unless the resizeWidthToContent
* property is set.
* @see mx.core.ComboBase#measure()
*/

override protected function measure():void
{
super.measure();
if (!this.resizeWidthToContent) measuredMinWidth = DEFAULT_MEASURED_MIN_WIDTH;
}

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (this.resizeDropdownWidthToContent && isNaN(this.preferredDropdownWidth))
{
var width:Number = getContentMaxWidth().width + getStyle("arrowButtonWidth");
this.dropdownWidth = Math.max(this.width, width);
}
}

public function getContentMaxWidth():Object
{
return calculatePreferredSizeFromData(this.collection.length);
}

}

I also opened a bug about it.

Monday, May 25, 2009

How to make KPrinter work with Firefox 3?

openSUSE 11.1

In the recent past there have been several new software updates and upgrades which have almost infuriated me and forced me to revert to using old versions. The top two of these new things are:
  1. Firefox 3 which cannot be persuaded to use kprinter anymore the way Firefox 2 was persuaded.

  2. KDE 4 and its applications which totally and absolutely ignore the KDE 3 configuration with no apparent way to migrate the configuration either. Fortunately openSUSE still carries KDE 3.5 which I'm using currently.

The first of these items, however, is solved now, and here are the steps I took to make kprinter work with Firefox 3 (inspired by a post from this thread):
  1. The first step is to edit the file /etc/gtk-2.0/gtkrc and add the following line to the end:
    gtk-print-backends = "lpr,file"

    This will make the lpr target appear in the Firefox 3 print dialog.

  2. The second step is to switch the lpr command for kprinter command by executing:
    cd ~/bin
    ln -s `which kprinter` lpr

  3. And the third and final step is to get rid of the Firefox 3 print dialog by opening the URL about:config and creating there the following new Boolean option:
    print.always_print_silent = true

And that's it - Firefox 3 now prints directly to kprinter.

NB! The only quirk I've found is that you cannot cancel the kprinter dialog - or it will hang Firefox 3 for some reason.

EDIT: After some testing, however, this way of printing seems to be very buggy - most pictures do not print at all and those that do end up on the printed page are heavily compressed with visible compression artifacts, the text is uneven and looks ugly.
It seems that the LPR printing uses the lowest possible resolution with no known way to fix this higher.

I've switched back to Firefox 2.0.0.20 for now until the Firefox 3 will play nice within KDE!

Wednesday, January 21, 2009

How to stop ComboBox from resizing itself automatically...

Adobe Flex 3

One of the many grievances I have with the otherwise wonderful Adobe Flex is the way the ComboBox component with percentage width resizes itself to accommodate the data which is loaded into it. There seems to be no switch to disable this behavior and yet retain the scalability of the ComboBox control itself.

The problem manifests itself best when you have, for example, two adjacent ComboBox widgets both set to be 50% width and you assign to the first a list of rows with short names and to the other a list of rows with long names - both widgets will resize themselves to a different width to accommodate their respective contents.

After searching for and failing to find a solution to this, I decided to try and write a workaround myself. I needed to fixate the width of the comboboxes right after they were first displayed and before they got their data. There was no need for the combobox to be resized later. In order to do this, I extended the original ComboBox and added the following code to it:

First I added a property via which you can turn on or off the new functionality:
/**
* Property indicating if the initially measured width of the combobox will be
* fixed as soon as the combobox has been layed out.
* Only applies to combobox'es which have their width specified as a percentage.
*/

[Inspectable(category="General", enumeration="true,false", defaultValue="false")]
public var fixPercentWidthAfterInitialMeasurement:Boolean = false;

Second, to the constructor of the combobox, I added an event listener:
public function AComboBox()
{
super();
this.addEventListener(FlexEvent.UPDATE_COMPLETE, handleUpdateComplete);
}

Finally, I added the event handler method:
/**
* This eventhandler is called right before the widget is drawn on screen - it's size has already been calculated,
* but it has not yet received its contents, therefore now it is good time to convert its percentage width into
* an explicit width, so that future data loaded into the combobox would not resize the compobox causing scrolling.
*/

private function handleUpdateComplete(event:FlexEvent):void
{
if (this.fixPercentWidthAfterInitialMeasurement &&
(!isNaN(this.percentWidth))) this.explicitWidth = this.width;
}

The idea here is to capture the event which is dispatched after the ComboBox size has been determined, right before the combobox is drawn on screen. Each ComboBox can have its width specified either explicitly in pixels or as a percentage of the containers width. When the width of the ComboBox is set as a percentage, I now assign its actual pixel width to the explicitWidth property. This will fixate the width and also stop the ComboBox from automatically resizing itself.

That solved the situation for me - the ComboBox retained its size after the initial layout.