HOWTO: Compiling mplayer with multi-core decoding support
I'm posting this HowTo since I think it is a great advancement in HD playback on Linux and people should be able to take advantage of it. I found out how to do this from the following post on doom9.org: http://forum.doom9.org/showthread.ph...45#post1221445
Overview: To use mplayer with multithreaded decoding abilities all you have to do is compile mplayer as per usual, but having replaced the normal ffmpeg source code (within the mplayer source code directory) with the ffmpeg-mt source code (http://gitorious.org/projects/ffmpeg/repos/ffmpeg-mt).
I'm going to use the following guide written by andrew.46 entitled [Howto] Successfully install the svn mplayer + gmplayer + all the codecs as the basis for my tutorial as it's very thorough and I feel there's no need to reinvent the spoon.
How to install:
1. Follow andrew.46's guide until you reach the point "Download and Compile the svn mplayer" (you can skip the step "Installing the amr libraries" if you don't need these, I skipped it)
2. When you reach the step "Download and Compile the svn mplayer" proceed as andrew.46 says with downloading the mplayer source code from SVN:
Code:
$ cd $HOME
$ svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
When this is done it's time to download the ffmpeg-mt source code. First you need git, install it with the following command:
Code:
sudo apt-get install git-core
Then download the source code for ffmpeg-mt using git:
Code:
git clone http://git.gitorious.org/ffmpeg/ffmpeg-mt.git
In order to make use of the now downloaded ffmpeg-mt source code you need to replace the three following folders from the mplayer source directory with the folders from the ffmpeg-mt directory: "libavcodec", "libavformat" and "libavutil".
Code:
cd mplayer #enter the directory where the mplayer source code is
rm -rf libavcodec libavformat libavutil #delete the three aforementioned folders
cp -a ../ffmpeg-mt/libavcodec . #copy the three folders from the ffmpeg-mt source dir to mplayers source dir
cp -a ../ffmpeg-mt/libavformat .
cp -a ../ffmpeg-mt/libavutil .
Now you have the mplayer source code in which the ffmpeg source has been replaced with the ffmpeg-mt source. You should be ready to go.
Now just follow the rest of andrew.46's guide starting from:
Code:
$ cd $HOME/mplayer
$ ./configure --enable-gui
$ make
$ sudo make install
$ make clean
and mplayer should compile with no problems.
Here are some benchmarks of mplayer with the normal single-threaded ffmpeg decoder compared to the multi-threaded ffmpeg decoder playing various 1080p H.264 video samples (using my Core2 Quad 2.83GHz CPU):
Code:
SINGLE-THREADED FPS MULTI-THREADED FPS PERCENT INCREASE IN FPS
The Dark Knight 37 121 329%
In Bruges 45 134 296%
(no -ss 120)
The Bank Job 46 141 305%
The Terminator 37 126 341%
(no -ss 120)
(MPLAYER ARGUMENTS: -vc ffh264 -lavdopts threads=4 -vo null -benchmark -frames 1000 -ss 120 -nosound)
I hope you've enjoyed this guide, I basically just snatched the guides from the two aforementioned users and joined them, thanks goes out to them.
Happy HD viewing :)
Re: HOWTO: Compiling mplayer with multi-core decoding support
thank you, I gonna try this when I upgrade my system, very soon.
for now, can you tell me what this mean?
Code:
Starting playback...
[h264 @ 0x8902510]Cannot parallelize deblocking type 1, decoding such frames in sequential order
VDec: vo config request - 1280 x 720 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [null] 1280x720 => 1280x720 Planar YV12
V: 162.5 0/ 0 70% 0% 0.0% 0 0
that's when using
Code:
-vc ffh264 -lavdopts threads=4 -vo null -benchmark -frames 1000 -ss 120 -nosound
(pentium 4, 2.6ghz)
Re: HOWTO: Compiling mplayer with multi-core decoding support
Hi,
You might be better to use a newer version of my MPlayer guide:
http://ubuntuforums.org/showthread.php?t=1024592
which is a little more polished than the older one that you have linked to. Better still why not copy and paste the relevant sections of my guide into your own? I have absolutely no objection and it would make it a bit easier for people to follow your guide from beginning to end.
All the best,
Andrew
Re: HOWTO: Compiling mplayer with multi-core decoding support
Where do I download the svn tarball for ffmpeg-mt? Using git is too slow for my current bandwidth?
Thanks
Re: HOWTO: Compiling mplayer with multi-core decoding support
Has anyone experienced glitches / crashes during h.264 playback (encoded with x264)??
Re: HOWTO: Compiling mplayer with multi-core decoding support
Quote:
Originally Posted by
andrew.46
Hi,
You might be better to use a newer version of my MPlayer guide:
http://ubuntuforums.org/showthread.php?t=1024592
which is a little more polished than the older one that you have linked to. Better still why not copy and paste the relevant sections of my guide into your own? I have absolutely no objection and it would make it a bit easier for people to follow your guide from beginning to end.
All the best,
Andrew
Hi Andrew
Thank you for letting me use your guide. Yes, pasting the above modifications into your guide would indeed be easier to follow, I just haven't gotten around to asking you for permission since I haven't had much spare time since writing the above guide.
But I will definitely do it when I have some more time on my hands.
Alternatively, anyone here are also free to use my guide above and copy and paste the relevant modifications into andrew's guide, if they don't wish waiting for me to do it.
Re: HOWTO: Compiling mplayer with multi-core decoding support
I can't understand why we need a special version of ffmpeg-mt libraries, if I can see on Smplayer (mplayer gui) some multithread decode options... ?
Thank you.
Re: HOWTO: Compiling mplayer with multi-core decoding support
Quote:
Originally Posted by
psychok9
I can't understand why we need a special version of ffmpeg-mt libraries, if I can see on Smplayer (mplayer gui) some multithread decode options... ?
Thank you.
The options in Smplayer are *probably* related to an older implementation of multithreading in ffmpeg which doesn't work with most modern x264 encoded videos. ffmpeg-mt is not stable yet, therefore it has to be manually copied to the mplayer source if one wishes to use it.
Re: HOWTO: Compiling mplayer with multi-core decoding support
First of all, many thanks for this HOWTO. I have been looking for something like this already for some time...
However, I've ran into a problem: Mplayer (r 29238) doesn't compile anymore when I replace the folders libavcodec libavformat libavutil with the ones from ffmpeg-mt.
FYI, I used the following configure options
Code:
./configure --codecsdir=/usr/lib/codecs --confdir=/etc/mplayer --enable-gui --prefix=/usr
make throws the following error:
Code:
make -C libswscale
make[1]: Entering directory `/home/ingo/SOURCE/mplayer/libswscale'
cc -DHAVE_AV_CONFIG_H -I.. -I.. -Wundef -Wdisabled-optimization -Wno-pointer-sign -Wdeclaration-after-statement -std=gnu99 -Wall -Wno-switch -Wpointer-arith -Wredundant-decls -O4 -march=native -mtune=native -pipe -ffast-math -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I. -D_REENTRANT -I/usr/include/directfb -I/usr/include/ -I/usr/include/SDL -D_REENTRANT -D_REENTRANT -Ilibdvdread4 -I/usr/include/freetype2 -I/usr/include -I/usr/include/schroedinger-1.0 -I/usr/include/liboil-0.3 -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -c -o swscale.o swscale.c
swscale.c: In function 'sws_format_name':
swscale.c:482: error: 'PIX_FMT_YUV420PLE' undeclared (first use in this function)
swscale.c:482: error: (Each undeclared identifier is reported only once
swscale.c:482: error: for each function it appears in.)
swscale.c:484: error: 'PIX_FMT_YUV422PLE' undeclared (first use in this function)
swscale.c:486: error: 'PIX_FMT_YUV444PLE' undeclared (first use in this function)
swscale.c:488: error: 'PIX_FMT_YUV420PBE' undeclared (first use in this function)
swscale.c:490: error: 'PIX_FMT_YUV422PBE' undeclared (first use in this function)
swscale.c:492: error: 'PIX_FMT_YUV444PBE' undeclared (first use in this function)
In file included from swscale.c:1196:
swscale_template.c: In function 'yuv2yuv1_MMX2':
swscale_template.c:961: warning: initialization from incompatible pointer type
swscale_template.c:961: warning: initialization from incompatible pointer type
swscale_template.c:961: warning: initialization from incompatible pointer type
swscale_template.c:961: warning: initialization from incompatible pointer type
swscale_template.c: In function 'yuv2packed2_MMX2':
swscale_template.c:1246: warning: dereferencing type-punned pointer will break strict-aliasing rules
swscale_template.c:1246: warning: assignment discards qualifiers from pointer target type
swscale_template.c:1247: warning: dereferencing type-punned pointer will break strict-aliasing rules
swscale_template.c:1247: warning: assignment discards qualifiers from pointer target type
swscale_template.c: In function 'hScale_MMX2':
swscale_template.c:2244: warning: initialization discards qualifiers from pointer target type
swscale_template.c: In function 'swScale_MMX2':
swscale_template.c:2946: warning: assignment discards qualifiers from pointer target type
swscale_template.c:2947: warning: assignment discards qualifiers from pointer target type
swscale_template.c:2952: warning: assignment discards qualifiers from pointer target type
swscale_template.c:2953: warning: assignment discards qualifiers from pointer target type
swscale_template.c:2959: warning: assignment discards qualifiers from pointer target type
swscale_template.c:2960: warning: assignment discards qualifiers from pointer target type
swscale_template.c:2969: warning: cast from pointer to integer of different size
swscale_template.c:2975: warning: cast from pointer to integer of different size
swscale_template.c:2983: warning: cast from pointer to integer of different size
swscale_template.c:2998: error: 'PIX_FMT_YUV420PLE' undeclared (first use in this function)
swscale_template.c:2998: error: 'PIX_FMT_YUV422PLE' undeclared (first use in this function)
swscale_template.c:2998: error: 'PIX_FMT_YUV444PLE' undeclared (first use in this function)
swscale_template.c:2998: error: 'PIX_FMT_YUV420PBE' undeclared (first use in this function)
swscale_template.c:2998: error: 'PIX_FMT_YUV422PBE' undeclared (first use in this function)
swscale_template.c:2998: error: 'PIX_FMT_YUV444PBE' undeclared (first use in this function)
swscale_template.c: In function 'sws_init_swScale_MMX2':
swscale_template.c:3155: error: 'PIX_FMT_YUV420PBE' undeclared (first use in this function)
swscale_template.c:3156: error: 'PIX_FMT_YUV422PBE' undeclared (first use in this function)
swscale_template.c:3157: error: 'PIX_FMT_YUV444PBE' undeclared (first use in this function)
swscale_template.c:3158: error: 'PIX_FMT_YUV420PLE' undeclared (first use in this function)
swscale_template.c:3159: error: 'PIX_FMT_YUV422PLE' undeclared (first use in this function)
swscale_template.c:3160: error: 'PIX_FMT_YUV444PLE' undeclared (first use in this function)
swscale.c: In function 'getSwsFunc':
swscale.c:1795: warning: unused variable 'flags'
swscale.c: In function 'planarCopy':
swscale.c:2166: error: 'PIX_FMT_YUV420PLE' undeclared (first use in this function)
swscale.c:2166: error: 'PIX_FMT_YUV422PLE' undeclared (first use in this function)
swscale.c:2166: error: 'PIX_FMT_YUV444PLE' undeclared (first use in this function)
swscale.c:2166: error: 'PIX_FMT_YUV420PBE' undeclared (first use in this function)
swscale.c:2166: error: 'PIX_FMT_YUV422PBE' undeclared (first use in this function)
swscale.c:2166: error: 'PIX_FMT_YUV444PBE' undeclared (first use in this function)
swscale.c: In function 'getSubSampleFactors':
swscale.c:2223: error: 'PIX_FMT_YUV420PLE' undeclared (first use in this function)
swscale.c:2224: error: 'PIX_FMT_YUV420PBE' undeclared (first use in this function)
swscale.c:2243: error: 'PIX_FMT_YUV444PLE' undeclared (first use in this function)
swscale.c:2244: error: 'PIX_FMT_YUV444PBE' undeclared (first use in this function)
swscale.c:2249: error: 'PIX_FMT_YUV422PLE' undeclared (first use in this function)
swscale.c:2250: error: 'PIX_FMT_YUV422PBE' undeclared (first use in this function)
swscale.c: In function 'sws_setColorspaceDetails':
swscale.c:2288: error: 'PIX_FMT_YUV420PLE' undeclared (first use in this function)
swscale.c:2288: error: 'PIX_FMT_YUV422PLE' undeclared (first use in this function)
swscale.c:2288: error: 'PIX_FMT_YUV444PLE' undeclared (first use in this function)
swscale.c:2288: error: 'PIX_FMT_YUV420PBE' undeclared (first use in this function)
swscale.c:2288: error: 'PIX_FMT_YUV422PBE' undeclared (first use in this function)
swscale.c:2288: error: 'PIX_FMT_YUV444PBE' undeclared (first use in this function)
swscale.c: In function 'sws_getColorspaceDetails':
swscale.c:2336: error: 'PIX_FMT_YUV420PLE' undeclared (first use in this function)
swscale.c:2336: error: 'PIX_FMT_YUV422PLE' undeclared (first use in this function)
swscale.c:2336: error: 'PIX_FMT_YUV444PLE' undeclared (first use in this function)
swscale.c:2336: error: 'PIX_FMT_YUV420PBE' undeclared (first use in this function)
swscale.c:2336: error: 'PIX_FMT_YUV422PBE' undeclared (first use in this function)
swscale.c:2336: error: 'PIX_FMT_YUV444PBE' undeclared (first use in this function)
swscale.c: In function 'sws_getContext':
swscale.c:2408: error: 'PIX_FMT_YUV420PLE' undeclared (first use in this function)
swscale.c:2408: error: 'PIX_FMT_YUV422PLE' undeclared (first use in this function)
swscale.c:2408: error: 'PIX_FMT_YUV444PLE' undeclared (first use in this function)
swscale.c:2408: error: 'PIX_FMT_YUV420PBE' undeclared (first use in this function)
swscale.c:2408: error: 'PIX_FMT_YUV422PBE' undeclared (first use in this function)
swscale.c:2408: error: 'PIX_FMT_YUV444PBE' undeclared (first use in this function)
swscale.c: In function 'reset_ptr':
swscale.c:2917: error: 'PIX_FMT_YUV420PLE' undeclared (first use in this function)
swscale.c:2917: error: 'PIX_FMT_YUV422PLE' undeclared (first use in this function)
swscale.c:2917: error: 'PIX_FMT_YUV444PLE' undeclared (first use in this function)
swscale.c:2917: error: 'PIX_FMT_YUV420PBE' undeclared (first use in this function)
swscale.c:2917: error: 'PIX_FMT_YUV422PBE' undeclared (first use in this function)
swscale.c:2917: error: 'PIX_FMT_YUV444PBE' undeclared (first use in this function)
swscale.c: In function 'sws_getCachedContext':
swscale.c:3404: warning: assignment discards qualifiers from pointer target type
make[1]: *** [swscale.o] Error 1
make[1]: Leaving directory `/home/ingo/SOURCE/mplayer/libswscale'
make: *** [libswscale/libswscale.a] Error 2
When I use the original libraries sources from svn trunk, then it compiles without errors. :confused:
Any ideas how this can be fixed?
Thanks.
btw: I am running Jaunty 9.04
Re: HOWTO: Compiling mplayer with multi-core decoding support