How to compile mplayer with vdpau support on Ubuntu

In February of 2009 I wrote an article on how to compile mplayer with vdpau support. Since then things have changed a little bit with mplayer and compiling mplayer with vdpau support has become a whole lot easier.

The biggest and most important thing is that mplayer has built in support for vdpau. You no longer need to use the patched version made available by nVidia.

Before we start compiling, you might want to know a bit more about it and if it’s something you want to do.

What is VDPAU?
WikiPedia defines it as follows:

VDPAU (Video Decode and Presentation API for Unix) is an API designed by NVIDIA for its GeForce 8 series and later GPU hardware, targeted at the X Window System on Unix operating-systems (including Linux, FreeBSD, and Solaris). The VDPAU API allows video programs to offload portions of the video decoding process and video post-processing to the GPU video-hardware. Currently, the portions designed to be offloaded by VDPAU onto the GPU are motion compensation (mo comp) and inverse discrete cosine transform (iDCT), and VLD (Variable-Length Decoding) for MPEG-1, MPEG-2, MPEG-4 AVC (H.264), VC-1, and WMV3/WMV9 encoded videos.

Great! What does it mean?
What it means that instead of using your processor is utilizes your graphics processor for certain decoding processes. This allows you to run other things when you are watching a video, the most known application that benefits from this is mythTV, you can use a less powerful processor to watch videos.

Why do I want it?
Well like I said, if you have a less powerful processor and you want to watch a DVD, movie on your computer this implementation makes it possible.

It says it is designed by nVidia, can I use it with other graphic cards?
Short answer, No. The API is designed specifically for nVidia graphic card, and then only for the GeForce 8 and higher.

Let’s start

First of all you’ll need to use the official nVidia graphics driver, not the one that comes with Ubuntu itself.
To download the latest driver go to this site. At the time I’m writing this, the latest version is 180.51. You’ll need to download the pkg1 version.

Install nVidia driver
To compile mplayer with VDPAU support we need to run the nVidia driver.
Install this driver follow the following steps.

  • Log off from your computer. Not restart but Logoff
  • Press Ctrl-Alt-1. Your on the console right now
  • Login like you normally would
  • Type:
    sudo su -

    And when asked for your password give your password

  • If you are running Gnome type:
    /etc/init.d/gdm stop

    If you are running KDE type:

    /etc/init.d/kdm stop
  • In order to install the driver we’ll need to install some software:
    apt-get install build-essential linux-headers-`uname -r`
  • Go to the directory where you downloaded the driver
  • Type: sh NVIDIA-Linux-x86-180.51-pkg1.run
  • Accept the license, no need to search the FTP site and let the installer modify the X configuration
  • Personally I always reboot after this
    reboot

Compiling mplayer
I download everything in /d1/software/mplayer

Get the latest version from the official mplayer site, you will have to download the version marked Subversion snapshot.
You will also need all the development files for mplayer, we can get those by using aptitude.
In order to compile mplayer you’ll also need two extra files, nVidia does provide them but for your convenience I tarred them up. You can find the download link in the sidebar of this blog under Local Downloads.

Prepare for configuration and compilation
Open a terminal.

cd /d1/software/mplayer
tar xf mplayer-checkout-snapshot.tar.bz2
tar xf vdpau_20090305.tar.gz
mv vdpau /usr/include/
sudo aptitude build-dep mplayer

Configuring, Compiling and Installing
I use the –target in my configure script to force mplayer to use this that specific target. For some reason the configure script doesn’t recognize I have a core2 processor. You can leave it out and mplayer will figure out what kind of processor you have.

cd mplayer-checkout-2009-05-29
./configure --enable-gui --disable-x264-lavc --disable-x264 --enable-vdpau --target=i686-linux --prefix=/usr --confdir=/etc/mplayer --mandir=/usr/share/man

As mentioned earlier, mplayer doesn’t recognize the core2 I have, so in order for the compilation to use core2 I modify the output created by the configuration script.
Skip this if you don’t have a core2 processor!

sed 's/i686/core2/g' config.mak > /tmp/config.mak
mv /tmp/config.mak config.mak

Now for the compilation and installation

make
sudo make install

That’s all, you should have mplayer with VDPAU capabilities.

In order for mplayer to use vdpa you will need to add the following lines to the mplayer configuration.

cd ~/.mplayer

Use your favorite text editor to modify or create the file config
Add the following lines

# Write your default config options here!
vo=vdpau,xv,
vc=ffh264vdpau,ffmpeg12vdpau,

And that’s it, you are all set.

How do you know if you are using the VDPAU capabilities?
Download a clip from here

  • Open mplayer from the menu
  • Open a terminal and type: top
  • Open the movie in mplayer and play it
  • Check top in the terminal, you should see gmplayer in the command column. This is the GUI version of mplayer. Check the %CPU column. Try to remember the approximate percentage.
  • Close mplayer
  • Open another terminal
  • Type: gmplayer
  • Open the movie in mplayer and play it
  • Check top in the terminal, you should see gmplayer in the command column. This is the GUI version of mplayer. Check the %CPU column.
  • If the percentages of CPU is lower while playing the movie started from the menu you are running VDPAU. Congrats.
    If the percentages are about the same something went wrong during the configuration/compilation steps I described

Putting it all together
I have put the above steps together in a small shell script, called do-it.sh. Whenever I want to update mplayer, I just run the script and “automatically” have the latest version.

#!/bin/bash
rm -rf mplayer-checkout*
curl http://www.mplayerhq.hu/MPlayer/releases/mplayer-checkout-snapshot.tar.bz2 -o mplayer-checkout-snapshot.tar.bz2 -v
tar xf mplayer-checkout-snapshot.tar.bz2
cd mplayer*
./configure --enable-gui --disable-x264-lavc --disable-x264 --enable-vdpau --target=i686-linux --prefix=/usr --confdir=/etc/mplayer --mandir=/usr/share/man
sed 's/i686/core2/g' config.mak > /tmp/config.mak
mv /tmp/config.mak config.mak
make
sudo make install
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值