Friday, October 24, 2014

#26 2012-12-04 01:30:37 pm

BenJi
Member
From: France
Registered: 2012-11-23
Posts: 30

Re: Parsing infos/numbers

Here the log file of today : http://c-and-d.fr/perso/ArchivePlay.log

Offline

 

#27 2012-12-04 01:50:00 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 1520

Re: Parsing infos/numbers

I ran the script with the sample datas which you posted.
So, there weren’t the extraneous nil bytes.

Yvan KOENIG (VALLAURIS, France) mardi 4 décembre 2012 20:49:55

Offline

 

#28 2012-12-04 01:53:06 pm

BenJi
Member
From: France
Registered: 2012-11-23
Posts: 30

Re: Parsing infos/numbers

You ran the sxript on the archiveplay.log i just posted and you are able to se the dur_sec value?

Offline

 

#29 2012-12-04 02:20:18 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 1520

Re: Parsing infos/numbers

BenJi wrote:

You ran the sxript on the archiveplay.log i just posted and you are able to se the dur_sec value?

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 :

Applescript:


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

With your sample file it works.

Yvan KOENIG (VALLAURIS, France) mardi 4 décembre 2012 21:20:14

Offline

 

#30 2012-12-04 02:34:34 pm

Nigel Garvey
Moderator
From: Warwickshire, England
Registered: 2002-11-19
Posts: 3549

Re: Parsing infos/numbers

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:

Applescript:

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


NG

Offline

 

#31 2012-12-04 02:37:14 pm

BenJi
Member
From: France
Registered: 2012-11-23
Posts: 30

Re: Parsing infos/numbers

@yvan This isna big step forward!
This works for me and my log file!

Thanks a lot for the tip.

The only thing is that i will have to install text wrangler on my process machine and use it in addition...

What does exactly do textwrangler that cant be made in applescript?

I dont quite understand your bit of script.


Anyway thanks a lot for the tip!

Last edited by BenJi (2012-12-04 02:38:29 pm)

Offline

 

#32 2012-12-04 02:43:59 pm

BenJi
Member
From: France
Registered: 2012-11-23
Posts: 30

Re: Parsing infos/numbers

Nigel Garvey wrote:

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:

Applescript:

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

Exactly, these are smpte timecodes

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 ')

Last edited by BenJi (2012-12-04 02:47:33 pm)

Offline

 

#33 2012-12-04 02:46:07 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 1520

Re: Parsing infos/numbers

BenJi wrote:

@yvan This isna big step forward!
This works for me and my log file!

Thanks a lot for the tip.

The only thing is that i will have to install text wrangler on my process machine and use it in addition...

What does exactly do textwrangler that cant be made in applescript?

I dont quite understand your bit of script.


Anyway thanks a lot for the tip!

Encore un français qui ne juge pas utile d'ouvrir le dictionnaire des applications utilisées !

Je le fais donc pour vous :

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 ».

Il y a probablement moyen d'effectuer le nettoyage autrement.
Je cherchais avant tout à donner au plus vite une formule opérationnelle.
Maintenant que le problème est clairement identifié je suis sur que Niget va vous concocter une incantation magique effectuant le nettoyage sans aspirateur.

Yvan KOENIG (VALLAURIS, France) mardi 4 décembre 2012 21:46:00

Offline

 

#34 2012-12-04 02:49:59 pm

BenJi
Member
From: France
Registered: 2012-11-23
Posts: 30

Re: Parsing infos/numbers

Merci mais j'avais ouvert le dico, mais c'est le null que je ne comprenais pas.

Merci pour le tuyeau

For others : the textwrangler tips cleared the file of all unwanted bytes!
But it would be nice not to use another app

Last edited by BenJi (2012-12-04 03:31:33 pm)

Offline

 

#35 2012-12-04 08:22:10 pm

McUsrII
Member
Registered: 2012-11-20
Posts: 2354
Website

Re: Parsing infos/numbers

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.

Last edited by McUsrII (2012-12-04 08:22:59 pm)


Filed under: do shell scipt

Offline

 

#36 2012-12-04 11:51:14 pm

McUsrII
Member
Registered: 2012-11-20
Posts: 2354
Website

Re: Parsing infos/numbers

Never mind the above, it doesn't work anyways.

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:

Applescript:


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.

smile


Filed under: utf8

Offline

 

#37 2012-12-11 07:40:18 am

BenJi
Member
From: France
Registered: 2012-11-23
Posts: 30

Re: Parsing infos/numbers

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.

Offline

 

#38 2012-12-11 07:56:05 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 1520

Re: Parsing infos/numbers

BenJi wrote:

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.

Yvan KOENIG (VALLAURIS, France) mardi 11 décembre 2012 14:55:58

Offline

 

#39 2012-12-11 08:23:31 am

McUsrII
Member
Registered: 2012-11-20
Posts: 2354
Website

Re: Parsing infos/numbers

It is McUsr Yvan, and I'll leave the magic to Nigel. smile


Filed under: utf-16

Offline

 

#40 2012-12-11 10:01:38 am

BenJi
Member
From: France
Registered: 2012-11-23
Posts: 30

Re: Parsing infos/numbers

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

   

Applescript:

   
       tell document 1
           select at in_point to out_point
           trim
       end tell

Last edited by BenJi (2012-12-11 10:24:02 am)

Offline

 

Board footer

Powered by FluxBB

[ Generated in 8.911 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)