Applescript movie duration timecode to frames

Hi all

2 Questions

FIRST QUESTION

in a text file I have the movie names and their timecode duration

I hope to convert the timecode duration to the equivalent frame count.

Every movie time base is 25 frames per seconds

My text file has the Movie filename a tab and the timecode. This is just an example


MOVIE1.MOV [TAB] 00:02:12:05

MOVIE2.MOV [TAB] 00:04:02:12

MOVIE3.MOV [TAB] 00:00:32:19


How to convert this to a new file as follows?

movie filename tab and frames count

MOVIE1.MOV [TAB] XXXX Frames

and so on?


The file list is rather long with over 625 different takes ....


SECOND QUESTION

How to ask Quicktime Player 7 to open a movie file and place the playhead at a given frame?


thanks a lot



Dan


Message was edited by: etnad for spelling

Mac Pro, Mac OS X (10.6.8), null

Posted on Jan 13, 2015 11:47 AM

Reply
6 replies

Jan 13, 2015 4:33 PM in response to etnad

Hello


Regarding Q1, you may try something like this.



set infile to (choose file of type {"public.plain-text"} with prompt "Choose input file.")'s POSIX path set outfile to (choose file name default name "out.txt" with prompt "Choose output file.")'s POSIX path do shell script "perl -CSDA -w <<'EOF' - " & infile's quoted form & " > " & outfile's quoted form & " use strict; local $\\ = qq(\\n); local $, = qq(\\t); while (<>) { my ($n, $h, $m, $s, $f) = /(.*?)\\t([0-9]{2}):([0-9]{2}):([0-9]{2}):([0-9]{2})/; print +($n, (3600 * $h + 60 * $m + $s) * 25 + $f) if $f; } EOF"




Regarding Q2, you may try something like this.



set f to (path to desktop)'s POSIX path & "a.mov" set frame_number to 40 set fps to 25 tell application id "com.apple.quicktimeplayer" -- QuickTime Player 7 tell (open f as POSIX file) set current time to frame_number / fps * time scale end tell end tell




Regards,

H

Jan 14, 2015 6:45 AM in response to Hiroto

Thanks Hiroto

both your script work perfectly, I want to explain what we are trying to achieve.

We are using FilemakerPro database as a pre-editing tool for a film we shoot

Too complex here to explain the serious reasons for this choice

The scripts in reply to the first question allows us to create a frame field in FMP to then choose various different starting points in our film-files.



We use successfully this FMP and Applescript combined script from within filemaker to open clips we choose from our FMP file:

Let (

mac_path = Right ( Substitute ( Media Path; "/"; ":"); Length (Media Path) - 1);



"tell application \"Quicktime 7\"" & ¶ &

"activate" & ¶ &

"open " & Quote ( mac_path ) & ¶ &

"

set the dimensions of movie 1 to {480, 270}

" & ¶ &

"end tell"

)



the script calls the clip in QT and plays it

we use the script to open more than one QT window to compare takes as QT allows to see more than one film at the time,

While your script works perfectly from within Filemaker as "Native Applescripts" playing from the starting point set in the script, I am not able to adapt it in the one we use already. we need to merge them to use some of the fields in my database for the frame_number required.



Adding this information to the original working script, Quicktime opens the film and gives an error telling it cannot set the playhead to the frame and stops before changing the film dimensions.



This is what I did



Let (

mac_path = Right ( Substitute ( Media Path; "/"; ":"); Length (Media Path) - 1);

"set frame_number to " & Frames & ¶ &

"tell application \"Quicktime 7\"" & ¶ &

"activate" & ¶ &

"open " & Quote ( mac_path ) & ¶ &

"set current time to frame_number" & ¶ &

"set the dimensions of movie 1 to {480, 270}" & ¶ &

"end tell"

)





Is there a way to fit parts of your scripts in FMP?



Regards



Dan

Jan 14, 2015 5:49 PM in response to etnad

Hello


I'm not familiar with AppleScript run in Filemaker Pro, but it seems you're setting current time to frame number where it should be number of seconds * time scale.


So try replacing the line:


"set current time to frame_number" & ¶ &



with this:


"set current time to frame_number / 25 * time scale" & ¶ &




As a whole, something like this:


Let ( mac_path = Right ( Substitute ( Media Path; "/"; ":"); Length (Media Path) - 1); "set frame_number to " & Frames & ¶ & "tell application \"Quicktime 7\"" & ¶ & "activate" & ¶ & "open " & Quote ( mac_path ) & ¶ & "set current time to frame_number / 25 * time scale" & ¶ & "set the dimensions of movie 1 to {480, 270}" & ¶ & "end tell" )




* I assumed video is in 25 fps.


Good luck,

H

Jan 15, 2015 9:18 PM in response to etnad

Hello


After looking at the script closer, it appears not telling document when setting current time. Correction would be as follows.



Let ( mac_path = Right ( Substitute ( Media Path; "/"; ":"); Length (Media Path) - 1); "set frame_number to " & Frames & ¶ & "tell application \"QuickTime Player 7\"" & ¶ & "activate" & ¶ & "tell (open " & Quote ( mac_path ) & ")" & ¶ & "set current time to frame_number / 25 * time scale" & ¶ & "set dimensions to {480, 270}" & ¶ & "end tell" & ¶ & "end tell" )



Regards,

H

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript movie duration timecode to frames

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.