[APPLE TV] XBMC on Apple TV (720p) H.264 video bit-rates?
#1
Question 
I absolutely adore the form factor and design of the Apple TV. I'm very excited to see XBMC for the Apple TV.

Unfortunately, XBMC doesn't utilize the hardware acceleration for decoding videos and this is why it can't handle high bitrate video (I still don't know what the limit actually is with XBMC).

This chart shows resolutions and bit rate of content found in iTunes. I've been using this as the basis for my own video library.

Image

How well would XBMC on the Apple TV play this content?
Reply
#2
berdelyi Wrote:I absolutely adore the form factor and design of the Apple TV. I'm very excited to see XBMC for the Apple TV.

Unfortunately, XBMC doesn't utilize the hardware acceleration for decoding videos and this is why it can't handle high bitrate video (I still don't know what the limit actually is with XBMC).

This chart shows resolutions and bit rate of content found in iTunes. I've been using this as the basis for my own video library.

Image

How well would XBMC on the Apple TV play this content?

I have no problem playing any 720p Apple content. Lower resolution is a piece of cake Wink Seems to be fine up into the 5-6Mbit rates for 720p content encoded in a similar flavor of h.264 encoding. I guess you would call it standard h.264.

But remember that there are several flavors of h.264 that offer different compression routines, some require more cpu than others. In addition, the ffmpeg version used in XBMC is not recent and there have been numerous improvements regarding h.264 that will help if future versions of XBMC.
Reply
#3
So, XBMC on the Apple TV can handle 720p (1280x720) up to 4 Mbps (using h.264)? From Apple's website, the max bit rate for the device is 720p @ 5 Mbps.

I'm encoding DVD content using Handbrake (on my Mac) and haven't done HD content yet.

Now it may depend on the h.264 codec used to to encode the video?

I see a great future for XBMC on the Apple TV if it can handle 720p (1280x720) @ 4 Mbps.
Reply
#4
berdelyi Wrote:So, XBMC on the Apple TV can handle 720p (1280x720) up to 4 Mbps (using h.264)? From Apple's website, the max bit rate for the device is 720p @ 5 Mbps.

I'm encoding DVD content using Handbrake (on my Mac) and haven't done HD content yet.

Now it may depend on the h.264 codec used to to encode the video?

I see a great future for XBMC on the Apple TV if it can handle 720p (1280x720) @ 4 Mbps.

Remember that max bit rates from Apple's web site regarding the AppleTV are what Apple says are allowed to be decoded using quicktime.

XBMC does not use quicktime but uses ffmpeg. From what I've seen, XBMC can handle slightly higher bit-rates that what Apple quotes.

Be careful lumping h.264 into one set of bit-rate definitions. It's much more complicated than that. See -> http://en.wikipedia.org/wiki/H.264
Reply
#5
My primary gripe about the Apple TV has been lack of DivX support. Yeah, I've used patchstick and installed Perian but then I had to use the ATV Fooler script to encapsulate the DivX file so it could be imported into iTunes and later synced.

I've since gone back to using a non patched Apple TV and now encoding my content to H.264. I like managing my content in iTunes.

However, I'm very excited about XBMC for the Apple TV and have to create another patchstick and give it a try.
Reply
#6
Something to assist in installing XBMC for Mac on the AppleTV will pop out soon. Still in development.

Another nice feature of XBMC for Mac on the AppleTV is an SMB client is build inside XBMC so you don't need to do any SMB hacks Wink
Reply
#7
Hey everybody,

My two cents regarding the bitrate et al. I have alot of 720p movies in high profile which will make the ATV vomit. I always reencode my movies to a setting that works really nice for me. The ATV supports H.264 main profile and if I'm not mistaken, main profile allows for peaks pf up to 14 MBps. In theory. I reencode using ffmpeg @ around 5500 kbps with a max rate of 6500 into a MPEG-4 container. It works like a friggin charm. Higher rates may work - I have used a peak of 7500 without problems. I'm sure you can go higher, but you really won't see any difference IMHO.

For those interested, I made a small bash script that converts the movie in question. The FFMPEG command in it is as follows;

ffmpeg -y -i INPUTMOVIE.mkv -threads 4 -s 1280x720 -aspect 1280:720 -r ntsc-film -vcodec libx264 -g 150 -qmin 8 -b 5500k -level 31 -loop 1 -sc_threshold 40 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 2 -qmax 51 -maxrate 6500k -bf 1 -keyint_min 40 -async 50 -acodec libfaac -ar 48000 -ac 2 -ab 128k OUTPUTMOVIE.mp4

Please adjust the size setting - alot of movies are 1280x544 etc. Also, see if your source is PAL or NTSC and change the "-r" accordingly. The command line is the same one that the Mac app VisualHub uses - with some small tweaks. Try it out at let me knwo how it works out for you! Also, the sound bitrate is set to 128 in this example. 160 kbps will work aswell. Maybe 192, but I've had some problems with that setting.

Cheers.
Reply
#8
oh, and if you want to use the bash script, here it is (copy pasted from a now forgotten source in the interwebs and then tweaked - sorry)

Code:
#!/bin/sh

### Transcode 720p H264 mkv files for the Apple TV

if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" -a -n "$5" ]
then

        # Get the beginning time from the date cmd.
        START=$(date)
        # ffmpeg cmd

        ffmpeg -y -i $1 -threads 4 -s 1280x$3 -aspect 1280:$3 -vcodec libx264 -g 150 \
        -qmin 8 -b $4k -level 31 -loop 1 -sc_threshold 40 \
        -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 2 -qmax 51 \
        -maxrate $5k -bf 1 -keyint_min 40 -async 50 \
        -acodec libfaac -ar 48000 -ac 2 -ab 128k $2

        # Get the ending time of the transcode process from the date cmd.
        END=$(date)

        # Log it. Perhaps mail it?
        echo "Transcoding of $1 was started on $START and completed on $END." > convertlog.txt

else

        echo "Usage: ./convert sourcefile destfile height_of_movie bitrate max_bitrate"
fi


Another ti if you SSh into a comp. that executes the script - use screen and execute it there.. that way you donät have to have your SSH open while converting.
Reply
#9
swedishchef Wrote:oh, and if you want to use the bash script, here it is (copy pasted from a now forgotten source in the interwebs and then tweaked - sorry)

Code:
#!/bin/sh

### Transcode 720p H264 mkv files for the Apple TV

if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" -a -n "$5" ]
then

        # Get the beginning time from the date cmd.
        START=$(date)
        # ffmpeg cmd

        ffmpeg -y -i $1 -threads 4 -s 1280x$3 -aspect 1280:$3 -vcodec libx264 -g 150 \
        -qmin 8 -b $4k -level 31 -loop 1 -sc_threshold 40 \
        -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 2 -qmax 51 \
        -maxrate $5k -bf 1 -keyint_min 40 -async 50 \
        -acodec libfaac -ar 48000 -ac 2 -ab 128k $2

        # Get the ending time of the transcode process from the date cmd.
        END=$(date)

        # Log it. Perhaps mail it?
        echo "Transcoding of $1 was started on $START and completed on $END." > convertlog.txt

else

        echo "Usage: ./convert sourcefile destfile height_of_movie bitrate max_bitrate"
fi


Another ti if you SSh into a comp. that executes the script - use screen and execute it there.. that way you donät have to have your SSH open while converting.

Two things:

1) How long would it take to do this conversion using the appletv hardware? This would be nice, since I wouldn't like to consume my CPU power with this kind of conversion that takes a long time. Maybe having this done automatically with ATV idle time?

2) Most matroska come with a RAW h264 that is under 6mb. That video file can be extracted directly and played properly on atv (i've tested several). In that case, you only need to reencode the audio, which is a LOT faster. I haven't seem a good tool for that yet, at least for Macs (there is one for windows). There are several console tools that you can use to extract video and do it manually, but it's just too much work. Something like a visualhub (which is dead now) using a smart script to detect bitrate and use the RAW h264 without reencoding when compatible with atv, would be awesome.
Reply
#10
To change the MKV container to TS without re-encoding the h.264 I use a tool called tsMuxer. This tool normaly runs on Windows, but I use Darwine to run in on OS X. It is very fast, around 2 minutes for a 1 GB MKV file.

The resulting TS file plays fine on Apple TV. Also I noticed that when the container is MKV and audio track is DTS, the DTS does not play.
The same movie in a TS container will play DTS on the Apple TV.

Now if the H.264 is high-profile even ina TS container the ATV cannot play it correctly. So I guess the bitrate has to be reduced to 5500 kbps.
I have not tried tsMuxer yet to do this, but looks like it is much faster than the other tool I tried (visual hub, handbrake) even running in Darwine.
Reply
#11
It's not just the bit rate, it's the profile level as well. XBMC uses straight CPU power to decode h.264 streams so it's going to be jerkier than the Quicktime decoding done by the AppleTV. Unfortunately there is like this strange voodoo surrounding what exactly the AppleTV considers an acceptable h.264 stream. We've tried demuxing the streams and hacking the raw h264 to say that it's main profile instead of high profile but..... that tricky apple knows it can't play it and won't even show it in the video list.

As for XBMC, it shows the file but the FPS suffers greatly. The prospect for using the GPU ala Quicktime is dismal as it's not open source and it would have to be reverse engineered. I'm not saying it's impossible, as a matter of fact if anyone can do it, it's probably the brilliant people that work on this project.

I've been everywhere however looking for a way to avoid the overnight re-encodes using ffmpeg or visualhub.
Reply
#12
nobleach Wrote:It's not just the bit rate, it's the profile level as well. XBMC uses straight CPU power to decode h.264 streams so it's going to be jerkier than the Quicktime decoding done by the AppleTV. Unfortunately there is like this strange voodoo surrounding what exactly the AppleTV considers an acceptable h.264 stream. We've tried demuxing the streams and hacking the raw h264 to say that it's main profile instead of high profile but..... that tricky apple knows it can't play it and won't even show it in the video list.

As for XBMC, it shows the file but the FPS suffers greatly. The prospect for using the GPU ala Quicktime is dismal as it's not open source and it would have to be reverse engineered. I'm not saying it's impossible, as a matter of fact if anyone can do it, it's probably the brilliant people that work on this project.

I've been everywhere however looking for a way to avoid the overnight re-encodes using ffmpeg or visualhub.

I am pretty sure that the AppleTV implementation of Quicktime makes no use of GPU hardware to accelerate h264 decoding.

But I do think it is a little faster than XBMC.

The new "brick" Macbooks *do* utilize GPU decoding.

C.
Reply
#13
Carniphage Wrote:I am pretty sure that the AppleTV implementation of Quicktime makes no use of GPU hardware to accelerate h264 decoding.

Quicktime does use the GPU for h264. Not as much as it could but the differences between XBMC using cpu only and Quicktime on the exact same content are too large to be just coding optimization differences. That is unless ffmpeg really sucks eggs in decoding h264 Smile
Reply
#14
Hi,

Can anyone help me :
I have some downloaded movies as 720p h264 ac3 5.1

How should i set up (handbrake for example) the conversion so Apple TV can play it well ?

Is the setting below ok?
With 5000 kpbs and 5.1, the Apple TV will play fine ?

Image
Reply
#15
davilla Wrote:Quicktime does use the GPU for h264. Not as much as it could but the differences between XBMC using cpu only and Quicktime on the exact same content are too large to be just coding optimization differences. That is unless ffmpeg really sucks eggs in decoding h264 Smile

But didn't you once say?....

"Regarding Perian, not true. While FrontRow does have lower CPU percentages on the same 720p video content, any use of the GPU for h.264 decode would result in a substantial decrease in CPU usage. Much, much more than I have seen. The Apple h.264 software decoder is just much more efficient that ffmpeg. While ffmpeg does use hand coded asm routines for decode, the big gains comes when the entire decode algorithm is done in asm and not in mixed asm/C. The hops through C are a killer in making something in asm run really fast."

C.
Reply

Logout Mark Read Team Forum Stats Members Help
[APPLE TV] XBMC on Apple TV (720p) H.264 video bit-rates?3