Multimedia in Fedora 7: II – Totem

September 8, 2007

Some introduction words

In previous post we talked a little about the theory behind playing media, now we will finally do the first practical step – we will get multimedia to work in the default multimedia player – totem. Just remember that this how-to is meant primarily for Gnome users, KDE users will use different multimedia player and most likely different libraries.

Despite general opinion, totem can play nearly everything and even though it is meant mainly for playing movies, it can handle music pretty well too. However the default installation can play pretty nothing. Why? Short answer is software patents. The longer one is that due to existence of software patents in the U.S. and their appliance on the most used codecs it is nearly impossible to ship those legally with Fedora. There are pretty good alternatives to those codecs, but these are not so widely spread – vorbis (sometimes called ogg vorbis or, wrongly, ogg) for audio, theora for video and ogg and matroska containers. These work out of box in fedora, but not everything you have is encoded with those. So how get to work the rest?

Software patents?

There’s one question which needs to be answered first. Does your country recognises software patents, or is it software patents free? If it has software patents you are in quite a bad position. The only legal way for you is to buy the codecs from the fluendo company. Thanks to them you can legally use most of the codecs in Linux as well. You can buy them at their web shop. One good thing is, that mp3′s are free (as in beer). Somewhat questionable is libdvdcss library for playing DVDs encrypted with CSS (most of those you buy in a shop). If you are sure it’s legal for you to use it, you will find a description how to get it in some of the next paragraphs.

GStreamer solution

If you come from the lucky countries where software patents does not legally exist you have a choice of using free codecs (both as in beer and as in freedom). Totem’s default engine used for playing videos and music is gstreamer and it also provides plug-ins with which you can play nearly everything. They can be installed from the livna software repository. WARNING!!!! If you use freshrpms don’t mix it with livna, it causes a lot of problems. All the packages I’ll be talking about are available in freshrpms too, but their names might slightly differ.

To install the livna software repository, download the livna-release package and install it. You can do that in terminal via rpm (rpm -Uhv /path/to/livna-release-7.rpm), where the ‘/path/to’ stands for the location you downloaded the package to. Alternative solution is to open the package with ‘Software Installer’. It should be available as a choice if you right-click on the downloaded package in nautilus. Next thing is to install all the packages you might need. So first, we will need to install packages with codecs.

So, open terminal and do the following two commands:

su -
yum -y install gstreamer-plugins-ugly \
gstreamer-plugins-bad gstreamer-ffmpeg

It will install all the needed packages (note that you’ll need to be connected to internet in order to download and install them with this easy way) and you can start playing your favourite songs and movies in totem. You’ll find it at Applications -> Sound & Video -> Movie Player.

Xine-lib solution

An alternative solution is to use xine-lib as backend to totem. You’ll need to uninstall totem first:

yum remove totem totem-mozplugin totem-plparser \
totem-devel

Be sure to write down all the packages that will be uninstalled as a dependency so that you can install them back after you install the xine based totem. Next step is to install the xine library and plug-ins that enable its support for the patented codecs. You should also install the libraries for playing DVDs. You will do that with simple yum command (you’ll again need the livna repository):

su -
yum -y install xine-lib-extras-nonfree xine-lib-extras

Next step is to install the xine based totem:

su -
yum -y install totem-xine-plparser totem-xine

More support, similar for all solutions

In order to play DVD video you’ll need some more packages. You can install them with a simple yum command, but note that the legality of use of libdvdcss is somewhat questionable so if you are not sure it is legal in your country to use it, omit it from the list. Here are the commands:

su -
yum -y install libdvdplay libdvdnav libdvdread libdvdcss

Last, optional, step is to enable the plug-in for gecko based browsers that totem provides. If you installed the xine based version, substitute totem-xine-mozplugin instead of totem-mozplugin. So this is the yum command for gstreamer based totem:

su -
yum -y install totem-mozplugin

and for xine based totem:

su -
yum -y install totem-xine-mozplugin

Some ‘final’ words

And the only thing left is to enjoy the media :-)

Today we described how to play media with the Fedora default Gnome Media Player, next time we’ll focus on playing and organising music, with all the stuff we like – id3v2 tag, mp3, flac, ogg vorbis and Linux music players.

Applications Science Echo Icon

August 30, 2007

After a whole day spent (well, actually, it was not a whole day…) with creating an Echo icon for Applications Science I finally created a 48×48 variant, smaller sizes hopefully will be faster, but that I leave for tommorow. What’s so long on this? Shortly, everything. Now the long variant. I wanted to use same shape that is used by the gnome icon theme:

applications-science gnome 32x32 icon

but that has some issues. Firstly, I need to create an isometric perspective icon and in case of bulbs it proved harder than usual, but that was actually one of the easiest thing on this icon. Next, the bulbs are created from glass. Gee, I don’t recall any Echo icon using glass as a material. Actually, glass is one of the hardest materials to visualise, it is both transparent and reflective… So, the question was, how to make an echo-styled glass. After some tries I came to a conclusion that I’ll use the Metalic colours (quite common for echo icons) and use mask for transparency setting (because the lightning gradient has highlight on different position than transparency gradient).

That has one drawback I discovered too late. It seems an inkscape bug, but as I has rawhide installed I sought for a workaround. The problem is that inkscape on all tries exported the png with white background instead of transparent! And workaround? Open in gimp and save there. But it has another problem – the shadows are a little offset. This is however rather easy to work around. Just let gimp render the svg bigger and then down scale it. You will loose nothing from the quality and will have nice more than 8x antialiasing…

Ok, so the bulbs I draw with semitransparent back sides in metalic colours and for front sides I used simple white transparent gradient. Actually I came to conclusion to do it this way after playing with a real light bulb for about a five minutes…

Now how about the liquid inside. Looking at a bottle with watter I though it would be solid, with a highlight where its surface touches the bulb. Actually I added one more highlight to the surface, reflecting the lightning which comes from the top. Because the liquid is below the front side of the bulb the gradient from glass nicely changes the visual style of the liquid inside as well.

The last things are shadows. That was one of the easier parts. Just drop shadow on ground and on other bulbs and I am set. And here is the 48×48 result (more sizes will come probably tommorow):

applications-science echo 48x48 icon

UPDATE: As I expected the optimizations for smaller sizes took far less time. The 16×16 icon is edited directly from relevant gnome icon. Here is the complete set:

applications science 16x16applications science 22x22applications science 24x24applications science 32x32applications science 48x48

Working on Nodoka Theme IV.

August 10, 2007

Well, it has been some time since I last blogged. It was mostly due to vacationing. Now I am back and will provide you with the news on the Nodoka theme. So, the last version so far is 0.5.3, Daniel is working on some code improvements and we are heading to first stable version’s (0.6) first beta (0.5.90). The current look is more or less final. I hope you will all enjoy it. Its now in development repo, so you can install it with a simple yum command.

yum --enablerepo=development install nodoka-theme-gnome

or if you already have it installed substitute the ‘install’ for ‘update’.

Also, for those intereted in hacking/sources, I moved the sources temporarily to my fedorapeople page and reqested resources for fedora hosted. So far only gitnodoka group for git access was created, Jess is too busy with rawhide.

Working on Nodoka Theme III.

July 20, 2007

A lot of things happened since my last post concerning the Nodoka theme. First of all I hacked a little on the engine and the buttons, editboxes, radiobuttons, checkbuttons and progress bars have now more or less final look and work good. I also submited a package reviews for the theme and a feature reqest. On yesterdays FESCO the Nodoka Theme was discused and it was agreed that if Art Team is OK with it it will be moved to CategoryApprovedFedora8. Yay, seems that Fedora will finaly have it’s own theme.

So, how’s it currently look:

Nodoka 0.3.2.1 Preview

GEdit plugins

July 13, 2007

Well, today I discovered great thing – gedit plugins. As a default in Fedora they are mostly turned off, but I couldn’t resist and most of them I turned on, as they seems to be really usable. To list a few there are external tools (so that you can run from gedit whatever command you want, e.g. run make in the directory you are in), modelines (really cool. It can replace all tabs with spaces. Nice for spec files. Also it allows automatic indentation), snippets (really makes coding faster), file browser pane and tag list (really really cool thing for XHTML/CSS).

And from “notepad” you can make and developers lair:

GEdit - Developers Lair

About linux there is one good thing. You can learn something new even when using an application you thought you knew throughoutly…

EDIT: I’ve just found, that the plugins I discovered is just only the beginning of a bigger world. There tons of plugins available gedit, see
GEdit-Plugins. Some of them are also available in fedora, install the package gedit-plugins and you’ll see ;-)

Working on Nodoka Theme II.

July 12, 2007

Daniel today posted the sources of Nodoka Engine so Nodoka is making progress. I quickly made new rpms both of the Nodoka theme and the Nodoka engine and made some changes to the engine. You can download the current version on the Nodoka Theme wiki page.

I tried to do all the changes as additions, so the old murrine styles can be used, while the nodoka style is slightly different. You can notice that I removed the glassy style – so all the widgets has now soft gradients only. I also made the gradient more noticeable in progress bar and menu items. Shadows are however still missing and frames and notebook widgets processing were not updated as well. I hope we will make it looks mostly how the design is mockuped at the latest before Test 2. Also I hope to include the rpms in Fedora repository in Test 1.

Nodoka Theme Preview

Any comments, feedback, patches, etc. are more than welcome.

Multimedia in Fedora 7: I. – A Bit of Theory

July 11, 2007

Introduction

Multimedia was always considered an issue in GNU/Linux, especially in Fedora which is based on FOSS which is freely redistributable and thus cannot include codecs for various patented multimedia formats like mp3. This series of blogpost is meant to address the issues of playing and making various multimedia under Fedora 7.

It’s always good to start with theory behind. Let’s say you want to play a video you obtained somewhere. How can you do that? How can you check what is needed? How is it actually made? Look at this diagram:

video file content

You see there that video file is first processed by splitter, which must know the container format in which is the file stored. Then it is splitted into three (but possibly more or less) streams and each stream is processed by itself. So audio is decoded by audio decoder (if available) and sent to audio device, video is decoded by video decoder (if available) and sent to video device and subtitles can be either added by video decoder (most players do this) or processed by special rendering library (e.g. libass) which sends it to video device for displaying.

Encoding is done much similar. First you encode the video and audio streams with appropriate coders prepare subtitle streams in desired format and then mix them together with mixer which makes the final output file stored in desired container. Let’s have a closer look on these parts.

Containers

Containers are used to store audio and video data streams in files. If you cannot handle the container, you cannot play the video inside either. So the first thing you’ll look for when trying to play a video is whether your software can handle the container or not.

Containers can be exclusive to audio (like WAV) or can be more flexible and contain audio, video, subtitles, and some of them even more. Some of the most extensively used containers nowadays are AVI, Matroska, Ogg and OGM.

But you can ask: why there are so many of them? What are the differences? Which one I should use for my videos? Well, it’s not easy to answer these questions. There are containers that are meant to work only with specific range of codecs (and thus could be optimised specially for the data inside), like MP4 which is can contain only MPEG-4 videos, and there are so much flexible containers that you can store almost everything in it ranging from audio,video and subtitles to fonts, like Matroska. There are formats suitable for playing locally stored files, like AVI, and there are formats designed for internet streaming, like FLV (flash video).

So your choice would depend most likely on what do you want it for. But as you will most probably encode videos for storing on a HDD or CD/DVD you will most probably choose between AVI, OGM and Matroska for video. For audio you usually do not need to care of these things, as most audio formats have their file formats included, so if you play mp3, you have mp3 container, if you want FLAC, you have FLAC container, however if you want vorbis, you will most likely find it in Ogg container.

Now, what are the pros and cons of AVI, OGM and Matroska? Which one you should choose? Well if you look only for features, quality and speed you’ll chose Matroska. OGM is, well, quite aside of main interest, it has some advantages compared to AVI, and is open source, but cannot beat Matroska. So if you want everyone to play the file, without installing any additional software (on Windows), you’ll chose AVI, since every Windows release capable of playing videos can read AVI files. The rest of cases is handled by Matroska. Simply said, it’s better, it’s faster and it’s open.

And what’s so good about Matroska? You can do almost everything with it. You can attach as many video/audio streams as you want, the same with subtitles, you can attach fonts, you can define aspect ratio for a movie, so it can be anamorphic. Support for anamorphic videos is vital if you’d like to rip DVDs. Most of wide screen DVDs are encoded so that if you displayed it pixel on pixel you would get deformed video. That’s because you can store the same amount of data in wide-screen movie as in classical 4:3 movie, while keeping the vertical resolution same.

But if you want to rip it, you need to decide – encode it wide-screened or leave it anamorphic? If you want it anamorphic, the container must support it – and matroska does. If you decide to encode it wide-screened you will loose quality – you must resize it, either to make vertical resolution bigger, keeping the horizontal same, or making it smaller, keeping the vertical resolution same. The first approach leads to double resizing (when you play the movie, it is usually resized again to fit in the screen) and bigger size, the second leads to loss of detail. So it’s better to use Matroska and leave it anamorphic.

Some of the other advantages of Matroska are that it supports DVD like menus, is designed on streaming as well, you can set chapters, it’s designed to be stream-able over the internet, has high error recovery, etc.

If you are interested you can read about the most common containers on the wikipedia on Container format page or look at the Comparison of container formats on the same site.

Audio Formats

Now, if your have a support for the container, you need and audio codec to play the audio inside (or to encode the audio). The most common audio formats are mp3, vorbis, FLAC, WAV and wma. We can divide them further into lossy (mp3, vorbis, wma) and loss-less (FLAC, WAV, wma). The lossy codecs use special algorithms to decide what you can’t hear and cut it of the audio, so you loose some data, but most of the people should not notice it, unless encoded with very low bit-rates (i.e. how many bit [eight bits is one byte] are needed to store one second of the audio).

If you want to play mp3 audio you have quite wide choice in case of codecs. Probably the best choice is lame mp3 encoder. MP3 is good choice because nearly everyone can play it. It’s playable on modern CD players, car radios, mobile phones, PCs, etc. MP3 is bad choice, because it has bad quality compared to some more modern formats like vorbis. If you want mp3 and decent quality you should not go under 128 kbps (kilobits per second), good choice is 192 kbps with VBR (variable bit-rate).

For wma the situation is worse, because it’s completely closed and patented format. If you use Linux those will be one of the most hard to play. Quality is good, but most of the files available on internet are encoded using such low bit-rates that artifacts are more than noticeable. Some people says that it’s like hearing the music through casserole. But it is better than mp3 at same bit-rates. WMA can also be compressed in loss-less mode – than the quality is same as of the original.

The best choice for Linux users (and not only them ;-) ) in lossy formats is vorbis. The quality is similar or better than of most of the other lossy audio formats available, it’s open source and it’s included on most Linux distributions by default. Windows users however would need to install the codec manually and most CD/flash players don’t support it.

For loss-less compression the situation is easier. WAV is used for tens of years already and is never a bad choice. FLAC, however, support sample rate up to about 1 MHz and usually reduces file size to about one half the size of WAV. Also it is open source. So under Linux FLAC is certainly a better choice, WAV can be used only for compatibility reasons because it’s bigger and can be of worse quality.

If you wish to read more of audio compression, you can find it on the wikipedia on Audio compression page. Comparison of audio codecs is available on the wikipedia as well.

Video Formats

And now, we are at last at the part which is most confusing – video formats. Why? Well, can you tell what’s the difference between DivX and XviD? Do you know that XviD and DivX coded videos use the same format? Do you know that video codec and video format is not the same? Do you know what FourCC is? And many other questions.

So let’s start with some basics: video formats are specifications. They say how one device sends video to the other, OR in case of digital media it says how the video in a file is stored. The basic two analog video formats are PAL (used in the Europe) and NTSC (used in the U.S.). The difference is in fps (frames per second) and resolution. PAL videos are 625-line/50 Hz, however on the TV only 576 lines are displayed. Fifty Hz means that it displays fifty fields in a second. The video is interleaved, so the fields are half-frames, and it gives 25 fps. NTSC videos are 525-line/60 Hz, however only 480 lines are displayed on the TV. NTSC videos are interleaved and has 60000:1001 fields per second, which gives 30000:1001 frames per second.

Digital formats can be e.g. HDTV (1024p, i.e. 1024 lines, progressive) or compression specifications. Probably to most commonly used nowadays are MPEG-4 ASP, MPEG-4 AVC, RealVideo, Theora and WMV. You will probably know WMV – it’s default windows video format and is not very portable and RealVideo, in which many televisions have their internet broadcast. MPEG-4 ASP is known as DivX or XviD, MPEG-4 AVC is know as H.264 and Theora is open video format.

But formats are only specifications, to play/encode the video you need a video codec (COder and DECoder). The most widely spread nowadays are DivX, XviD, WMA and RealVideo, but ffmpeg and x264 are gaining their share as well. DivX and XviD are mostly the same, as they implement the same standard (MPEG-4 ASP), the difference is in power – i.e. how fast it can encode using the same quality setting. In past there was also a difference in how much of the standard was implemented, but now the standard is implemented more or less completely in both. The main problem is that FourCC used in description of a film which should be used to describe format is used to describe codec and that could confuse many video players resulting in failing to play DivX encoded video with XviD decoder and vice-versa, complaining that decoder is missing.

Here, the best choice is ffmpeg, because it’s set to associate itself with all videos it can actually decode, so it can be used instead of DivX or XviD decoders and many others. But, MPEG-4 ASP is quite old standard and is being continually replaced with newer MPEG-4 AVC. The probably most know codec implementing this standard is x264. The standard itself is patented, however x264 codec is open-source and has one of the best implementations of this standard so far. The H.264 specification, as it is also known, is the best lossy compression available, but it’s also slower. So if you’d like to HD video encoded in H.264 it will most probably have same or at least similar quality compared to original, but you’ll need a very fast machine. However, for DVD rips it’s playable on most of computers, and has the best quality to size ratio you can get.

WMV and RealVideo are a little bit different. They are used mostly for internet streams, quality usually isn’t much high – but that’s due to high compression. WMV has a great disadvantage that make it to on a OS different than windows is usually hard, RealVideo is similar same for the fact that you can use RealPlayer. But I myself have rather bad experience with RealPlayer on Fedora.

So if you want to play videos you will play most of them with ffmpeg codec, if you want to encode the best choice is in most cases H.264. Theora is a possibility and it’s completely open, however it’s rather slow and has worse quality than H.264.

For more info you can go to wikipedia to Video codec page or Comparison of video codecs.

Subtitles

Well, what to say here… There are three basic types of subtitles: hard, prerendered and soft. Hard subtitles are encoded in the movie itself and thus cannot be turned of. Usually not a good choice. Prerendered subtitles are separate video frames which are during playing overlaid on the original video. They usually lack anti-aliasing and are not very used. Soft subs are the most common ones. They’re usually a text file which contains timings, positions, styling, etc. and the subtitles themselves. It can be separate or included in the file with the video. Some of the advantages are that they can be anti-aliased, can be turned off, they’re style can be changed, they can be latter edited&hellip.

Some of the most commons soft subtitles formats are SUB, SRT SSF, ASS, … In my opinion the best ones are ASS subtitles. They can be styled, they can move inside the picture, you can do with them mostly the same you could do with hardsubs, while maintaining a small size and leaving the ability to later edit them or turn them off during the movie.

More info about subtitles is on wikipedia on page Subtitles.

Conclusion

If you are playing a file, try to find one that uses an open container (in Linux it’s certainly and advantage), has a good quality and uses formats that can be played on Linux. That means that if you get matroska file with H.264 and AAC/AC3 or vorbis audio you are happy. OGM and AVI containers are worse, but possible. Also the rest of MPEG formats family (ranging from mpeg-1 through mp3 to DivX) is usually well supported. If you rely on official fedora repositories, you must however restrict yourself to matroska/OGM, theora and vorbis/FLAC. Maybe I’ve forgotten something, but this is certainly most reliable.

If you’re going to encode, decide whether you want quality at all costs, whether you want only open technologies, or whether you want as much portability as possible. If you depend on quality than combination of Matroska, H.264 and AAC/AC3 or vorbis is the best you can have for video and FLAC is the best you can get for audio. If need open technologies, than use the same as for playing. If you want interoperability, you’ll need to choose something widely supported – that means AVI, MPEG-4 ASP, mp3. Another possibility are WMV and WMA formats – but only if your target group are people with Windows.

Next time I will start with something more interesting – i.e. how to make playing of movies and songs in Fedora 7 work.

Working on Nodoka Theme I.

July 10, 2007

Well, as you might noticed one of the first releases of Nodoka theme for Metacity and GTK was released. You can get it at the Nodoka wiki. It’s intended to become a Fedora default theme in the future. Currently it’s based on Murrine engine, but it’s not the final stage. The look is going to be even better. Daniel Geiger forked the Murrine engine and is going to adjust it to the Nodoka needs. I am looking forward when he publishes the sources.

So let’s compare the default look of Fedora 7 and Fedora 8 if Nodoka would be included.

Fedora 7:
Fedora 7 default desktop

Fedora 7 default widgets

Fedora 8 (with Nodoka, Echo, and Fedora Moon theme [from Mola Pahnadayan]):
Fedora 8 default desktop (proposed)

Fedora 8 default widgets (proposed)

Note that regarding Fedora 8 nearly all presented here are sketches and might not be included in final, or might look different. However, I hope that the Nodoka theme and the Echo icons we will make in time.

Hello world!

July 10, 2007

Hello world! I am starting blogging in English. I hope you will like it. It will be mostly about Fedora.


Follow

Get every new post delivered to your Inbox.