lqez
lqez

Reputation: 3008

Best way to get notification when file uploading is being completed

I created a video transcoder using ffmpeg. User uploads RAW videos - very big, about 20GB - via FTP.

Currently, a php script is monitoring local paths every 5 seconds with below strategy.

  1. Look up local filesystem.
  2. If a 'new' file appears, add it to database with modified time and its size.
  3. After 5 seconds, check the modified time and size again,
    1. Not changed : Set status as [DONE], and encode the video into './output' directory. ( 'output' is explicitly excluded from monitoring )
    2. Changed : Wait another 5 seconds.

It works very well, but it burns some cpu power to find 'new file'. Is there any way to get the 'exact timing' when file uploading is being completed?

Upvotes: 3

Views: 685

Answers (2)

user557846
user557846

Reputation:

if you can, install inotify then its super easy via a bash script. otherwise a bash script may still be more efficient.

update: php supports inotify with: php.net/manual/en/book.inotify.php

Upvotes: 1

AlfredoVR
AlfredoVR

Reputation: 4287

Try making a perl daemon that checks for new files, i think it would be less resource intensive. Also, another more unix like alternative, and i think better overall: http://en.wikipedia.org/wiki/File_Alteration_Monitor

Upvotes: 1

Related Questions