In a recent project, I need to achieve high performance video playback in OpenGL. I tried Gstreamer-sharp and OpenTK and got reasonable FPS. However, after digging deeper into the topic, i did more tests and here i would like to share the results.

PC: Intel Core i5-2320 Quad Core 3.0GHz/4GB RAM/GT440 GPU 1GB

OS: Xubuntu 12.04LTS 32bit/NVIDIA Driver 295.59

SAMPLE VIDEO: Big Buck Bunny, AVI/MPEG-4 Codec Video/1920×1080/24FPS/YUV420 Planar/12000kbps, AC3 Codec Audio/48000Hz/448kbs

RESULT(CPU usage):

1 – mplayer

2 – gstreamer python bindings, play.py example.

3 – pyglet media player example.

4 – openframeworks videoplayer.

5 – gstreamer-sharp + opentk

6 – gstreamer-sharp + opentk + GPU color conversion

7 – gstreamer tools. gst-launch -v playbin2 uri=file:///test.avi

8 – gstreamer tools with glimagesink. gst-launch filesrc location=test.avi ! decodebin2 name=decoder ! queue ! glupload ! glimagesink decoder. ! queue ! audioconvert ! audioresample ! autoaudiosink

Both openframeworks(4) and my gst-sharp warpper in opentk(5) have high cpu loads. Their working procedures are similar. The only difference is the language, aka c++ and c#.

Checkout the c# code here. I will share more details in test 5 and 6.

In test 5(ThreadedVideoPlayer.cs), i use gstreamer appsink. The main thread poll the RGB data from the gst thread and feed to GPU texture. To accelerate data transfer between GPU and CPU, I also tried Pixel Buffer Object, although it does not help a lot. The CPU usage is above 20% whereas mplayer and gstreamer tools consume less than 10%.

With some googling, i found that color conversion could be the bottleneck. So in test 6(ThreadedGLSLVideoPlayer.cs), i removed the color conversion from the gst pipeline simply by setting the appsink format to be YUV instead of RGB. The color conversion is done with custom GLSL shader(thanks to x-quadraht). Now the cpu usage drops significantly(see column 6) to less than 10%.

[Ubuntu]

ISSUE: Nvidia display driver problem on a two graphics card PC.

[EE] No devices detected. No screen found.

SOLUTION:

lspci -v

Get PCI bus number for graphics cards, 1:0:0 and 6:0:0 for instance.

sudo vi /etc/X11/xorg.conf

Under section “Device”, add

BusID “PCI:1:0:0″

Restart X and everything works like a charm.

http://wiki.linuxquestions.org/wiki/Using_multiple_monitors

[CUDA]

ISSUE: “error while loading shared libraries: libcudart.so.3: cannot open shared object file: No such file or directory”

SOLUTION:

sudo vim /etc/ld.so.conf

Add “/usr/local/cuda/lib”

Save and quit.

ld config -v | grep cuda

山寨的联通3G网卡,无型号,隆信通,在Ubuntu 11.10下使用:

lsusb信息如下:

Bus 003 Device 003: ID 05c6:6000 Qualcomm, Inc. Mass Storage Device.

使用如下命令切换到modem模式:

usb_modeswitch -v 05c6 -p 1000 -M 5553424312345678000000000000061b000000020000000000000000000000 -R 1
切换成功后可ls /dev/tty*看到ttyUSBx的设备。

打开网络配置用户名和密码都为any,pin码为1234,网络为3gnet,其余默认。

Tricks