Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Disclaimer: This is not an actual question, but rather "share your knowledge, Q&A-style"

So, I'm running Xbmc on my Raspberry Pi and I'm having trouble understanding what I can actually play with it and what not.

I read the RPi can play H.264 encoded videos, but I can only find x264 encoded videos. Will that work, too? And if so, why won't some files work probably?

share|improve this question
up vote 35 down vote accepted

There seems to be a lot of misunderstanding around what H.264 (with a dot) actually is. So, quoting from Wikipedia:

H.264/MPEG-4 Part 10 or AVC (Advanced Video Coding) is a standard for video compression, and is currently one of the most commonly used formats [...]

The important part to stretch here is that it's only a standard. That means, videos are not actually encoded with H.264, but with a codec that meets the H.264 standard. One of the most common ones is x264 (lower-case x, no dot):

x264 is a free software library for encoding video streams into the H.264/MPEG-4 AVC format.
x264 implements a large number of features compared to other H.264 encoders.

So, H.264 is kind of an Interface and x264 is an Implementation (with the actual functionality) of that interface.

So, the Pi will play x264 encoded files just fine.

Then why do some x264 encoded files not play smoothly but stop every 4-6 seconds (depending on the amount of GPU-Ram)?

Most of the time, it's the sound. Since x264 is an encoder for HD video files, most of those files come with a digital high-quality sound-track, which uses the DTS-codec.

The Pi is (at the moment) not able to hardware-decode the DTS-track and it's CPU is not powerful enough. There is a discussion about this on the official Forums which is worth looking into.

To find out if this is the case for you, you can use the mediainfo-tool (must be installed, package-names depend on your distro):

[tv@raspberry]$ mediainfo some_random_movie.mkv 
# Shortened output!
Audio #2
ID                                       : 3
Format                                   : DTS
Format/Info                              : Digital Theater Systems
Codec ID                                 : A_DTS

You now have two options:

  1. Buy a DTS-capable receiver (maybe your TV can do it, too?) and enable "pass-through" (last point) in Xbmc (or whatever player you're using).
  2. Convert the DTS-Tracks to AC3, which can be passed through (faster) or CPU decoded.

To find out what your receiver (the thing you plugged your HDMI-cable in) is capable of, use the tvservice-tool (which is not in the PATH, so you'll need the full path):

[tv@raspberry ~]$ /opt/vc/bin/tvservice -a
     PCM supported: Max channels: 2, Max samplerate:  48kHz, Max samplesize 24 bits.
     AC3 supported: Max channels: 6, Max samplerate:  48kHz, Max rate  640 kb/s.

As you can see, my current receiver is capable of decoding PCM and AC3 (not DTS).

My solution to this problem is to convert the Audio-Tracks which are DTS to AC3. Here is a small one-liner that converts all audio-streams in infile.mkv to AC3 and doesn't touch the video:


ffmpeg -i infile.mkv -map 0 -codec:v copy -codec:s copy -codec:a ac3 outfile.mkv


avconv -i infile.mkv -map 0 -vcodec copy -acodec ac3 -ab 256k outfile.mkv

Note: The above command also sets the bit-rate for the resulting AC3 encoded audio-stream (which is necessary, it seems). While 256kbps is reasonably good (most DVD's use 192kbps), you might want to in/decrease it.

Luckily, this takes only around 5 minutes (depending on your hardware, of course). As a little bonus, your file becomes smaller and if you're not an Audiophile, you won't hear a difference.

Still, 1080p FullHD Movies are stuttering, the screen goes black for a few seconds with no sound but the video-playback seems to continue. The Movie is H.264 encoded in an MKV container with AC3 tracks. What is the problem?

Most likely, there is nothing wrong with the movie-file, but with your Xbmc settings. In my case, the problem was the "refresh rate" of Xbmc. This is set to 60Hz by default. For 720p and any other small video files, this seems to not be a problem for the Pi, but 1080p files result in the above problem.

Lower the refresh-rate to something less than 60Hz (at least 24Hz are sufficient for Movies). There are two options here:

  1. Global Xbmc (including Xbmc itself): System -> Settings -> System -> Video output -> Refresh rate
  2. Movies only (determined by video-file): System -> Settings -> Video -> Playback -> Adjust display refresh rate to match video

After lowering the refresh rate, 1080p movies should also play just fine.

share|improve this answer
Very possibly the best answer on RaspberryPi.stackexchange.com. – Vincent P Jan 29 '13 at 4:52
Oh also I see that ffmpeg is even available for the RPI. sudo apt-get install ffmpeg. Have you tried this on the RPI? Does it work well? – Vincent P Jan 29 '13 at 4:55
@Raphael no, it's not: stackoverflow.com/a/9477756/717341 – Lukas Knuth Mar 15 '13 at 11:49
@Raphael it depends on your distro. In ArchLinux, I don't see this problem. – Lukas Knuth Mar 15 '13 at 11:53
@LukasKnuth good answer except ffmpeg is not deprected. avconv is a fork. – aergistal Sep 19 '15 at 20:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.