Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHK Functions :: InCache() - Cache List of Recent Items


  • Please log in to reply
172 replies to this topic
SKAN
  • Administrators
  • 9114 posts
  • Last active:
  • Joined: 26 Dec 2005

To get total space of disk, use Return SPC * BPS * TC instead of Return SPC * BPS * FC...


Valuable Tip. I did not notice it! :oops: Thanks!
I have changed the code to reflect the suggestion.
Thanks to Ternary Operator, I could do it without an increase of line.

Regards, :)

wakewatcher
  • Members
  • 254 posts
  • Last active: Oct 04 2011 10:03 PM
  • Joined: 15 Jul 2006

AviFileInfo()

Returns the video properties of an AVI file as a pipe delimited string.


I'm trying to determine the start/end timestamps/codes for video clips as I'm trying to sync up multiple camera angles. Is there a way to determine the start time/code, e.g, yr:mm:day:hr:min:sec:frame? Then I suppose I can add the duration to figure out the end information. Thanks.

SKAN
  • Administrators
  • 9114 posts
  • Last active:
  • Joined: 26 Dec 2005
:roll: I do not understand .. Can you explain it, please.

wakewatcher
  • Members
  • 254 posts
  • Last active: Oct 04 2011 10:03 PM
  • Joined: 15 Jul 2006
Sorry for my lame explanation. (It's been a late night - early morning for me with Christmas and all :D ) This is what I'm doing: I've got two cameras taking sports video clips more or less concurrently. (Videos of my son's American football games.) I pull these off the cameras which makes separate avi files of each football 'play' from two different angles. After getting the clips loaded I need to paste them together syncronized. (The coaches use these for coaching my son's team.) See <!-- m -->http://www.wakewatch... ... index.html<!-- m --> for a low rez example) I've got this all working with Linux but want to port it to windows and use AHK for the scripting language to pull it all together. (Right now there is a lot of hand work getting the angles sync'd later I figure I can also use some of the recent ahk avi gui stuff to ultimately help out there as well.) Anyway in order to syncronize the clips I need to see where they start and stop. So by taking the starting and ending timestamps (or starting timestamp and duration) of each camera I can determine which video clips need to be glued together. (This assumes the cameras are more or less sync'd to start with which they are.) Hope this helps explain what I'm trying to do.

SKAN
  • Administrators
  • 9114 posts
  • Last active:
  • Joined: 26 Dec 2005

Is there a way to determine the start time/code, e.g, yr:mm:day:hr:min:sec:frame? Then I suppose I can add the duration to figure out the end information.


After re-reading number of times, I am more confused.

I guess an avi file stores just the duration inside the avi file.

yr:mm:day:hr:min:sec: can be retrieved from the file creation date (of the avi file) , and can be correct to a certain extent - provided both the cameras are sync`ed with the same clock time.

Number of frames can be retrieved with API as demonstrated by me.

What Am I missing ? :roll:

wakewatcher
  • Members
  • 254 posts
  • Last active: Oct 04 2011 10:03 PM
  • Joined: 15 Jul 2006
In linux we use "tcextract -x dv" (<!-- m -->http://www.transcodi...scode?Tcextract<!-- m -->) to pull the dv stream out of the avi and the dv stream contains the time stamps/codes for each frame. Then have a utility (based on linux dv libraries) to figure out the start and stop times (to the resolution of the frames within each second) of each clip. (The clip lengths are generally only around 10 seconds each.) Unfortunately the avi file creation date doesn't give you the time that the clip was taken just the time it was pulled off the camera. I appreciate you for taking the time to at least understand what I'm trying to do. (Even if its not possible.)

SKAN
  • Administrators
  • 9114 posts
  • Last active:
  • Joined: 26 Dec 2005

(Even if its not possible.)


I not sure whether it is impossible. I am just a noob when it comes to AVI. I have not played much with that stuff.

I feel sorry for not being able to help you :(. Maybe you can post it in the ask-for-help section and someone else might have an answer.

Regards, :)

wakewatcher
  • Members
  • 254 posts
  • Last active: Oct 04 2011 10:03 PM
  • Joined: 15 Jul 2006
I did ask on the ask-for-help section. (Well on the same basic topic.)

http://www.autohotke...pic.php?t=14395

And you pointed me here. :D

But again thanks for the effort and speedy responses. I'll try some of the video forums (http://www.doom9.net but hope to wrap it all together with ahk.

SKAN
  • Administrators
  • 9114 posts
  • Last active:
  • Joined: 26 Dec 2005

I did ask on the ask-for-help section. (Well on the same basic topic.)

http://www.autohotke...pic.php?t=14395

And you pointed me here. :D


:shock:

I completely forgot that it was you for whom I had written this function.

:lol:

Anyways. Try bumping that ask-for-help topic. Someone more knowlegeable might help us.

Regards, :)

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
I am not really knowedgeable of the AVI format, but I know it is just a shell format containing various video encodings. The AVI info just provide generic info, not info specific to one encoding (AFAIK!).
I suggest you locate a Windows utility to manipulate or extract info from your specific codec, perhaps there is a Windows port of your Linux utility.

SKAN
  • Administrators
  • 9114 posts
  • Last active:
  • Joined: 26 Dec 2005

ProcessCreationTime()

Usage : ProcessCreationTime( ProcessID )

ProcessCreationTime() ascertains the creation time for an existing process and returns a time string in YYYYMMDD24MISS format.

Note:[*:1jjbaiji]If an invalid PID or a null is passed, the function returns a standard timestamp in UTC : 16010101000000 i.e., Zero hour on 1st January 1601. But, for me it will be 16010101053000 as my timezone is UTC+ 5hr 30m.

[*:1jjbaiji]Does not return correctly for Windows Explorer instances. It will be creation time of explorer.exe.
Reference:

Ask-for-Help Topic : Window (or process) creation time? - evl, Micha, shimanov ( Thanks! )
Ask-for-Help Post : VBS_ProcessCreationTime() - Skan ( Slow and ugly :evil: )

MSDN Reference :

GetProcessTimes()
FileTimeToLocalFileTime , FILETIME Structure
FileTimeToSystemTime , SYSTEMTIME Structure

OpenProcess()
CloseHandle()
Process Security and Access Rights

The function along with a test:

[color=#808080]Winget, PM_PID, PID, ahk_class Progman
cTime := ProcessCreationTime( PM_PID )
MsgBox, 0, ProcessCreationTime(), %cTime%
FormatTime, cTime, %cTime%
MsgBox, 0, Program Manager created on , %cTime%

Return[/color]

ProcessCreationTime( PID ) {                        ; Requires AutoHotkey v1.0.46.03+

 VarSetCapacity(PrCT,16)  ,  VarSetCapacity(Dummy,16)  ,  VarSetCapacity(SysT,16)

 AccessRights := 1040       ; PROCESS_QUERY_INFORMATION = 1024,  PROCESS_VM_READ = 16
 hPr:=DllCall( "OpenProcess", Int,AccessRights, Int,0, Int,PID )
 DllCall( "GetProcessTimes" , Int,hPr, Int,&PrCT, Int,&Dummy, Int,&Dummy, Int,&Dummy)
 DllCall("CloseHandle"      , Int,hPr)

 DllCall( "FileTimeToLocalFileTime" , Int,&PrCT, Int,&PrCT )  ; PrCT is Creation time
 DllCall( "FileTimeToSystemTime"    , Int,&PrCt, Int,&SysT )  ; SysT is System Time

 Loop 16   {       ; Extracting and concatenating 8 words from a SYSTEMTIME structure
  Word := Mod(A_Index-1,2) ? "" :  *( &SysT +A_Index-1 ) + ( *(&SysT +A_Index) << 8 )
  Time .= StrLen(Word) = 1 ? ( "0" . Word ) : Word  ; Prefixing "0" for single digits
           } 

Return SubStr(Time,1,6) . SubStr(Time,9,8) ; YYYYMMDD24MISS
}


** Edit: Shortened/Optimised code posted on 04-Nov-2009 **
ProcessCreationTime( PID ) {                       
 hPr := DllCall( "OpenProcess", UInt,1040, Int,0, Int,PID )
 DllCall( "GetProcessTimes", UInt,hPr, Int64P,UTC, Int,0, Int,0, Int,0 )
 DllCall( "CloseHandle", Int,hPr)
 DllCall( "FileTimeToLocalFileTime", Int64P,UTC, Int64P,Local ), AT := 1601
 AT += % Local//10000000, S
 Return AT
}


PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Nice, you got rid of WSH finally...
Two quick remarks, after a glance at your code:
- Again, unless explicitely needed by the API, prefer UInt to Int, at least for handles and pointers.
- I would rewrite Time .= StrLen(Word) = 1 ? ( "0" . Word ) : Word as Time .= SubStr("0" . Word, -1, 2)
Since you like short code, it should please you. ;-)

polyethene
  • Administrators
  • 5517 posts
  • Last active: Oct 19 2014 02:44 PM
  • Joined: 26 Oct 2012
Yeah, and I would use:
Loop, 8

		time .= A_Index = 3 ? : *(p := &SysT + (A_Index - 1) * 2) + (*++p << 8)

	Return, time


Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005

I would use...

I was sure you would. But you teach bad style for beginners. Your code is clever, it works in AHK, but it could fail with an optimizing compiler, which can reorder terms, drop the ones not affecting the output, etc. Even AHK stops early at evaluating Boolean expressions, when the result would not change with the rest. You would have to disable optimizations, resulting in slower code overall.

Side effects, like assigning variables inside expressions, are better avoided. They make the code hard to port, understand, debug, maintain and they prevent automatic optimizations. At least provide a clean version next to a highly optimized one.

SKAN
  • Administrators
  • 9114 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear PhiLho, :)

- Again, unless explicitely needed by the API, prefer UInt to Int, at least for handles and pointers.


Can you please explain the difference between Signed and Unsigned Integer. That is one thing I have not been able to figure out.

Please..

:)