Posts Tagged ‘ubuntu’

20091102 ffmpeg ERROR: libx264 version must be >= 0.78

Yesterday, I succumbed to the temptation and clicked on the Upgrade button… which means that I upgraded my Ubuntu system to 9.10. And as expected, my own build of ffmpeg got broken because of the way the binary had been built — it was trying to load a library by its exact name and version, and as it couldn’t locate it, boom! end of the story.

So I understood that I had to rebuild the binary so that it could use the latest version of the libraries which had been updated too. But I had the bad idea of running svn update on the ffmpeg sources folder before rebuilding, and as a result, the latest version can’t be built with the version of libx264-dev which comes with Ubuntu 9.10, giving me the ‘libx264 version must be >= 0.78′ error. Booh!

As I didn’t want to mess with installing custom library versions, I have just made a guesstimate of the revision number I used the last time and have gone back to that revision number:

sole@courgette:~/Applications/ffmpeg$ svn update -r 19900

After that, I just followed the very same process that I described a few posts ago.

(The reason why I didn’t just select an specific SVN tag or something is because well, those guys have only the ‘0.5′ tag under the branches directory!)

20091022 dig

I normally go to webs like dnsstuff to find the IP address of a domain. But since I found this command, I think I’ll stop visiting them so often!

An example is worth one thousand words:

sole@courgette:~$ dig google.com

; <<>> DiG 9.5.1-P2 <<>> google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15808
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             239     IN      A       74.125.53.100
google.com.             239     IN      A       74.125.45.100
google.com.             239     IN      A       74.125.67.100

;; Query time: 12 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Thu Oct 22 09:50:01 2009
;; MSG SIZE  rcvd: 76

By default it returns type A DNS records, which are the ones for translating domain names to IP addresses. But you can also ask it to retrieve other record types. For example, for retrieving every record that it can find:

sole@courgette:~$ dig -t ANY google.com

; <<>> DiG 9.5.1-P2 <<>> -t ANY google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15253
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.                    IN      ANY

;; ANSWER SECTION:
google.com.             175     IN      A       74.125.45.100
google.com.             175     IN      A       74.125.67.100
google.com.             175     IN      A       74.125.53.100
google.com.             807     IN      MX      10 google.com.s9a1.psmtp.com.
google.com.             807     IN      MX      10 google.com.s9a2.psmtp.com.
google.com.             807     IN      MX      100 smtp1.google.com.
google.com.             807     IN      MX      10 google.com.s9b1.psmtp.com.
google.com.             807     IN      MX      10 google.com.s9b2.psmtp.com.
google.com.             807     IN      MX      100 smtp2.google.com.
google.com.             171315  IN      NS      ns1.google.com.
google.com.             171315  IN      NS      ns2.google.com.
google.com.             171315  IN      NS      ns3.google.com.
google.com.             171315  IN      NS      ns4.google.com.

;; Query time: 14 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Thu Oct 22 09:51:05 2009
;; MSG SIZE  rcvd: 326

There it shows now the name servers (NS column) and the mail servers (MX column) too.

Go play around with its options and see what you can find. Of course this is very raw and could do with a bit of makeover, but it’s a command line option and there are lots of pages/scripts out there who use dig as its base for a more attractive result. But for what I usually need this is more than enough.

Something to note is that these results are taken from your current DNS cache. I.e. let’s say you’ve changed the DNS values for a domain and want to make sure that the changes have been applied… then do not expect this tool to show instant changes, because the results would still be in your DNS cache. You either reset your router or wait until the cache expires and your query shows the updated results. And of course you also have to wait until the change propagates :)

I didn’t have to install any new package for running this program, I guess it comes by default with ubuntu. But I haven’t investigated it either :D

Happy digging! ;)

20091001 Roll your own ffmpeg build

I like to have my own build of ffmpeg. That way I don’t have to worry about not having this or that codec available. What I do is keep it in my ~/Applications/ffmpeg folder. Some people suggest using a ~/bin directory but I hate to drop every binary into the same place.

Here are the magic lines:

cd ~/Applications

svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg

cd ffmpeg

sudo apt-get install libmp3lame-dev libfaad-dev libfaac-dev\
 libxvidcore4-dev liba52-0.7.4 liba52-0.7.4-dev libx264-dev\
 libtheora-dev libvorbis-dev

./configure --enable-gpl --enable-nonfree --enable-libmp3lame\
--enable-libfaac --enable-libfaad --enable-libtheora \
--enable-libvorbis --enable-libx264 --enable-libxvid

make

Once that finishes, you get an ffmpeg executable in the ~/Applications/ffmpeg folder. So you can explicitly call from your scripts with ~/Applications/ffmpeg/ffmpeg. And because it has a ton of enabled codecs, it’s less problematic to read videos from different sources than it is with the default build which comes with Ubuntu. Or even output videos using codecs such as mp3.

This will probably surely fail in a future version of Ubuntu, but it works as of today. Of course, if the libraries’ names change, you’ll have to adjust as appropriate too. It might also fail if the very svn checkout you do is not compiling properly, but hey! that’s the fun of living in the bleeding edge :-P

20090420 Generate bitmap font: a little plug-in for The Gimp

I made this little plug-in for the Gimp because I needed to generate a fixed-width font bitmap (what I have called a Bitmap Font) to load and use in an application of mine. I then thought that maybe someone would like to learn how to make plug-ins for the Gimp with Python, as I did, so that’s why I’m posting it here.

It turns out to be very simple. Your plug-ins need to be placed in your user’s directory for the Gimp. In my case, that is ~/.gimp-2.6/plug-ins. When the program starts up, it will scan that folder, looking for any possible plug-ins there.

In my case, I decided I wanted to place the plug-in in the File menu, under Create:

File ... Create...

That is done with the register function at the end of the code, amongst other configuration settings for the window that shows up if you select my plug-in:

register(
        "sole_generate_bitmap_font",
        "Generate bitmap font",
        "Generate bitmap font",
        "Soledad Penades",
        "Soledad Penades",
        "2009",
        "<Image>/File/Create/_Generate Bitmap Font",
        "",
        [
                (PF_FONT, "Font", "Font", "04b03"),
                (PF_SPINNER, "Font_Size", "Size", 8, (0, 1000, 1)),
                (PF_RADIO, "orientation", "Orientation", "horizontal",
                        (("_horizontal", "horizontal"), ("_vertical", "vertical"))
                )
        ],
        [],
        sole_generate_bitmap_font)

Generate bitmap font

The plug-in, as it is, offers only few configuration options but if you want more, they can be added very easily. There’s a but: the only thing I couldn’t manage to do is to remove the “Input image” and “Input drawable” options (note they aren’t specified in my code either, it seems they are added automatically).

Once you press ‘OK’, it will create a new document with the selected font. This is an example:
Example bitmap font

Now, that isn’t a fixed width font. When this texture is used for writing texts, it produces text that can be read but feels weird, because that font has not been designed to be used with fixed widths. Anyway, you get the idea. I’m still looking for a fixed width font that I like and find easy to read, so that’s why I’m using this one for the example. It is the classic 04b_03 by 04.

You can take a look at the full source code here and download it here too, directly from the SVN repository. Enjoy it!

20090210 Mac mini as a headless server

Last week our humble home server decided it wouldn’t boot any more, and as I had been postponing the migration to a new home server for too long (around six months I think), it was the moment to really do it. We had been warned several times already: it wouldn’t turn on sometimes. Other times it was just fine. But it all smelt like a power supply unit failure.

So I set out on the task of replacing it with my mac mini (the one I pulled apart back in 2007), since it’s quieter, smaller and will probably use less energy as well.

I installed Ubuntu onto it. It was pain free and done in 20 minutes (including partitioning and formatting). I then enabled the remote desktop service (aka VNC), disconnected the display and keyboard and connected them back to my main machine. Then I continued configuring things and copying data from the previous server using an external enclosure for the hard disks, and it looked pretty much fine…

… until I tried to reboot the mini. It just stayed there, dead. Not responding to pings, not showing in the router, just dead. I wondered if that could be a problem with the firewire disk preventing ubuntu from completing the boot, but it sounded strange to me. I connected again a display and keyboard, rebooted and it worked again, which led me to believe that the mini wouldn’t boot without an attached display (i.e. headless).

Some more sources confirmed my suspicion, and this one had a solution which would trick the mini into believing there is a monitor connected. It involved paying a visit to maplin for buying a male VGA connector and soldering a resistor between pins 2 and 7, which I didn’t really feel like doing since it was 1 AM and even worse, it was cold outside!

I began searching in all our “boxes with cables and connectors” to see if I could find something useful and suddenly the salvation appeared before my eyes:

DVI to VGA

The mac mini’s DVI to VGA adapter!

But the articles and tutorials out there said to use a 75Ω resistor, and the lowest one I had handy was a 220Ω resistor. VGA voltage levels are 0.7V, and the way this hack works is that the computer will assume there’s a monitor connected if there’s some sort of connection between pins 2 and 7, which correspond to green video and green ground respectively. The worst that could happen was that it didn’t detect anything because the resistor ate too much of the 0.7V. So I decided to try this:

VGA trick

I shut down the mini, connected the strange device in place of the display, and turned it on again. After the characteristic mac TAAAAAA chord, I spent some seconds spent with my fingers crossed, and tried to connect via VNC to the mini from another machine. Guess what… it worked!

Afterwards, I covered the resistor with a piece of cellotape to prevent it from making any false contact, should any metallic stuff fall in that area (which shouldn’t happen anyway, but you never know).

And if this looks hacky, just look at the solution of these guys – they directly bridge the DVI pins with the resistor!

Finally, let me tell you this didn’t happen when booting the mini with Mac OS X. It looks like an evil strategy to keep people using Mac OS X – but I couldn’t trust Mac OS X with my home server. Not with its annoying obsession of updating iTunes and Quicktime every other week (approximately), amongst other fine features of Apple’s operating system.