Making video render FLY!

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.

before-core-mod.jpg · 60.4K · 257 views
after-core-mod.jpg · 83.2K · 273 views
Quote · 15 Nov 2011

Good info, thanks!

BoonEx Certified Host: Zarconia.net - Fully Supported Shared and Dedicated for Dolphin
Quote · 15 Nov 2011

Glad I could contribute. I attached screen shots of the htop - before and after. I caught it at the tail end during the rendering so the cores are slowing down, but you get the point. Oh and I made a mistake - This box only has 16g of ram, not 20.

Quote · 15 Nov 2011

Holy Hell! You have no idea just how big an issue this has been for a very long time!

I give you ten whole kudos for this! Thanks man!

http://towtalk.net ... Hosted by Zarconia.net!
Quote · 15 Nov 2011

@Dugn8r

since 2007 I'm here working on my dolphin sites and I really hated video upload and playback. 

Thank you so much for this post. Amazing, I can smile na :-)

Diddy is not greedy and has time. Dolphin is cool and its not just mine :-)
Quote · 15 Nov 2011

so with a dual core it is useless to do any changes to the header.inc.php?

Diddy is not greedy and has time. Dolphin is cool and its not just mine :-)
Quote · 15 Nov 2011

well you can do threads 2  but, doing this is not a very good idea if you think about it....   what happens when you have 100 people on your site and 1 person uploads a video...   do you really want to dedicate 100% cpu to ffmpeg.    i think not. 

https://dolphin-techs.com - Skype: Dolphin Techs
Quote · 15 Nov 2011

@jay, right, and thats why I decided to upgrade to Quad Core cos its simply a important issue :-)

Diddy is not greedy and has time. Dolphin is cool and its not just mine :-)
Quote · 15 Nov 2011

 

Holy Hell! You have no idea just how big an issue this has been for a very long time!

I give you ten whole kudos for this! Thanks man!

 Well thanks. I can't figure out anything else in linux or Dolphin, so I was glad i could discover this. I've actually learned a lot by reading up on FFMpeg and seeing his Dolphinhow Dolphin passes off the processing.One could actually have two boxes; one for a web server and one to store the video. The web server box could symlink right to the video box and the video box could Cron the processing, leaving the web server to do nothing but serve the web.

I've only been using Linux and Dolphin for a few weeks but I'm starting to like it.

Quote · 16 Nov 2011

At my server it says:

Total processors: 4

Processor #1
Vendor
GenuineIntel

Name
Intel(R) Xeon(R) CPU X3210 @ 2.13GHz
Speed
1600.000 MHz
Cache
4096 KB
Processor #2
Vendor
GenuineIntel

Name
Intel(R) Xeon(R) CPU X3210 @ 2.13GHz
Speed
1600.000 MHz
Cache
4096 KB
Processor #3
Vendor
GenuineIntel

Name
Intel(R) Xeon(R) CPU X3210 @ 2.13GHz
Speed
1600.000 MHz
Cache
4096 KB
Processor #4
Vendor
GenuineIntel

Name
Intel(R) Xeon(R) CPU X3210 @ 2.13GHz
Speed
1600.000 MHz
Cache
4096 KB

 

Does that mean I have 4 core?

Diddy is not greedy and has time. Dolphin is cool and its not just mine :-)
Quote · 19 Nov 2011

yes thats correct  4 cores

https://dolphin-techs.com - Skype: Dolphin Techs
Quote · 20 Nov 2011

 @jay, I'm a bit confused now cos Arvixe "chat" support told me 4 cores for each processor which would make it 16.

I better check once more

yes thats correct  4 cores

 

Diddy is not greedy and has time. Dolphin is cool and its not just mine :-)
Quote · 20 Nov 2011

I think they meant the processor has 4 logical processors (also known as cores). That's according to the intel specs. I highly doubs any web hosting company would host on a server with 4 actual processors - it would be hugely expensive and a massive waste of processing power. Even my dual G34 Opteron setup is far too potent for what Boonex and Linux requires. The mitigating factor is if you are going to render video. Video rendering is pure math and lots of it.

By the way - I've found how to make FFMpeg use a GPU to render video - you have to download the uncompiled program (I forget what Linux calls this), download the ATI drivers for Linux and then compile FFMpeg with the ATI drivers. Not that anyone will ever need that, but you never know. I'm just throwing that out there.

If you ever want to host your own and don't need a ton of storage space, I found a  A GREAT LITTLE SERVER (click here) by SuperMicro- it would make a perfect boonex server if you put a larger HD in it (or 2 and run it in RAID 1 in case you have a drive failure). I bought this to use as a PBX system and it only cost me $250.00!!! Throw on a free Linux like CentOS or Ubuntu server and you are ready to go! It's got two Intel 5500 series quad core processors for a total of 8 cores, 8 gigs of memory... it's noisy as holy hell (sounds like my wife) but well worth it. (by the way, for those needing a PBX, get a box like this, put CentOS 5.x on it and install SnomOne - it's free up to 10 users!!!

Here's my little setup - the little supermicro 1U is on the very top (my Boonex servers are the two on the very bottom - also SuperMicro).

Servers.JPG · 101.3K · 239 views
Quote · 23 Nov 2011

I've applied this in 7.1 and it works fine; it seems the audio process is the bottleneck now.

I added the one for video and that worked, and audio but it seems it didn't work, what needs to be added?

   "playX264" => $GLOBALS['sFfmpegPath'] . " -y -i #input# -b:v #bitrate#k -threads 6 -vcodec libx264 -s #size# #audio_options# #output#",    "play" => $GLOBALS['sFfmpegPath'] . " -y -i #input# -r 25 -b:v #bitrate#k -threads 6 -s #size# #audio_options# #output#",

ManOfTeal.COM a Proud UNA site, six years running strong!
Quote · 1 Feb 2013

Nathan, how many cores do I have?

http://towtalk.net ... Hosted by Zarconia.net!
Quote · 1 Feb 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.