仅自动 ffmpeg 转换已完成、完全上传的文件

发布于 2024-11-05 14:20:16 字数 258 浏览 4 评论 0原文

也许最好从描述场景开始。

我们有一个带有 ffmpeg 的 Debian 服务器,我们用它来将各种视频文件转换为 FLV。 这些文件由许多不同的人通过 FTP 提供,并保存在“uploads”文件夹中。

我需要编写一个 PHP 脚本来遍历上传文件夹中的所有文件,选择完整的文件(即当前未上传或没有任何上传错误),然后使用 ffmpeg 将它们转换为 FLV。

我可以进行转换和其他所有操作,但如何确定文件是否完整且已完全上传?

非常感谢!

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 different 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我的影子我的梦 2024-11-12 14:20:16

据我所知,您不能仅仅确定文件是否仍在上传。您可以每分钟运行一个 cronjob 来获取文件大小并将其存储在数据库或文件中。然后,如果您第二次运行 cronjob 并且文件大小相同:转换它们,如果不是......再等一分钟,然后重试。

我不相信存储的文件大小包含上传完成后应有的大小。

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.

送舟行 2024-11-12 14:20:16

还有另一种方法可以解决这个问题,我们多年来一直这样做。

大多数 ftp 服务器(proftpd 都会)会输出一个日志,该日志会告诉您文件上传何时成功完成。您可以将此日志记录设置为转到 unix 命名管道/fifo,然后让守护进程脚本读取此日志以确定要处理哪些文件。这非常有效,并且仅在文件完全成功上传后才对其进行处理。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文