Tuesday, May 20, 2008
32-bit MPlayer on 64-bit Linux, again
Almost exactly one year ago, I published here an essay on building 32-bit mplayer on 64-bit RHE Linux (took me a lot of time when, actually). Reading this over a year later, I can hardly understand how I really managed to do it and how the process worked; it must have been some magic which mplayer configuration did. Anyway, here is much more straightforward and comprehensive approach on building not just mplayer, but whole 32-bit Linux (sub-) system within existing 64-bit OS. It is based on Ubuntu 8.04 "Hardy Heron" , but should work with small modifications on any Debian-based system.
The following largely based on this forum post, which in turn references this tutorial. I will assume that code name of your release is "hardy" and 32-bit root is "/sys32"; make sure to replace with values suitable for your system.
- sudo apt-get install dchroot debootstrap
- sudo mkdir /sys32/
- sudo vi /etc/dchroot.conf
- Add this line: hardy /sys32
- sudo debootstrap --arch i386 hardy /sys32/ http://archive.ubuntu.com/ubuntu
- sudo cp /etc/{passwd,shadow,group,sudoers,hosts} /sys32/etc/
- sudo cp /etc/apt/sources.list /sys32/etc/apt/sources.list
(At this moment you might want to edit your sources.list file to your taste, or remove from there things that are specific to 64-bit system, not that there should be any)
Now comes some controversial step. Full-blown debian installation could take gigabytes of disk space, and only small piece of that is binary data which is different for 32-bit. You can reduce the required disk space by "sharing" certain folders with architecture-independent data between the main system and sub-system, but that has also a site-effect of making certain actions in the sub-system break how things work in your main system. Forum post that I referenced above recommend you share /usr/share/fonts this way, but I decided against it; it costs me about 200Mb more, but adds certain piece of mind. Some directories though are worth sharing.
- sudo vi /etc/fstab
- Add the following lines:
- /home /chroot/home none bind 0 0
- /tmp /chroot/tmp none bind 0 0
- /dev /chroot/dev none bind 0 0
- /proc /chroot/proc proc defaults 0 0
- /media/cdrom0 /chroot/media/cdrom0 none bind 0 0
- sudo mkdir /chroot/media/cdrom0
- sudo mount -a
OK, by now you should have a basic Debian-style 32-bit system under /sys32; this command
- sudo chroot /sys32/
would switch you to operate from "within" this sub-system. From this point on, we continue setup from within (note that "chroot" automatically puts us into root-privileged shell, so "sudo" isn't needed)
- locale-gen "en_US.UTF-8"
- dpkg-reconfigure locales
- apt-get update
- apt-get upgrade
- apt-get install libgtk2.0-dev gcc g++ make
The last command is just an example; feel free to install whatever you feel like you need, including software built from source, or anything else. MPlayer, among other things, could be built this way without any problems.
Note that when installing from source, it may be useful to do everything but the last installation step from your regular user account, like that:
- [Download all source you might want]
- sudo chroot /sys32/
- su - your_user_account
- cd /tmp
- tar -xvzf your_sources.tag.gz
- cd your_sources
- ./configure
- make
- make test
- exit
- cd /tmp/your_sources
- make install
One last remark: you can install some 32-bit support as part of your 64-bit system, including compiler and run-time libraries (you can't however get build libraries and headers other than building them yourself following steps similar to outlined above). Here it is:
- apt-get install build-essential lib32gcc1 libc6-dev-i386 libc6-i386 lib32stdc++6 ia32-libs gcc-multilib
This makes it possible to run gmplayer as /sys32/usr/local/bin/gmplayer, without any change in environment or any dependencies on the 32-bit subsystem.
Labels: 64-bit, debian, mplayer
Monday, December 17, 2007
Russian subtitles in mplayer
After a few attempts, I successfully made Russian subtitles to work correctly in mplayer. Here how it works:
- Download Cyrillic bitmap fonts from mplayer site (there are other collections there that might work as well);
- Unpack anywhere you want;
- Edit font.desc file, removing references to non-existing font files;
- Download (for instance, from here) or prepare subtitles (I used .srt file) in Windows (1251) encoding;
- Run mplayer like that:
gmplayer -font <full path to font.desc> -sub <full path to .srt file> ... - Don't forger that mplayer saves its options in ~/.mplayer directory and re-uses them by default, so on your next invocation either use your "default" parameter like -font /usr/local32/share/mplayer/font/font.desc, or remove relevant files from ~/.mplayer .
Friday, September 14, 2007
Copy DVD
Well, the next best thing after using gmplayer is copying (protected) DVDs. Number of good utilities exist under Windows, e.g. free DVD Decrypter and non-free but very good Magic DVD Ripper. Here we will cover what is available under Linux.
First, very good review, and only slightly outdated, is available in Gentoo Wiki. In fact, from all the tools mentioned there I only tried the simplest one: dvdbackup.
Here is what to do:
- Install libdvdcss ;
- Install libdvdread . Run configure command like that: ./configure --with-libdvdcss-libs=/usr/local/lib
- Get dvdbackup;
- Goto "src" subdirectory;
- (optional) Consider applying this patch;
- Compile dvdbackup like that: gcc -I/usr/local/include dvdbackup.c -o dvdbackup /usr/local/lib/libdvdread.a /usr/local/lib/libdvdcss.a -ldl (Note: linking libdvdread.so does not work for some reason, but feel free to use libdvdcss.so)
- Copy dvdbackup to /usr/local/bin or whatever
- Use like that:
(to copy DVD)
dvdbackup -v 4 -M -i /media/cdrecorder -o ~/mytopdir -n my_name
(to get info)
dvdbackup -i /media/cdrecorder -I
gmplayer dvd://1 -dvd-device ~/mytopdir/my_name
Friday, May 18, 2007
Compiling MPlayer on linux-amd64
I now have a new desktop computer (DELL Precision Workstation 390n, RH Enterprise 4) and already spent a few days setting it up in various ways. Most of the time, it has been straightforward, but setting up MPlayer was much less than trivial.
Here is an overview of the main steps required to install it (MPlayer 1.0rc1-4.1.1 © 2000-2006)
1. 64-bit vs. 32-bit problems
(This section will not apply to you if your OS is 32-bit)
MPlayer must be compiled in 32-bit mode since it invokes proprietary Windows codecs and therefore some basic 32-bit environment must be available.- Make sure gcc -m32 can be used to compile 32-bit programs (you might also want to setup gcc4, see below; note that you will not need C++ support, plain gcc will suffice);
- Create special new directory for 32-bit stuff, e.g. /usr/local32, set your $PATH and $LD_LIBRARY_PATH accordingly;
- Install 32-bit version of libpng library, by setting export CFLAGS="-m32 -O2" and executing ./configure --prefix="/usr/local32";
- Now you need 32-bit version of gtk-2 libraries. You can compile them from scratch, but in my case I only had to setup symbolic links (in /usr/local32/lib): libatk-1.0.so -> /usr/lib/libatk-1.0.so.0 libgdk_pixbuf-2.0.so -> /usr/lib/libgdk_pixbuf-2.0.so.0 libgdk-x11-2.0.so -> /usr/lib/libgdk-x11-2.0.so.0 libglib-2.0.so -> /usr/lib/libglib-2.0.so.0 libgmodule-2.0.so -> /usr/lib/libgmodule-2.0.so.0 libgobject-2.0.so -> /usr/lib/libgobject-2.0.so.0 libgtk-x11-2.0.so -> /usr/lib/libgtk-x11-2.0.so.0 libpango-1.0.so -> /usr/lib/libpango-1.0.so.0 libpangox-1.0.so -> /usr/lib/libpangox-1.0.so.0 libpangoxft-1.0.so -> /usr/lib/libpangoxft-1.0.so.0
- Download appropriate "Binary Codec Packages", e.g. "essential" and "win32codecs" from http://www.mplayerhq.hu/MPlayer/releases/codecs/ , and install them under /usr/local32/lib/codecs;
- Download "Skins" (at least one) from main download page http://www.mplayerhq.hu/design7/dload.html, and install under /usr/local32/share/mplayer/skins, and make symbolic link "default" to default skin, e.g. default -> Blue
- Download one bitmap font from here and install per documentation, which is to say, unpack it under /usr/local32/share/mplayer and make symbolic link "font": /usr/local32/share/mplayer/font -> font-arial-14-iso-8859-1
- Install a true type font in directory ~/.mplayer and make a symbolic link subfont.ttf, e.g: ~/.mplayer/subfont.ttf -> tahoma.ttf
- unset CFLAGS (or open a new shell); otherwise, you will disregard special compilation flags used by mplayer;
- configure with the command: ./configure --enable-gui --cc='gcc4 -m32' --target=i386-linux --with-extraincdir=/usr/local32/include --with-extralibdir=/usr/local32/lib --prefix="/usr/local32" (using gcc4 is nor relevant to the crash, but was helpful with some other problems which appeared with gcc3. Versions used: gcc3 = 3.4.6, gcc4 = 4.1.1)
- in a separate directory, configure as above but with additional option --enable-debug. and compile only one object: libvo/sub.o (you can run make to compile everything, there is no harm)
- Copy libvo/sub.o from 2-nd directory to the 1-st and re-build MPlayer in the 1-st directory;
- Now execute "make install" in the 1-st directory (with appropriate permissions) and enjoy!
- Standard mplayer help suggests to use Command Line Option -slang to select subtitles, e.g. -slang en. In fact, for some reason this is not very reliable. It is in fact much more convenient to use option -sid
. This way, trying sequentially -sid 0, -sid 1, -sid 2, ... you will find what you need. E.g., most often this is what you'd use to play DVD: gmplayer -sid 0 -fs dvd://1 - Perhaps it is worth looking at new project Democracy (to be renamed to Miro), which is a multi-platform universal media player, implemented in Python and using Pyrex, xine and some other packages.
Labels: 64-bit, mplayer, redhat
