Jump to content

FileGetSize() problem


Go to solution Solved by InnI,

Recommended Posts

Posted (edited)

I have a camera recording video via ffmpeg, but the video's file size doesn't seem to update when periodically checked via FileGetSize($path). It does update when I manually right click > property and check the file size, or when I reopen the folder containing the video and interact with it in some way. It's like windows isn't actually check when autoit asks, but it does check it when I manually inspect it... if that makes sense?

Do you have to somehow modify the file or trick windows into re-checking the file, before calling FileGetSize()?

Edit: To be more clear, a video file that is periodically written to by ffmpeg, which should be increasing in file size, does not display any increase in file size when checked with autoit. But checking manually in windows I can see the file size increasing.

Edited by lIlIIlIllIIIIlI
rewording
Posted
7 hours ago, lIlIIlIllIIIIlI said:

FileGetSize()

Try with _WinAPI_GetFileSizeEx(), maybe there's a difference.

Some guy's script + some other guy's script = my script!

Posted (edited)

Try this code :

ConsoleWrite(GetSize(@ScriptDir, "Relax.mp4") & @CRLF)

Func GetSize($sDir, $sFile)
  Local $oShellApp = ObjCreate("shell.application")
  Local $oDir = $oShellApp.NameSpace($sDir)
  Local $oFile = $oDir.Parsename($sFile)
  Return $oFile.size
EndFunc

or simply :

ConsoleWrite(GetSize(@ScriptDir, "Relax.mp4") & @CRLF)

Func GetSize($sDir, $sFile)
  Local $oShellApp = ObjCreate("shell.application")
  Return $oShellApp.NameSpace($sDir).Parsename($sFile).size
EndFunc

 

Edited by Nine
Posted

Script1 (add data to file)

$b = DllStructGetData(DllStructCreate("byte[1024]"), 1)
$f = FileOpen("test.txt", 2 + 16)
For $i = 0 To 99
  Sleep(500)
  FileWrite($f, $b)
Next
FileClose($f)

Run this script during script execution Script1 (file size does not change without open/close file)

$path = "test.txt"
For $i = 0 To 99
  Sleep(500)
  ; FileClose(FileOpen($path))
  ConsoleWrite(FileGetSize($path) & ":" & GetSize(@ScriptDir, "test.txt") & @CRLF)
Next

Func GetSize($sDir, $sFile)
  Local $oShellApp = ObjCreate("shell.application")
  Local $oDir = $oShellApp.NameSpace($sDir)
  Local $oFile = $oDir.Parsename($sFile)
  Return $oFile.size
EndFunc
Posted (edited)
2 hours ago, InnI said:

file size does not change without open/close file

You are right.  I tested on a nvidia recorder and it does not change unless you access the file.
FileClose(FileOpen("file")) does make it work.

Edited by Nine

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...