If it is so, that your text has control characters at the end of it, then this way, may do the trick:
I always hope it is as easy as that.
set a to "20:30:47:15ÃŽ"
set b to words of (text 1 thru 11 of a)
b
if you should have to change from BigEndian to SmallEndian, then I think the Unix tool dd can be handy, just another option, as I think Nigel’s method is the easiest one.
Edit
The swab option of dd isn’t usable, since it only swaps odd and even bytes.
Perl has its pack and unpack functions that is usuable.
set duree_a_traiter to ((characters 1 thru -2 of duree_a_traiter) as string)
And i checked how many char i could remove at the end without removing any actual value i need, i came to 2.
I can remove 2 char with this command and it doesnt affect my value. I must have invisible char in the log.
Of course the answer is NO.
Compare the time where I post my first message with the time when you posted the link.
Try to replace the instruction reading the file by this one :
set fichierSource to ((path to desktop as text) & "ArchivePlay.log")
tell application "TextWrangler"
activate
open fichierSource
zap gremlins text of document 1 with nulls
set bigtext to text of document 1
close document 1 saving no
end tell
The file to which you’ve linked seems OK and the text it contains is little-endian UTF-16.
The times you’re trying to convert to seconds look like SMPTE codes, where the figures after the decimal point are frames, probably in 25ths of a second.
Assuming you’ve used my previous code to get the text into the script properly, you can convert ‘duration’ to seconds like this:
set duration to item 8 of enregistrement_a_traiter2 -- existing line.
tell duration to set duration to (word 1) * hours + (word 2) * minutes + (word 3)
set duration to duration div 1 + (duration mod 1) * 4
But i dont need the exact frame count, as i cannot trim my movie to a specific frame in qt… Thats why i added a an extra second at the end of each clip i wanted to trim.
The +9 is because i have a 10 seconds white in between each clips on my big video file (the one i’m segmenting with this script)
If there is a way to trim to,the exact frame thzt would be awsome but i didnt find anything.
By the way, i tried to process my log with your scriot but the result was the same, the number could not be used as integer…
The only working solution for now is the textwrangler one
Thanks a lot to everyone helping in this thread ')
zap gremlins‚v : Removes or replaces unwanted characters from text
zap gremlins specifier : the text to be processed
[zap action delete_gremlin/Œreplace_with_code/Œreplace_with_char] : action to be performed on gremlin characters (defaults to delete_gremlin)
[zap character text] : character to use as the replacement with “replace_with_char” is used
[nulls boolean] : zap null (ASCII 0) characters?
[controls boolean] : zap control characters?
[non ASCII characters boolean] : zap non-ASCII characters?
→ text : the modified text
En bon Français, la commande :
zap gremlins text of document 1 with nulls
supprime les octets nuls du texte.
De ce fait le script peut traiter du texte sans « parasites ».
This can do almost the same, but you’ll loose the linefeeds, so you are back into square one, with a sed script for getting the data out of the log.
tr -d “[:control:]” <ArchivePlay.log >|new.log
The unix command tr - translit can be invoked from the command line to to this. There is no problem on doing that comand on every paragraph of your logfile, paragraph by paragraph by a do shell script.
This was interesting, and i did find something to work for you, I did this with the logfile you posted, and I got sane characters back, when I looked at it in Script Debugger:
set muf8 to (do shell script "iconv -f UTF-16LE -t UTF-8 /Users/you/your/path/To/Nigels/fixed/Logfile")
# Now the text should be able to be processed as you wanted it to.
Awesome !!!
This is perfect.
Yvan predict that you would do some magic here; and you did.
Thanks a lot.
I’ll post the whole script when i’ll be done. Might be usefull to others.
In fact, I tought to Nigel (apologizes for the typo in my original message)
I’m not sure of who is behind the pseudo McUsrII.
Maybe it’s my old acquintance McUsr but I’m not sure so I was unable to guess that he would deliver a magical incantation before Nigel.
since you’re around, would you know how to trim in quictime to an exact frame?
I looked into the dictionary of quictime 7 (qt X doesnt mention frames), and apparently it s possible to use frames. But it is possible to use frame to trim?
edit : nevermind, i found what i was looking for. The syntax is different. I had to do thid
tell document 1
select at in_point to out_point
trim
end tell