AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AHK Functions - RandStr()
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Mon Dec 04, 2006 6:59 pm    Post subject: Reply with quote

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


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

Regards, Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
wakewatcher



Joined: 15 Jul 2006
Posts: 139

PostPosted: Mon Dec 25, 2006 6:40 pm    Post subject: Re: AviFileInfo() Reply with quote

Skan wrote:
Quote:
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.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Mon Dec 25, 2006 6:47 pm    Post subject: Reply with quote

Rolling Eyes I do not understand .. Can you explain it, please.
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
wakewatcher



Joined: 15 Jul 2006
Posts: 139

PostPosted: Mon Dec 25, 2006 7:19 pm    Post subject: Reply with quote

Sorry for my lame explanation. (It's been a late night - early morning for me with Christmas and all Very Happy ) 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 http://www.wakewatcher.redirect.hm/football/2005/index.html 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.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Mon Dec 25, 2006 7:48 pm    Post subject: Re: AviFileInfo() Reply with quote

wakewatcher wrote:
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 ? Rolling Eyes
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
wakewatcher



Joined: 15 Jul 2006
Posts: 139

PostPosted: Mon Dec 25, 2006 8:11 pm    Post subject: Reply with quote

In linux we use "tcextract -x dv" (http://www.transcoding.org/cgi-bin/transcode?Tcextract) 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.)
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Mon Dec 25, 2006 8:26 pm    Post subject: Reply with quote

wakewatcher wrote:
(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 Sad. Maybe you can post it in the ask-for-help section and someone else might have an answer.

Regards, Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
wakewatcher



Joined: 15 Jul 2006
Posts: 139

PostPosted: Mon Dec 25, 2006 8:53 pm    Post subject: Reply with quote

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

http://www.autohotkey.com/forum/viewtopic.php?t=14395

And you pointed me here. Very Happy

But again thanks for the effort and speedy responses. I'll try some of the video forums (www.doom9.net but hope to wrap it all together with ahk.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Tue Dec 26, 2006 6:02 am    Post subject: Reply with quote

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

http://www.autohotkey.com/forum/viewtopic.php?t=14395

And you pointed me here. Very Happy


Shocked

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

Laughing

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

Regards, Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Dec 26, 2006 9:50 am    Post subject: Reply with quote

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.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Sat Dec 30, 2006 11:38 am    Post subject: ProcessCreationTime() Reply with quote

Quote:
ProcessCreationTime()

Usage : ProcessCreationTime( ProcessID )

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

Note:
  • 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.

  • 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 or Very Mad )

MSDN Reference :

GetProcessTimes()
FileTimeToLocalFileTime , FILETIME Structure
FileTimeToSystemTime , SYSTEMTIME Structure

OpenProcess()
CloseHandle()
Process Security and Access Rights

The function along with a test:

Code:
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


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
}


_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sun Dec 31, 2006 10:30 am    Post subject: Reply with quote

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. Wink
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Titan



Joined: 11 Aug 2004
Posts: 5068
Location: imaginationland

PostPosted: Sun Dec 31, 2006 12:38 pm    Post subject: Reply with quote

Yeah, and I would use:
Code:
   Loop, 8
      time .= A_Index = 3 ? : *(p := &SysT + (A_Index - 1) * 2) + (*++p << 8)
   Return, time

_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4016
Location: Pittsburgh

PostPosted: Sun Dec 31, 2006 4:17 pm    Post subject: Reply with quote

Titan wrote:
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.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Fri Jan 05, 2007 7:38 pm    Post subject: Reply with quote

Dear PhiLho, Smile

you wrote:
- 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..

Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Page 5 of 7

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group