After getting Dolphin 7 configured, I installed htop (from the Ubunto command line: sudo apt-get install htop) so I could see my system resources and pay attention to possible bottlenecks. For those interested, my server has for following:
- Asus server motherboard
- 2x AMD opteron 8 core processors for a total of 16 cores
- 20 gb DDR3 ram
- Asus Pike 1078 hardware RAID controller
- 8x1 tb hard drives running in RAID 10
- Ubuntu 11.04 Server edition (no GUI)
Okay... so I uploaded a 100 meg video to the server to see how much of my system resources it would consume. While monitoring htop, I saw the video start to renter at 100%... only on one core. I was a bit dissapointed and thought there had to be some kind of setting to make it run with more cores, right? It took a 100 meg video and would take eight minutes or longer to render, unacceptable if you have a bunch of people uploading videos.
After scouring the ffmpeg documentation, I found the holy grail for which I was searching: -threads . But where would I put it? I had to do a search of every file that would invoke the ffmpeg command, so I ran:
$ grep -R -i -n 'ffmpeg' *
I took a gander at the results and there it was: line 18 in the header.inc.php file located in the /YourWebSite/flash/modules/video/inc/ folder.
(to edit: $ sudo vi /YourWebSite/flash/modules/video/inc/header.inc.php
where YourWebSite is the root of your web site)
Once you are in the header.inc.php file, you will see the following at line 18:
"playX264" => $GLOBALS['sFfmpegPath'] . " -y -i #input# -r 30000/1001 -b #bitrate#kb -bt 128kb -vcodec libx264 -deblockalpha 0 -deblockbeta 0 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -me_method hex -me_range 16 -subq 7 -bf 0 -b_strategy 2 -bframebias 0 -trellis 1 -flags2 +mixed_refs -coder 1 -refs 8 -g 300 -keyint_min 25 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.0 -complexityblur 20.0 -qblur 1.0 -qmin 10 -qmax 51 -qdiff 4 -i_qfactor 0.71 -b_qfactor 0.77 -s #size# #audio_options# #output#",
If you are using vi as your editor, hit i (for insert mode) and scroll to the area I highlighed in red writing. Now, add the following:
-threads x
where X is the number of processor cores to use. Since I have 16 cores and Linux's overhead is so tiny, I chose to use 8 cores for video rendering (-threads 8). Here is what my line 18 now looks like:
"playX264" => $GLOBALS['sFfmpegPath'] . " -y -i #input# -r 30000/1001 -b #bitrate#kb -bt 128kb -threads 8 -vcodec libx264 -deblockalpha 0 -deblockbeta 0 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -me_method hex -me_range 16 -subq 7 -bf 0 -b_strategy 2 -bframebias 0 -trellis 1 -flags2 +mixed_refs -coder 1 -refs 8 -g 300 -keyint_min 25 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.0 -complexityblur 20.0 -qblur 1.0 -qmin 10 -qmax 51 -qdiff 4 -i_qfactor 0.71 -b_qfactor 0.77 -s #size# #audio_options# #output#",
I now render video with 8 cores and the same 100 meg video takes about 45 seconds to render. A HUGE improvement in my opinion. Best of all, I had a bunch of friends log on at the same time while video was rendering to put a load on the server in for form of page requests and dowloads and the requests were easily handled by the other cores with no bottlenecking whatsoever.
If you are using a hosting company, chances are they are using two quad core XEONS so I probably wouldn't change the threads to more than 4. in fact, if you have the ability to install HTOP, it will show how many cores you have.
I hope this helps anyone in the same situation as I am... my next post will be on how to increase the number of cores used in processing photographs.
One limitation I would love to see handled (and maybe they do) is the ability to have a graphics engine (like a GTX 580) take care of all of the video rendering and leaving the processors alone. Video rendering would smoke!
One thing to keep in mind - I am running an 8 disk RAID 10 array, so writes are wickedly fast. If you do this mod and you are only seeing your cored max out to less than 100%, it is probably due to the fact your disk I/O's can't keep up with it. If you are seeing 4 cores running at 85%, drop it to 3 cores and see what happens. May as will make it as efficient as possible.