首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自动检查媒体编码器转换是否完成

自动检查媒体编码器转换是否完成
EN

Stack Overflow用户
提问于 2015-11-25 23:44:05
回答 1查看 75关注 0票数 0

如果Adobe Media Encoder完成将监视文件夹从.avi转换为.mp4,是否可以检入Autoit?

我寻找了一个进程,但找不到可以检查进程是否存在的东西。

EN

回答 1

Stack Overflow用户

发布于 2015-11-26 00:45:02

您可以使用以下代码等待文件创建完成:

代码语言:javascript
复制
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

WaitForAdobeMediaFile(@ScriptDir & "\mp4YouAreLookingFor.mp4")
If @error Then
    MsgBox(262160, "Error", "FileExists timeout error.")
Else
    MsgBox(262208, "", "Adobe Media is done making the file.")
EndIf

Func WaitForAdobeMediaFile($sFilePath, $iFileExistsTimeout = 10000, $iWaitForNoMoreChanges = 5000)
    Local $hTimer, $sFileLastModified

    $hTimer = TimerInit()

    ;wait for timeout or for the file exist
    While 1
        ;if file is found
        If FileExists($sFilePath) Then ExitLoop

        ;if the timeout is hit
        If TimerDiff($hTimer) >= $iFileExistsTimeout Then Return SetError(1)
    WEnd

    $hTimer = TimerInit()

    ;gets the date and time that the file was last modified
    $sFileLastModified = FileGetTime($sFilePath, $FT_MODIFIED, 1)
    While 1
        ;reset the last time the file was modified if there was a change
        If $sFileLastModified <> FileGetTime($sFilePath, $FT_MODIFIED, 1) Then
            $hTimer = TimerInit()
            $sFileLastModified = FileGetTime($sFilePath, $FT_MODIFIED, 1)
        Else
            ;if the file has not been modified for the set amount of time
            If TimerDiff($hTimer) >= $iWaitForNoMoreChanges Then ExitLoop
        EndIf
    WEnd
EndFunc   ;==>WaitForAdobeMediaFile

您可以像这样更改默认超时参数(它们是以毫秒为单位设置的)。

代码语言:javascript
复制
WaitForAdobeMediaFile(@ScriptDir & "\mp4YouAreLookingFor.mp4", 30000, 50000)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33920715

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档