如何将ffmpeg转码过程信息链接到vb6 GUI应用程序中?

发布于 2024-07-20 11:19:23 字数 846 浏览 1 评论 0原文

我正在使用 ffmpeg 的 vb6 gui 前端,到目前为止我所能做的就是通过 cmd.exe 调用 ffmpeg,这将在整个过程仍在运行时显示命令提示符。 我认为这是 WinFF(另一个基于 pascal 的 ffmpeg 前端 gui)如何工作的常态。

但当我看到另一个 GVC gui 时,我被震惊了,它有一个进度条和一切。

所以基本上,我正在寻找一种方法,如何干净地隐藏整个命令提示符并将转码进度链接到我的 GUI 中的进度条。

所以这是我的计划,我正在考虑找到一个 win32 api 函数,我可以调用 cmd 行并隐藏它,并且 从这里的另一个讨论,我想我必须阅读日志文件才能获取 ffmpeg 进度信息。

那么我应该为 win32 api 调用哪个函数呢? 有谁知道更好/更简单的方法来完成这项工作? 谢谢

更新:

如果有人感兴趣,我找到一个 关于如何获取cmd 输出到我的 vb6 应用程序中,这正是伟大的 joacim :)

i'm playing with a vb6 gui frontend for ffmpeg and as of now all i can do is to call the ffmpeg via cmd.exe which will shows the command prompt while the whole process is still running. And i thought this was the norm seeing how WinFF, another pascal based frontend gui for ffmpeg works.

But i was blown away when i saw this other GVC gui which has a progress bar and everything.

So basically, i'm looking into a way how i could cleanly hide the whole command prompt and link the transcoding progress to a progress bar into my gui.

So here's my plan, I'm thinking of finding a win32 api function which i can call the cmd line and yet hide it, and from another discussion here, i think i would have to read the log file to get the ffmpeg progress information.

So which function should i call for the win32 api?
And does anyone knows of a better/easier way to get this done?
thanks

Updates:

In case anybody is interested, i find a nice class module on how to grab the cmd output into my vb6 app, and it's by none other than the great joacim :)

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

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

发布评论

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

评论(2

书间行客 2024-07-27 11:19:23

我在 OSX 上为 Java 编写了完全相同的东西。 非常简约的逻辑:

  • 您需要在生成 ffmpeg 输出时读取它。
  • 逐行解析输出(CR 和 LF)
    • 找到“持续时间”行,将时间值存储为整数秒。 “持续时间:00:03:18.48,开始:0.000000,比特率:274 kb/s”(CRLF 终止)
    • 从该点开始,解析 CR 并查找完成时间(以秒为单位)值。 “帧= 2816 fps=667 q=11.0 Lsize= 13036kB 时间=187.66比特率= 569.1kbits/s”(CR 终止,无 LF)
    • 除以(时间/持续时间)即可得出百分比!

我不相信将 ffmpeg 写入日志文件会起作用。 至少在 *nix 上,ffmpeg 将此输出写入 std err,并且您需要捕获的状态行没有换行符,因此会覆盖之前的状态行。 这是您可以在自己的代码中克服的问题。

抱歉,无法帮助解决 VB6 部分,但假设可以直接捕获您 shell 进程的输出。

I have written this exact same thing for Java on OSX. Very minimalist logic:

  • You need to read ffmpeg output as it is produced.
  • Parse the output line by line (both CR and LF)
    • Find the 'Duration' line, store the time value as seconds in an integer. "Duration: 00:03:18.48, start: 0.000000, bitrate: 274 kb/s" (CRLF terminated)
    • From that point onward, parse the CR and look for the time (in seconds) completed values. "frame= 2816 fps=667 q=11.0 Lsize= 13036kB time=187.66 bitrate= 569.1kbits/s" (CR terminated, no LF)
    • Do the division (time / duration) and you have a percentage!

I do not believe having ffmpeg write to a log file is going to work. On *nix at least, ffmpeg writes this output to std err, and the status lines that you need to capture do not have a line feed, and so overwrite the previous status line. This is something you can overcome within your own code.

Sorry, can't help with the VB6 part, but would assume it is straight forward to capture output from a process you shell out.

浪菊怪哟 2024-07-27 11:19:23

首先请原谅我的英语,我说的是西班牙语。
我找到了答案。
1/首先放入预设,我有这个例子“输出格式 MPEG2 DVD HQ”

-vcodec mpeg2video -vstats_file MFRfile.txt -r 29.97 -s 352x480 -aspect 4:3 -b 4000k -mbd rd -trellis -mv0 -cmp 2 -subcmp 2 -acodec mp2 -ab 192k -ar 48000 -ac 2

这条指令可以制作一个 txt 文件,不要忘记将命令 -vstats_file Mitxt.txt 包含到预设中,例如例子。 这可以在您的文件 Source 的文件夹源中生成一个 ubicadet 报告。 如果你愿意,你可以输入任何名称,然后你可以用这个例子阅读这个txt。

Private Sub Timer1_Timer()
 Dim strLastLine As String
 'For example my ruta "C:\Documents and Settings\Gortiz\Mis documentos\file.txt"

 strLastLine = ReadLastLineOfFile("C:\Documents and Settings\Gortiz\Mis _ documentos\file.txt")
 Lst1.AddItem strLastLine
End Sub

Function ReadLastLineOfFile(sFileName As String) As String
 Dim objFSO, TS
 Dim sTmpContents As String
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set TS = objFSO.OpenTextFile(sFileName, 1)
 sTmpContents = TS.ReadAll
 TS.Close
 Set TS = Nothing
 Set objFSO = Nothing

 ReadLastLineOfFile = Split(sTmpContents, vbCrLf)(UBound(Split(sTmpContents, vbCrLf)) - 1)
End Function

在名为 Lst1 的列表框中,您可以看到结果。 比特率、处理帧数、处理时间(以秒为单位)。 ETC

First excuse my english i'm speak on spanish.
I find the answer.
1/First put in the presets, i have this example "Output format MPEG2 DVD HQ"

-vcodec mpeg2video -vstats_file MFRfile.txt -r 29.97 -s 352x480 -aspect 4:3 -b 4000k -mbd rd -trellis -mv0 -cmp 2 -subcmp 2 -acodec mp2 -ab 192k -ar 48000 -ac 2

This instruction can make a txt file don't forget includes the commands -vstats_file Mitxt.txt into the presets like the example. this can make a report which it's ubicadet in the folder source of your file Source. you can put any name if you want , then you can read this txt withthis example.

Private Sub Timer1_Timer()
 Dim strLastLine As String
 'For example my ruta "C:\Documents and Settings\Gortiz\Mis documentos\file.txt"

 strLastLine = ReadLastLineOfFile("C:\Documents and Settings\Gortiz\Mis _ documentos\file.txt")
 Lst1.AddItem strLastLine
End Sub

Function ReadLastLineOfFile(sFileName As String) As String
 Dim objFSO, TS
 Dim sTmpContents As String
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set TS = objFSO.OpenTextFile(sFileName, 1)
 sTmpContents = TS.ReadAll
 TS.Close
 Set TS = Nothing
 Set objFSO = Nothing

 ReadLastLineOfFile = Split(sTmpContents, vbCrLf)(UBound(Split(sTmpContents, vbCrLf)) - 1)
End Function

in a listbox called Lst1 you can saw the result which is. Bitrate, proceced Frames, Time of process in seconds. etc

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