开发者

Automatic ffmpeg conversion of only completed, fully uploaded files

Maybe it would be best to start by describing the scenario.

We have a Debian server with ffmpeg that we use to covert various video files into FLV. The files are supplied by a number of differe开发者_开发百科nt people via FTP and are kept in the "uploads" folder.

I need to write a PHP script that would go through all the files in the uploads folder, select the ones which are complete (i.e. not currently being uploaded or without any uploading errors) and then convert them to FLV using ffmpeg.

I can do the conversion and everything else, but how do I determine whether a file is complete and fully uploaded?

Many thanks!


Afaik you can't just figure out if a file is still being uploaded. You could run a cronjob everyminute getting the filesizes and store these in a database or file. Then if you run the cronjob the second time and the filesize is the same: convert them, if not.. wait another minute and then try again.

I don't believe there's a filesize stored with a file that contains the size it should be after the upload is done.


There is another way to go about this, which we have done for years.

Most ftp servers (proftpd does) will output a log which will tell you when a file upload has completed successfully. You can set this logging to go to a unix named pipe / fifo, and then have a daemonized script read this to determine which files to process. This works great, and only processes files after they are uploaded completely and successfully.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜