Sync with 2 videos and quicktime appelscript
Hello,
I try to sync with two videos applescript quicktime.
Both videos have the same duration, the first plays on the screen 1 the second on the screen 2. With this script, the video runs fine, but there is a slight delay. Do you know how to obtain a perfect synchronization.
Film1 set to "/ Volumes / VolumeRaid / encoding / EXPO / DAVIS/MOV/MilesDavisCS1 MILES - copie.mov"
Film2 set to "/ Volumes / VolumeRaid / encoding / EXPO / MILES DAVIS/MOV/MilesDavisCS1.mov"
tell application "QuickTime Player"
open Film1
open Film2
activate
present document 1 scale screen display 1
2 present document scale screen display 2
rewind 1 document
document rewind 2
stop
start
end tell
Thank you
Re: Sync with 2 videos and quicktime appelscript
I replace it with this (change of place of stop)
Code:
Quote:
Film1 set to "/ Volumes / VolumeRaid / encoding / EXPO / DAVIS/MOV/MilesDavisCS1 MILES - copie.mov"
Film2 set to "/ Volumes / VolumeRaid / encoding / EXPO / MILES DAVIS/MOV/MilesDavisCS1.mov"
tell application "QuickTime Player"
open Film1
open Film2
activate
present document 1 scale screen display 1
2 present document scale screen display 2
stop
rewind 1 document
document rewind 2
start
end tell
that just because your 2 ton rewind and stop the document 1 had time to take a little advance
Re: Sync with 2 videos and quicktime appelscript
Yes that's exactly it and it seems logical.
Thank you
Another question, to go a little further, will you know if it's possible to create a command that allows videos to be synchronized to the image and almost throughout the film. Indeed, the current script synchronizes the start but I am afraid that after three hours of film loop is no longer synchronized.
The idea would be to define a film as a master, the second as slave. So, how about laying on the master, the slave would also pose .Maybe it is too advanced functions for appelscript?
and secondly is it possible to launch the appelscript before the start of the session ?
Thank you again
Re: Sync with 2 videos and quicktime appelscript
is that the videos are identical? because in this case a video would be much simpler not?
Re: Sync with 2 videos and quicktime appelscript
you can add this in your script:
set looping of document 1 to yes
looping set of document 2 to yes
you can put it where you want in your script after the film open 2
However, I do not put after the start (story to avoid a gap - although unlikely)
Re: Sync with 2 videos and quicktime appelscript
What you can do is a loop in your script, so that your sync level of the rest of the first startup (who is perhaps not perfectly synchronized as recalled - but the gap should not be seen, especially if Videos are not the same)
You remove what I have proposed in my last post and you replace the "start" by
Code:
Quote:
repeat
start
delay TonTempsEnSecondes
end repeat
the time is to save the video, it might be a adapter for a second or two. You must prevent the start to launch the DVD of the video can be done while the video is not fully completed (in which case the start command has no effect and the video, once completed, will stop just to start a restart later)
looping the documents as I had proposed to you automatically create a gap in time: your videos, even if it is ostensibly the same time, are almost certainly slightly different length (except a calibrated exactly the same number of images - and yet I can not say that even then you did not shift over time)
Re: Sync with 2 videos and quicktime appelscript
start or stop will do nothing if you do not specify a document or all documents.
EX:
Code:
Quote:
1 stop paper
play documents
tell document 2
start
end tell
Yes, the start or play does not synchronize the sequence with the same menu "Read all sequences.
Here is a script that synchronizes two sequences with a gap of less than one tenth of a second, I tested here with less than five hundredths of seconds.
Code:
Quote:
Firsttime property: false
property times_scale1: 0
property times_scale2: 0
property latency: 0
property t_movies: ()
on run
Firsttime set to true
end run
on idle
if firsttime then
openFilms ()
else
tell application "QuickTime Player" to if exists then paper 2
tell t_movies
if not playing then of item 1 - 1 movie does not play
break item 2 - 2 film break
p set to 0
else
set p to 1
of if not playing then play item 2 item 2 - film 1 and film 2 is not playing -> play movie 2
end if
end tell
t_pos set to current time of documents - position players
The_diff set to (my milliieme ((item 1 of t_pos) / times_scale1)) - (my milliieme ((item 2 of t_pos) / times_scale2))
The_diff if> 0.1 or The_diff <-0.1 then - shifting more than a tenth of a second -> syncing
if p = 0 then - readers are paused
if times_scale2 = times_scale1 then
set current time of item 2 of t_movies to (current time of item 1 of t_movies)
else
set current time of item 2 of t_movies to ((current time of item 1 of t_movies) / times_scale1) * times_scale2
end if
else if p = 1 then - the players play
repeat with i from 1 to 10 - synchronizes during playback
set current time of item 2 of t_movies to (current time of item 1 of t_movies) + (Latency * i)
delay 3
t_pos set to current time of documents
The_diff set to (my milliieme ((item 1 of t_pos) / times_scale1)) - (my milliieme ((item 2 of t_pos) / times_scale2))
if The_diff <0.1 and The_diff> -0.1 then exit repeat - sync OK, less than a tenth of a second out of the loop
end repeat
end if
end if
end if
end if
return 5 - Check for 5 seconds
end idle
openFilms on ()
Film1 set to "/ Volumes / VolumeRaid / encoding / EXPO / MILES DAVIS/MOV/MilesDavisCS1.mov"
Film2 set to "/ Volumes / VolumeRaid / encoding / EXPO / DAVIS/MOV/MilesDavisCS1 MILES - copie.mov"
tell application "QuickTime Player"
close saving no documents
t_movies set to open Film1 (,) Film2
activate
tell Documents
repeat until load state of item 1 is complete and load state of item 2 is complete
delay 3
end repeat
set looping to true
1 item present scale screen display 2
2 present item scale screen display 1
break
times_scale1 set (,) to times_scale2 time scale
set current time to 0 - puts players at the beginning
play
delay 1
t_pos set to current time - position players
break
- Verify the diffferent time between the two films and adjusts the position of the second player according to the latency.
set n to (my milliieme ((item 1 of t_pos) / times_scale1)) - (my milliieme ((item 2 of t_pos) / times_scale2))
latency set to (n * times_scale2) div 1.3
set current time of item 1 to 0
set current time of item 2 to latency
delay 1
play
end tell
end tell
Firsttime set to false
end openFilms
we quit
Continuous quit
end quit
on milliieme (n) - returns the number with three decimal
return ((n * 1000) div 1) / 1000
end milliieme
The script is checked every five seconds, you can adjust according to your preferences.
The master sequence is the film of the variable in the script Film1
So, if the user pauses the master sequence, the script will pause the movie after his next audit, for the same reading
If the user (forward or backward) the position of one of two films, the script will synchronize after verification of its next time readers.
This script works with an idle, so you must save it as a "Software" and check the option "Stay in the background."
Add the application (the script) in the automatic opening at the opening of your session. (Preferences -> Accounts)
Edit: The script does only 1% on the CPU here.