Showing posts with label mpeg2. Show all posts
Showing posts with label mpeg2. Show all posts

Saturday, September 14, 2013

Intel Hardware Video Decoding on Linux! VDPAU, VA-API, and Flash!

My laptop has a Core 2 Duo 2.4ghz CPU with an integrated Intel video chipset (GM45). It plays flash fine, but I wondered if I could get some HW decoding like the ATI. Here goes:

Intel supports va-api, not vdpau (required by flash) I'm running Arch on my laptop, so it may require some modifications to use on other distros (or it may not work at all).

Requirements

  • xf86-video-intel
  • libva
  • libvdpau
  • libva-intel-driver (only does mpeg2)
  • libvdpau-va-gl

Optional

  • libva-driver-intel-g45-h264 - replaces libva-intel-driver (in the AUR, it does h.264 on specific chipsets, but may be worse than software decoding)
  • vainfo
  • vdpauinfo

Setup

After the required software is installed "vainfo" should return the supported decoders. vdpauinfo will return an error. Create a file (as root) /etc/profile.d/vdpau_vaapi.sh containing:

#!/bin/sh
export VDPAU_DRIVER=va_gl

Save and add execute permissions (chmod +x vdpau_vaapi.sh). Log off and back on or execute the export command above and vdpauinfo should return the supported codecs. Then modify /etc/adobe/mms.cfg and uncomment or add 

EnableLinuxHWVideoDecode=1

Next in chrome://flags enable 

Override software rendering list

Now it should work!

Notes:

  1. This works with flashplugin (11.2). I haven't played with it much, but it doesn't seem to work with pepper-flash (11.8). It has lower cpu usage than 11.2 with EnableLinuxHWVideoDecode commented out in /etc/adobe/mms.cfg, but uncommenting it has no effect. Either it's looking somewhere else for that config or it doesn't support it. 11.2 drops way below 11.8 with it enabled.
  2. Obviously different chipsets support different codecs, some may not support any at all. The VA-API Wiki page linked below has some info to that end.
  3. The Chrome flag may improve overall performance or it may break things / slow things down. you'll have to try it and see.
  4. You can check chrome://flash and chrome://gpu before and after to see what changes.

Links

Thursday, September 12, 2013

ATI Hardware Video Decoding on Linux! VDPAU, VA-API, and Flash!

XKCD - Supported Features
I love that XKCD. Anyway, I built a HTPC / home server around a Biostar Deluxe A681-350. It is powered by a AMD E-350 APU that combines a dual core 1.6ghz cpu and an ATI Radeon HD 6310 gpu on one chip. It's a low end system, but I don't need a lot of power here. It handles full screen 1080i video from an ATSC tuner beautifully. It won't play 360p flash smooth at 1/2 screen, and it's a slide show at full screen (1920x1200). It just doesn't have the CPU to decode and scale video. Mythtv uses hardware scaling, so it only has to decode on the cpu, and ffmpeg's software decoders are well optimized.

Today I installed Arch Linux on it. This post was going to cover that, but I discovered hardware acceleration for flash on ATI chipsets works!

Comparison

  • With software decoding and rendering flash takes 60-75% of my total cpu time (windowed, scaled as large as smooth playback allows).
  • With hardware decoding and (possibly?) rendering it takes 10-25% and plays smoothly full-screen.

 Requirements

  • A very up-to date system. (Arch hasn't supported it long, most distro's will probably take some time to, but you may find a ppa or can always compile from source)
  • kernel 3.10+
  • mesa 9.2+
  • libvdpau
  • ati-dri
  • xf86-video-ati
  • flashplugin

Optional

  • vdpauinfo (print info about VDPAU (and show's it's working)
  • vainfo (same as above, but for VA-API)
  • libva-vdpau-driver (allows va-api enabled apps to be accelerated)
  • libva

Setup

Assuming you have installed all these packages vdpauinfo should spit out a bunch of information on what's supported. If it doesn't you may need to specify the driver. I didn't need to, but you might (shouldn't) need to add something like this to your environment variables:

VDPAU_DRIVER=

Flash probably won't work until you edit /etc/adobe/mms.cfg and uncomment the line:

EnableLinuxHWVideoDecode=1

I haven't tried it in anything but chromium, so I'll stick to that for now. In chrome://flags I had to enable

Override software rendering list

Now Flash should have hardware decoding! MythTV can be configured to use vdpau decoding and it works nicely too.

VA-API

(I haven't messed with VA-API much, so this may or may not work.) For VA-API it may be necessary to add the following to your environment variables setup. (you don't need this for flash, it only supports vdpau)

LIBVA_DRIVER_NAME=vdpau

One way to do this is create a file (as root) /etc/profile.d/vaapi_vdpau.sh containing:

#!/bin/sh
export LIBVA_DRIVER_NAME=vdpau

Save and add execute permissions (chmod +x vaapi_vdpau.sh . Log off and back on or execute the export command above and vainfo should return the supported codecs.

Notes

  1. It only works with the open source driver, though there is a way to get it in fglrx. (see https://bbs.archlinux.org/viewtopic.php?id=166593&p=1)
  2. Before "top" shows flash using 120-150% cpu. After "top" shows  20-50% (dual core = 200% max)
  3. This works with flashplugin (11.2). I haven't played with it much, but it doesn't seem to work with pepper-flash (11.8). It has lower cpu usage than 11.2 with EnableLinuxHWVideoDecode commented out in /etc/adobe/mms.cfg, but uncommenting it has no effect. Either it's looking somewhere else for that config or it doesn't support it. CPU usage under 11.2 drops way below 11.8 with it enabled.
  4. Obviously different chipsets support different codecs, some may not support any at all. The VA-API Wiki page linked below has some info to that end.
  5. The Chrome flag may improve overall performance or it may break things / slow things down. you'll have to try it and see.
  6. You can check chrome://flash and chrome://gpu before and after to see what changes.

        Links: