使用ColdFusion的CFFILE标签来监控从FFmpeg的进度日志 [英] Using Coldfusion's CFFILE tag to monitor a progress log from FFMpeg

查看:246
本文介绍了使用ColdFusion的CFFILE标签来监控从FFmpeg的进度日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想学习如何使用CFFILE标签从ColdFusion的读取文本文件的内容。在我的情况下,该文本文件是由FFmpeg的产生,而它跨codeS的媒体文件的进度日志。我想写一个ColdFusion脚本,将定期轮询进度日志,直到日志表明FFmpeg的已经完成了它的转码操作。在客户端,然后我就可以使用Ajax来打它的ColdFusion脚本,并显示完成百分比的用户在FFmpeg的做工作。

I want to learn how to use the CFFILE tag from ColdFusion to read the contents of a text file. In my case, that text file is a progress log that is generated by FFMpeg while it transcodes a media file. I want to write a ColdFusion script that will poll the progress log periodically, until the log indicates that FFMpeg has finished its transcoding operation. On the client side I can then use Ajax to hit that ColdFusion script and show the user a "percentage completed" while FFMpeg does its work.

我FFmpeg的使用,最近的FFmpeg的版本现在支持一个新的进步标志产生的日志文件。下面我会告诉你的方式来使用日志文件中的这个标志,并且还生成的输出。

I got FFMpeg to generate the log file by using a new "progress" flag that recent versions of FFMpeg now support. Below I'll show you the way to use this flag, and also the generated output within the log file.

下面是FFmpeg的命令:

Here's the FFMpeg command:

ffmpeg -i c:\my_original_file.ogg c:\my_converted_file.mp3 -progress c:\my_progress.txt

上面的命令将导致FFmpeg的产生所谓my_progress.txt一个日志文件。

The above command will cause FFMpeg to generate a log file called my_progress.txt.

下面是它在日志文件中生成:

Here's what it generates in the log file:

total_size=206150
out_time_ms=51410044
out_time=00:00:51.410044
dup_frames=0
drop_frames=0
progress=continue

上面的6线在日志文件中反复产生,随着值

The above 6 lines are generated repeatedly in the log file, with increasing values.

total_size=206150
out_time_ms=51410044
out_time=00:00:51.410044
dup_frames=0
drop_frames=0
progress=continue
total_size=412413
out_time_ms=102975756
out_time=00:01:42.975756
dup_frames=0
drop_frames=0
progress=continue
total_size=618363
out_time_ms=154463111
out_time=00:02:34.463111
dup_frames=0
drop_frames=0
progress=continue
total_size=824939
out_time_ms=206107189
out_time=00:03:26.107189
dup_frames=0
drop_frames=0
progress=continue

最后,在作业完成时,6行的最后一块是最后的日志文件。请注意,进度=结束的最后一行:

Finally, when the job completes, the final block of 6 lines are the last ones in the log file. Notice the "progress=end" on the last line:

total_size=9725902
out_time_ms=2431348011
out_time=00:40:31.348011
dup_frames=0
drop_frames=0
progress=end

我想用CFFILE标签读取该文件(不管是大的文件已)中的只有最后6行的写一个ColdFusion脚本,而这每一次做脚本被调用时,由浏览器,通过Ajax。最后,我需要解析在这些线路上的值到变量,以便我可以将某些数据返回给调用者。

I want to write a Coldfusion script using the CFFILE tag to read only the last 6 lines of the file (no matter how large the file has become), and to do this each time the script is called, by the browser, via Ajax. Finally I need to parse the values on these lines into variables so I can return some data to the caller.

我已经研究进度条的FFmpeg的,但他们是在PHP这对我来说很难,而且,他们分析了FFmpeg的日志文件的旧格式的版本,我想用上面的新格式。任何人都可以请帮助?

I've researched progress bars for FFMpeg but they're in PHP which is hard for me, and besides, they parse the older formatted versions of FFMpeg's log files, and I would like to use the above newer formatting. Can anyone please help?

推荐答案

要取得最后六行 <强>尾 会更快,因为它会在后台工作,只加载你的要求(而不是读整个文件,然后通过它循环)。这会明显地也使用更少的内存,无论文件大小。

To get the last six lines tail will be faster, since it works backwards and only loads what you ask for (rather than reading in the whole file then looping through it). It'll obviously also use less memory, no matter the file size.

<cfexecute
    name      = "tail"
    arguments = "--lines=6 #Filename#"
    timeout   = 30
    variable  = "LastSixLines"
    />

<cfset Data = {} />
<cfloop index="CurLine" array=#LastSixLines.trim().split('\n')# >
    <cfset Data[ListFirst(CurLine,'=')] = ListRest(CurLine,'=') />
</cfloop>


当你似乎是在Windows上,您可能需要安装尾(它的pre-安装Linux和MacOS)。最简单的选项,以获取这将是 MSYS ,这取决于你用​​什么样的软件,你可能已经有 - 例如,混帐for Windows使用MSYS,并在其bin文件夹已经tail.exe。


As you appear to be on Windows, you likely need to install tail (it's pre-installed for Linux and MacOS). The simplest option to get it would be MSYS, which you may already have depending on what other software you use - for example, Git for Windows uses MSYS, and has tail.exe in its bin folder.

在这种情况下,第二行上述变化到这样的:

In that case, the second line above changes to something like:

    name      = "C:/Program Files/Git/bin/tail"

如果您需要在code工作在多个系统上,可以使这部分变量,(或出台相应的目录到系统路径,以便它可以从任何地方调用)。

If you need the code to work on multiple systems, you can make that part a variable, (or put the appropriate directory onto the system PATH so it can be called from anywhere).

这篇关于使用ColdFusion的CFFILE标签来监控从FFmpeg的进度日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆