Copy link to clipboard
Copied
Hello,
I wrote a quick script that reads a marker's Start and End and sets an In Point and Out Point on the activeSequence. Then it sends that In and Out Point to Media Encoder to render. Some of the rendered files have a Start point that is off by 1 frame(early). I've tried forcing Marker start time to use Ticks or seconds but it doesn't matter I still get some renders that are a frame too early. I attached a video to show the problem.
function sendMarkersToAME (activeSeq, outputPath, presetPath){
if(activeSeq){
var markers = activeSeq.markers
if (markers){
markerCount = markers.numMarkers
if (markerCount){
seqName = activeSeq.name
extName = "_Pr_v01.mov"
for (var thisMarker = markers.getFirstMarker(); thisMarker !== undefined; thisMarker = markers.getNextMarker(thisMarker)) {
//alert (thisMarker.name + " " + thisMarker.start.seconds + " " + thisMarker.end.seconds)
if(thisMarker.getColorByIndex() == 3){
inPoint = thisMarker.start.seconds
inPointTicks = thisMarker.start.ticks
activeSeq.setPlayerPosition(inPointTicks)
inPointInTimecode = playerPositionToTimecode (activeSeq.getPlayerPosition().seconds)
tcString = inPointInTimecode.replace(/;/g, '')
alert (tcString)
outputFileName = tcString + seqName + thisMarker.name + extName
alert(outputFileName)
completeOutputPath = outputPath.fsName + getSep() + outputFileName
//alert (completeOutputPath)
outPoint = thisMarker.end.seconds
activeSeq.setInPoint(inPoint)
activeSeq.setOutPoint(outPoint)
app.encoder.encodeSequence(activeSeq, completeOutputPath, presetPath.fsName, 1, 0)
}
}
}else{
alert ("No Marker Count")
}
}else{
alert ("No Markers")
}
}else{
alert ("No Active Sequence")
}
app.encoder.startBatch ()
}
Copy link to clipboard
Copied
What's in playerPositionToTimecode() ?
I can imagine that, when moving from seconds to ticks, enough rounding error could be introduced that frames would be off by one...
Copy link to clipboard
Copied
Bruce thanks for the quick reply...I'm not moving from ticks to seconds, I tried passing ticks or seconds to the inPoint
Still some of the renders that are off by 1 frame. What should I pass to activeSeq.setInPoint() to get the right in point on my render in Media encoder?
I use playerPositionToTimecode() to get the actual timecode of the player position so I can use TC In of the marker in the file name. I tried using .CTI.timecode but its relative to the start of the sequence, so if I change the start time to 01:00:00:00 and I have a marker start at 01:05:00:00 CTI.timecode returns 00:05:00:00. Its probably a round about way to do it but I couldn't think of anything else. Here is the whole script...note I only render orange markers.
//Start Media Encoder
startAME ()
seq = app.project.activeSequence
//alert (playerPositionToTimecode (seq.getPlayerPosition().seconds))
outputPath = Folder.selectDialog("Select Destination for rendered clip?")
if(outputPath){
fileType = '*.epr'
outputPresetPath = File.openDialog ('Select Export Preset', fileType , false);
if(outputPresetPath){
sendMarkersToAME (seq, outputPath, outputPresetPath)
}else{
alert ("No export preset selected")
}
}else{
alert ("No Destination Selected please try again")
}
function getSep () {
//Functiont to get OS, return the correct slash
if (Folder.fs === 'Macintosh') {
return '/';
} else {
return '\\';
}
}
function startAME (){
//Function to Start Media Encoder if its not running
var ameStatus = BridgeTalk.getStatus("ame")
if (ameStatus == "ISNOTRUNNING"){
app.encoder.launchEncoder();
}
}
function sendMarkersToAME (activeSeq, outputPath, presetPath){
if(activeSeq){
var markers = activeSeq.markers
if (markers){
markerCount = markers.numMarkers
if (markerCount){
seqName = activeSeq.name
extName = "_Pr_v01.mov"
for (var thisMarker = markers.getFirstMarker(); thisMarker !== undefined; thisMarker = markers.getNextMarker(thisMarker)) {
//alert (thisMarker.name + " " + thisMarker.start.seconds + " " + thisMarker.end.seconds)
if(thisMarker.getColorByIndex() == 3){
inPoint = thisMarker.start.seconds
inPointTicks = thisMarker.start.ticks
activeSeq.setPlayerPosition(inPointTicks)
inPointInTimecode = playerPositionToTimecode (activeSeq.getPlayerPosition().seconds)
tcString = inPointInTimecode.replace(/;/g, '')
alert (tcString)
outputFileName = tcString + seqName + thisMarker.name + extName
alert(outputFileName)
completeOutputPath = outputPath.fsName + getSep() + outputFileName
//alert (completeOutputPath)
outPoint = thisMarker.end.seconds
activeSeq.setInPoint(inPoint)
activeSeq.setOutPoint(outPoint)
app.encoder.encodeSequence(activeSeq, completeOutputPath, presetPath.fsName, 1, 0)
}
}
}else{
alert ("No Marker Count")
}
}else{
alert ("No Markers")
}
}else{
alert ("No Active Sequence")
}
app.encoder.startBatch ()
}
function playerPositionToTimecode (playerPosition){
actSeq = app.project.activeSequence
currentSeqSettings = actSeq.getSettings()
zeroPoint = actSeq.zeroPoint
zeroPointInSeconds = zeroPoint / 254016000000
playerPositionSeconds = new Time ()
playerPositionSeconds.seconds = playerPosition + zeroPointInSeconds
playerPositionTimecode = playerPositionSeconds.getFormatted(currentSeqSettings.videoFrameRate, actSeq.videoDisplayFormat)
return playerPositionTimecode
}