A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearPHP calling multiple videos to convert at once via mencoder.How can I limit it? - page 1
User InfoPosts
PHP calling multiple videos to convert at once via mencoder.How can I limit it?#1
I recently installed my video script to a new server but I am seeing that it will start to convert 1 video (via mencoder) then before finishing it, it will try and convery another, and another, so it will be trying to convert 4+ videos at the same time causing the server to shut down. The script developer said:

"It converts each video in a PHP background process. There might be a way to limit the number of PHP background processes on your server and queue them."

So how is this done please?

Regards

posted date: 2008-12-30 00:37:00


Re: PHP calling multiple videos to convert at once via mencoder.How can I limit it?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-30 00:37:01


Re: PHP calling multiple videos to convert at once via mencoder.How can I limit it?#3
Use some sort of lock. For example, use file locking on a directory so only one process at a time can use the resource.This would require a wrapper script for the encoder which will wait for the lock to be released by the currently running encoder. It should also be smart enough to detect when a lock wasn't freed if the encoder crashes, and release the lock.Edit:My understanding of the problem was there were multiple invocations of the script, each calling mencoder. However, from the other response, it seems that it might be one invocation running all the processes in the background. Then I think the solution using Semaphores is better.Edit:Looks like someone asked this question before:best-way-to-obtain-a-lock-in-php

posted date: 2008-12-30 00:43:00


Re: PHP calling multiple videos to convert at once via mencoder.How can I limit it?#4
Use PHP SemaphoresYou can use a shared counting Semaphore in PHP, and implement a queue with a cap on the no. of parallel executions. Semaphores are always the most recommended method for any form of concurrency control.Using this you can easily configure and control the parallel executions of mencoder, and limit them as well.PseudocodeBegin init sem=MAX; wait(sem) //sem--, waits if sem=0, till atleast one process comes out of the critical section /* Critical Section where you execute mencoder */ signal(sem)//sem++End

posted date: 2008-12-30 00:54:00


Re: PHP calling multiple videos to convert at once via mencoder.How can I limit it?#5
I like that answer, because it attacks the essential problem: there's no out-of-the-box solution in PHP, you have to brew your own thing for such kind of thing.

posted date: 2008-12-30 01:11:00


Re: PHP calling multiple videos to convert at once via mencoder.How can I limit it?#6
@Juan: Regd your Edit, I believe even with multiple invocations of the script. A SHM semaphore will be able to do the job (like POSIX semaphores in Unix).

posted date: 2008-12-30 01:16:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.