logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: FFMPEG Windows Apache 64bit Limiting CPU Consumption Page 1, 2, 3  Next
Author
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sat 22 Feb '14 6:27    Post subject: FFMPEG Windows Apache 64bit Limiting CPU Consumption Reply with quote

So basically i want to control / limit the cpu consumption of ffmpeg.exe on windows i thought i would post it here since it is a video streaming site.

Running under apache 2.4.6 64bit vc11.

Who has any idea of any tools or programs that can limit the cpu consumption of a process ?

I need to find something that can constantly scan for ffmpeg.exe and limit the cpu of it. Such a headache from this process.

http://ffmpeg.zeranoe.com/builds/

I saw some posts of people limiting apache's cpu consumption no idea if it was built in or some kind of third party program/tool you are using.

I have been searching sourceforge.net and github but everything i find is all for stress testing and not limiting cpu consumption of a specific process.

I did find this but i need a program constantly listening out for ffmpeg.exe (since it runs and closes at its own free will) http://stackoverflow.com/questions/11357713/how-to-limit-ffmpeg-cpu-usage?rq=1
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Sat 22 Feb '14 8:23    Post subject: Reply with quote

Instead looking for limiting usage of ffmpeg look for limiting cpu usage of windows processes.

Some versions of windows allow to set cpu limit using registry. Here is an article about it:
http://technet.microsoft.com/en-us/library/ff384148%28WS.10%29.aspx

Also, you can set affinity and a priority level of a process on some versions of windows.

For example on one of my servers I'm using Windows 2012R2 on a hardware with 16 logical cores. I have a process that is assigned to 2 cores which effectively limits its potential cpu useage to maximum of 12.5% of total cpu use on all cores.

Also check Windows System Resource Manager
http://technet.microsoft.com/en-us/library/cc755056.aspx

And yet another possibility. There is utility called process tamer.
http://www.maketecheasier.com/limit-app-cpu-usage-in-windows/

And finally Mr. Green
http://bitsum.com/processlasso/
Back to top
Anaksunaman



Joined: 19 Dec 2013
Posts: 54

PostPosted: Sat 22 Feb '14 9:30    Post subject: FFMPEG Windows Apache 64bit Limiting CPU Consumption Reply with quote

In the stackoverflow article you link to, there seems to be a consensus that reducing the -threads option for ffmpeg may be an option to reduce cpu usage. (discussed very briefly in the duplicate question link).

Also, while it's more of a bandwidth measure, might lowering bitrates help reduce cpu work and thus consumption?

https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sat 22 Feb '14 17:16    Post subject: Reply with quote

jimski wrote:
Also check Windows System Resource Manager
http://technet.microsoft.com/en-us/library/cc755056.aspx

And yet another possibility. There is utility called process tamer.
http://www.maketecheasier.com/limit-app-cpu-usage-in-windows/

And finally Mr. Green
http://bitsum.com/processlasso/


I came accross those programs in my search but the issue is none of them actualy listen or wait for the program to run they only work on currently running programs.

The problem with ffmpeg in a server enviorment is it is not always running it only gets run when someone uploads a media item and it converts it to a use friendly format such as flv, mp4, ogg, webm.

So everytime it closes and starts back up again it wont have the configuration set to limit it or set its proccess affinity. It is a bit of a headache i recon this is why people choose linux because they can control and limit programs like this.

Also with process tamer it wont download on any browser they have some kind of server issue.

(I did use the -threads 1 option on ffmpeg and it did not change anything.)

Process lasso might do the trick though i never came accross it before and it has a watchdog that waits for specific programs i will give it a test and post back if it works.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sat 22 Feb '14 20:23    Post subject: Reply with quote

Process lasso seems to be working fine for now will see how things go with it so far i like it.

Anyone aware of similar software out there that is cheaper or free ?
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Sat 22 Feb '14 21:01    Post subject: Reply with quote

CPUlimit.exe was useful for me in the old days when I has a slow PC. I do not know where I downloaded it, but here are some references:

http://www.blizzhackers.cc/viewtopic.php?t=442378
http://www.thecat.nl/VZCPULimit.html
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Sat 22 Feb '14 21:37    Post subject: Reply with quote

I was wondering if CPUlimit.exe (a 32-bit program) would work on a 64-bit OS. A little bit to my surprise it did work well on my 64-bits Windows 7 Pro. Try it at you own risk:

http://phpdev.toolsforresearch.com/cpulimit.zip

Start the program with 'cpulimit' in the directory with the exe and the ini.

With these settings ffmpeg only used 10% of the CPU capacity. When I issued cpulimit /q to stop the program, CPU usage of ffmpeg jumped up to 60-70%.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sun 23 Feb '14 5:56    Post subject: Reply with quote

Jan-E wrote:
I was wondering if CPUlimit.exe (a 32-bit program) would work on a 64-bit OS. A little bit to my surprise it did work well on my 64-bits Windows 7 Pro. Try it at you own risk:

http://phpdev.toolsforresearch.com/cpulimit.zip

Start the program with 'cpulimit' in the directory with the exe and the ini.

With these settings ffmpeg only used 10% of the CPU capacity. When I issued cpulimit /q to stop the program, CPU usage of ffmpeg jumped up to 60-70%.


Thats good to know Very Happy thanks jan-e i am currently using process lasso at the moment it gives me extra control over ram(i dont need it) but also setting process priorities etc.

It also starts at windows startup and is running all the time.(Allows me to set what programs / executables should always be running.)

This let me fix nginx to get nginx to run at windows boot. So i can restart windows server and now nginx will start at startup too so it killed allot of birds with one stone for me.

It also let me select what cores/threads of cpu to assign specific processes too (Very handy feature). Everything seems to be performing better now ffmpeg no longer hogs up my cpu Smile
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Wed 26 Feb '14 22:22    Post subject: Reply with quote

Today I stumbled over the php_av extension:
http://www.php-qb.net/
https://github.com/chung-leong/av/wiki

As someone who ported php_ffmpeg.dll from PHP 5.2 up until PHP 5.6 I was immediately attracted. You might want to try it:
http://phpdev.toolsforresearch.com/php-5.4.26RC1-nts-Win32-VC9-x86.zip

In the ZIP there is a phpinfo.htm with the specifications of php_av.dll. You'll need Zeranoe's shared DLL's from this build, but they are included in the ZIP as well:

This is a FFmpeg Win32 shared build by Kyle Schwarz.

Zeranoe's FFmpeg Builds Home Page: <http://ffmpeg.zeranoe.com/builds/>

This build was compiled on: Apr 24 2013, at: 22:21:53

FFmpeg version: 2013-04-24 git-aa96439
libavutil 52. 27.101 / 52. 27.101
libavcodec 55. 6.100 / 55. 6.100
libavformat 55. 3.100 / 55. 3.100
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 60.101 / 3. 60.101
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100


Last edited by Jan-E on Wed 12 Mar '14 20:03; edited 1 time in total
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Thu 27 Feb '14 4:13    Post subject: Reply with quote

Oh wow brilliant thanks Jan-E i just went over to using HTML5 on all videos on my site i had a bit of a nightmare with flv due to corrupt encoding in the original videos and pseudo streaming. Now i use MP4, webm and ogg files (Fully html5 compatible)
This is the HTML5 media player i use if anyone was intreasted.

http://mediaelementjs.com/

But that extension looks so wounderful if it is stable i will use it. Anything that functions for videos or html5 attracts me Smile
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Thu 27 Feb '14 23:56    Post subject: Reply with quote

I tested it Jan-E not working with php 5.5.7 nts 64bit vc11. Oh i see its compiled for vc9 Crying or Very sad
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 28 Feb '14 11:01    Post subject: Reply with quote

http://phpdev.toolsforresearch.com/php-5.5.10RC1-nts-Win32-VC11-x64.zip
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Fri 28 Feb '14 18:31    Post subject: Reply with quote

Thanks jan that version works fine Smile
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 28 Feb '14 20:30    Post subject: Reply with quote

BTW: I have upgraded it to FFMpeg 2.1.4:
http://ffmpeg.zeranoe.com/blog/?p=276#more-276

Zeranoe's latest builds have extra codecs, like x265. In the ZIP the FFMpeg DLL's are included for the moment, but in the future I will only include Zeranoe's readme as php_av_readme.txt.

Let me know how you use it. Is it a replacement for system calls to ffmpeg.exe? How does it perform? And (to be on topic) do ini-settings like av.max_threads_per_stream have any effect?
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Fri 28 Feb '14 20:57    Post subject: Reply with quote

I think the max threads per stream is if your streaming through php or doing live streaming i do not use it for that purpose.(And i dont see how it would work when nginx delivers all my static content.)

Like you said just to replace system calls to ffmpeg.exe it seems to work ok i have a much higher success rate in generating mp4 videos from flv's, .avi, webm, ogg etc etc.

Before i used to get allot of failures because the original uploaded video was corrupt or to generate a mp4 the output mp4 file would be larger than the original. I still do have some corrupt videos generated but thats from FLV's and god knows what the reason for that is.

If you like i can share the input and output data.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Tue 04 Mar '14 2:20    Post subject: Reply with quote

Is anyone familure with how to fix a corrupt output because of flv ?
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Tue 04 Mar '14 19:20    Post subject: Reply with quote

FLV container or FLV1 video codec? Sometimes old FFmpeg's or old MEncoders do what others cannot. I have got a bunch of old versions. But we are getting really off-topic now. Mail me at phpdev AT ehrhardt.nl to continue.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Fri 14 Mar '14 18:13    Post subject: Reply with quote

Jan-E wrote:
FLV container or FLV1 video codec? Sometimes old FFmpeg's or old MEncoders do what others cannot. I have got a bunch of old versions. But we are getting really off-topic now. Mail me at phpdev AT ehrhardt.nl to continue.


I did send you a email jan but had no reply. C0nw0nk AT hotmail.co.uk
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Fri 05 Dec '14 9:56    Post subject: Reply with quote

Jan-E, you may want to know that your AV builds are no longer compatible with the ffmpeg latest releases because ffmpeg renamed their dlls.
The latest versions of ffmpeg include avcodec56.dll while php_av.dll expects the avcodec55.dll.
The latest version of shared ffmpeg that I was able to get working with AV (php5.3) was dated August 8 2014.
Hope it helps. I'm a fan of your builds.


Last edited by jimski on Sun 11 Jan '15 9:42; edited 1 time in total
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Sun 11 Jan '15 9:30    Post subject: Reply with quote

How do you guys manage ffmpeg conversions on windows.

Do you use a job queue or a different method?

If you don't use a job queue then how do you deal with the cases when an ffmpeg video conversion fails for some reason. How do you track those cases and how do you restart them. Also how do you deal with cases when ffmpeg process hangs. How do you track it and shut it down.

Also post your experiences if you do use a job queue on windows.

On Linux all this is much simpler because running a job queue and getting the process IDs and tracking/shutting down processes is well implemented by the Linux OS and by php POSIX and other functions which are not available on windows. Also there are many open source projects related to this subject. On windows this is a major pain in the rear suspension.
Back to top


Reply to topic   Topic: FFMPEG Windows Apache 64bit Limiting CPU Consumption View previous topic :: View next topic
Post new topic   Forum Index -> Other Software Page 1, 2, 3  Next