Re: asx file creation
Re: asx file creation
- Subject: Re: asx file creation
- From: nate <email@hidden>
- Date: Tue, 5 Apr 2005 17:49:19 -0700
Brilliant!!! There is a couple of things that are off a bit, but is there a way you can comment some of this so I have a better understanding? let me try and explain a few things a bit more.
Okay the file name for this is 416R04.flx, so the output of the new file would then need to be 416R04.asx also the href would actually need to be the name of the asx file but referencing the actual video file, so <REF href="www.mywebsite.com/416R04.wmv"/>
The script would have to parse a folder for any files named .flx and then move them to maybe an /flx folder or something after it has created an asx file.
100 Edit 0001 to V1234 Field A1 NTSC Split Delay
110 Scene 11 Take 1 Cam Roll A1064 Sound 241 19:45:57:05.0
201 Rnk-X 3P 23.98 A1064 007021+00 000001280 Key EASTM KR292763 007021+00 P1
300 VTR-A Assemble 416R04 At 04:00:00:00.0 For 00:00:53:10.0 Using LTC
400 SOUND Playback 241 At 19:45:57:05.0 For 00:00:53:10.0 Using LTC
The tricky part here is I guess understanding the time code read outs, as the flex file has one format and the asx file has another.
00:53:10.0 For
00:47:25.0 <-Flex file, okay we drop the first 2 digits as that is tape number and we don't care about that in asx land, so we have 00:53:10.0, now we don't need anything after the decimal either which is field values, asx doesn't care about this, so that leaves us with 00:53:10, now the tricky part here is asx wants this format "hours:minutes:seconds", but the flex file is in "hours:minutes:frame", (ultimately it's "tape:hours:minutes:frames.field", but we don't need the other stuff)
there are 29.97 frames in a second, so there is some math there.. so for 5 frames x = 5/29.97, would actually be .167 seconds but as asx doesn't care about 10ths of a second only whole seconds so I guess this is irrelevant anyway, maybe round down to keep a whole second in front of the time being requested? let me know if you need more info, I think I included everything.
I hope I am not being nit-picky or anything, and I really appreciate the help here. I also apologize for the lengthy nature of this email.
-nate
On Apr 1, 2005, at 12:09 PM, kai wrote:
On Mon, 28 Mar 2005 14:49:26 -0800, nate wrote:
Hello, I currently have a web server up and running on osx and I want to use applescript or maybe perl? I'm not sure which yet to perform a sort of file conversion if you will. I am looking to have it parse a text file and output it in other format, basically it's coming from a text file and going to an asx file (which is really just an xml output).
here is a brief input file with 2x records.
----
000 Manufacturer Ascent No. 999 Equip AM-LOG Version 7.51 FLEx 1007
010 Title ALIAS
011 Client Facility
012 Shoot Date Transfer Date 02-14-05 Opr PDD Asst Bay
100 Edit 0001 to V1234 Field A1 NTSC Split Delay
110 Scene 11 Take 1 Cam Roll A1064 Sound 241 19:45:57:05.0
201 Rnk-X 3P 23.98 A1064 007021+00 000001280 Key EASTM KR292763 007021+00 P1
300 VTR-A Assemble 416R04 At 04:00:00:00.0 For 00:00:53:10.0 Using LTC
400 SOUND Playback 241 At 19:45:57:05.0 For 00:00:53:10.0 Using LTC
100 Edit 0002 to V1234 Field A1 NTSC Split Delay
110 Scene 11 Take 2 Cam Roll A1064 Sound 241 19:49:13:14.0
201 Rnk-X 3P 23.98 A1064 007080+00 000001148 Key EASTM KR292763 007080+00 P3
300 VTR-A Assemble 416R04 At 04:00:53:10.0 For 00:00:47:25.0 Using LTC
400 SOUND Playback 241 At 19:49:13:14.0 For 00:00:47:25.0 Using LTC
----
the output would need to look like:
----
<ASX version="3.0">
<TITLE>Alias</TITLE>
<ENTRY>
<TITLE>Edit 0001 to V1234</TITLE>
<REF href="Alias.WMV"/>
<STARTTIME VALUE="00:00:00" />
<DURATION VALUE = "00:00:53"/>
</ENTRY>
<ENTRY>
<TITLE>Edit 0002 to V1234</TITLE>
<REF href="Alias.WMV"/>
<STARTTIME VALUE="00:00:53" />
<DURATION VALUE = "00:00:47"/>
</ENTRY></ASX>
----
So what I am asking I guess, is, is this even doable? If so, how do I even begin? O.O
Any help is much appreciated.
Looks as if this question might have been overlooked, Nate - so I'll take a crack at it, FWIW...
In theory, AppleScript should be able to parse the input data into the form you require - with a few qualifications:
[1] It's not easy to tell if the data received here had extra spaces introduced (particularly at line endings) when sending. I've therefore had to use some guesswork about that. (I'm not that familiar with asx files.)
[2] I also couldn't work out how you derived the start times in the output data - since they look slightly different from those in the input data. I've assumed the differences were the result of a couple of small errors - and continued regardless. (Like some of my other vices, I try to keep assumptions to a minimum - but not always with resounding success...)
[3] Finally, the following example was based on certain information consistently appearing on the same line numbers (010, 100, 300, etc.)
If necessary, it should be fairly simple to fix the first couple of points. The last one might be resolved with a little more care. The main point here is merely to demonstrate that this sort of thing should be perfectly possible.
I've tried to keep the lines fairly short to avoid too much wrapping - though some instances may still occur (and the input data towards the end is almost *bound* to break up). Anyway, if you want to pursue this approach, and still need some more help, just shout.
Um... sorry about the length, folks:
--------------------
property uCase : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
property lCase : "abcdefghijklmnopqrstuvwxyz"
property tabStr : " " (* 4 spaces *)
property retStr : ASCII character 10
property timeTags : {{" At ", "STARTTIME"}, {" For ", "DURATION"}}
on capsToLowerCase(l)
repeat with n from 1 to count l
set text item delimiters to l's item n
if (count uCase's text items) > 1 then set l's item n to ¬
lCase's item (1 + (count uCase's text item 1))
end repeat
set text item delimiters to {""}
l
end capsToLowerCase
on capsToTitleCase(t)
set l to {}
set s to 1
tell t to repeat with n from 2 to (count words)
set e to (count (text 1 thru word n)) - (count word n)
set l's end to item s & my ¬
capsToLowerCase(items (s + 1) thru e)
set s to e + 1
end repeat
set l's end to t's item s
if s is (count t) then return l as string
(l as string) & capsToLowerCase(t's items (s + 1) thru -1)
end capsToTitleCase
on dataToASX(d)
set l to {}
set text item delimiters to "010 Title "
set d to d's text item -1
set text item delimiters to retStr
set mTitle to capsToTitleCase(d's text item 1)
set l to {"<TITLE>" & mTitle & "</TITLE>"}
set text item delimiters to retStr & "100 "
repeat with e in (get rest of d's text items)
set l's end to "<ENTRY>"
set text item delimiters to tabStr
set l's end to "<TITLE>" & e's text item 1 & "</TITLE>"
set l's end to "<REF href=\"" & mTitle & ".WMV\"/>"
set text item delimiters to retStr & "300 "
set e to e's text item -1
set text item delimiters to retStr
set e to e's text item 1
repeat with t in timeTags
set text item delimiters to t's item 1
set l's end to "<" & t's item 2 & " VALUE=\"" & ¬
(e's text item -1)'s text 1 thru 8 & "\"/>"
end repeat
set l's end to "</ENTRY>"
end repeat
set text item delimiters to retStr
set l to "<ASX version=\"3.0\">" & retStr & l & "</ASX>"
set text item delimiters to {""}
l
end dataToASX
set inputData to "000 Manufacturer Ascent No. 999 Equip AM-LOG Version 7.51 FLEx 1007
010 Title ALIAS
011 Client Facility
012 Shoot Date Transfer Date 02-14-05 Opr PDD Asst Bay
100 Edit 0001 to V1234 Field A1 NTSC Split Delay
110 Scene 11 Take 1 Cam Roll A1064 Sound 241 19:45:57:05.0
201 Rnk-X 3P 23.98 A1064 007021+00 000001280 Key EASTM KR292763 007021+00 P1
300 VTR-A Assemble 416R04 At 04:00:00:00.0 For 00:00:53:10.0 Using LTC
400 SOUND Playback 241 At 19:45:57:05.0 For 00:00:53:10.0 Using LTC
100 Edit 0002 to V1234 Field A1 NTSC Split Delay
110 Scene 11 Take 2 Cam Roll A1064 Sound 241 19:49:13:14.0
201 Rnk-X 3P 23.98 A1064 007080+00 000001148 Key EASTM KR292763 007080+00 P3
300 VTR-A Assemble 416R04 At 04:00:53:10.0 For 00:00:47:25.0 Using LTC
400 SOUND Playback 241 At 19:49:13:14.0 For 00:00:47:25.0 Using LTC"
dataToASX(inputData)
--------------------
(*
--> "<ASX version=\"3.0\">
<TITLE>Alias</TITLE>
<ENTRY>
<TITLE>Edit 0001 to V1234</TITLE>
<REF href=\"Alias.WMV\"/>
<STARTTIME VALUE=\"04:00:00\"/>
<DURATION VALUE=\"00:00:53\"/>
</ENTRY>
<ENTRY>
<TITLE>Edit 0002 to V1234</TITLE>
<REF href=\"Alias.WMV\"/>
<STARTTIME VALUE=\"04:00:53\"/>
<DURATION VALUE=\"00:00:47\"/>
</ENTRY></ASX>"
*)
--------------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden