Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Adobe Premiere中setInPoint和setOutPoint出现脚本错误?_Javascript_Video_Editing_Extendscript_Adobe Premiere - Fatal编程技术网

Javascript Adobe Premiere中setInPoint和setOutPoint出现脚本错误?

Javascript Adobe Premiere中setInPoint和setOutPoint出现脚本错误?,javascript,video,editing,extendscript,adobe-premiere,Javascript,Video,Editing,Extendscript,Adobe Premiere,我在使用时遇到了令人沮丧的砖墙: projectItem.setInPoint(seconds) projectItem.setOutPoint(seconds) …大约50%的时间(在源窗口中)I/O点设置为1帧错误(有时为2帧错误)。我觉得我已经尽了一切努力去发现这个模式是什么,但它似乎完全是随机的。 我认为这可能与下降帧、可变帧速率、剪辑与序列不同或其他奇怪之处有关,但错误发生在简单的恒定帧速率下,如25 fps。错误似乎没有韵律或原因(尽管相同的错误在某些帧上持续出现)。 子唇还有

我在使用时遇到了令人沮丧的砖墙:

projectItem.setInPoint(seconds)
projectItem.setOutPoint(seconds)
…大约50%的时间(在源窗口中)I/O点设置为1帧错误(有时为2帧错误)。我觉得我已经尽了一切努力去发现这个模式是什么,但它似乎完全是随机的。

我认为这可能与下降帧、可变帧速率、剪辑与序列不同或其他奇怪之处有关,但错误发生在简单的恒定帧速率下,如25 fps。错误似乎没有韵律或原因(尽管相同的错误在某些帧上持续出现)。

子唇还有一个更大的问题,因为脚本环境认为所有子唇都从第0帧开始。

我尝试了一切,包括在滴答声、秒或帧中工作,以及在它们之间转换。没有什么不同。

我试图完成的是在一组剪辑上设置输入/输出,运行脚本从这些源剪辑进行较小的剪切,然后将剪辑恢复到原始I/O点。大部分工作正常,但我无法使用此错误将所有剪辑恢复到原始I/O点。

下面是我编写的测试脚本。它获取当前的I/O位置,存储它们,然后将它们设置回相同的剪辑。一半的时候,这些值是不一样的!啊!这使得无法准确设置剪辑I/O

function framesToSeconds (frames, fps)
{
    return frames / fps;
}

function secondsToFrames (sec, fps)
{
    return sec * fps;
}

/*---------------------------------------------------*/

var projItems = app.project.rootItem.children;
var clip = projItems[2];
var fps = clip.getFootageInterpretation().frameRate;

var setIn = clip.getInPoint().seconds;
var setOut = clip.getOutPoint().seconds;

var inFrame = secondsToFrames (setIn, fps);
var outFrame = secondsToFrames (setOut, fps);

var secIn = framesToSeconds (inFrame, fps);
var secOut = framesToSeconds (outFrame, fps);

clip.setInPoint( secIn );
clip.setOutPoint( secOut );

var setIn = clip.getInPoint().seconds;
var setOut = clip.getOutPoint().seconds;

我还做了一些测试。虽然我不太了解错误的来源,但我相信我已经找到了解决方法

我测试了2个Slug,每个10秒长,帧速率不同,然后通过循环运行它们,并设置每个帧的IO点。我检查了每一帧,看看哪一帧是错误的。我发现:

测试_25fps_1280x720.mov:帧211209207203201上的错误

test_29fps_1024x576.mov:帧2512442122121,61上的错误

这些错误不是随机的。每当我试图在这些帧上设置一个in或out点时,它总是取整1帧(在大约50%的帧被关闭之前,我是错的,实际上它不到3%)

我最好的猜测是,有一些精度错误,因为有一个涉及大浮点数的计算。我无法确认,也不知道如何解决这个问题。但是我确实发现我可以在设置了输入和输出点之后测试它们,如果它不符合预期,我可以通过添加半帧(以秒为单位)的持续时间来重置该点。完整帧只会重复错误,但半帧会使Premiere四舍五入到正确的帧

这是我代码的主要部分:

/*---------------------------------------------------*/
function fixAnyFrameErrors (clip, inFrame, outFrame, fps, halfFrame)
/*---------------------------------------------------*/
{
    var inSecSet    = clip.getInPoint().seconds;
    var inFrameSet  = secondsToFrames (inSecSet, fps);
    var outSecSet   = clip.getOutPoint().seconds;
    var outFrameSet = secondsToFrames (outSecSet, fps);

    if ( parseFloat(inFrame) != parseFloat(inFrameSet) ) {
        clip.setInPoint( secIn + halfFrame );
    }

    if ( parseFloat(outFrame) != parseFloat(outFrameSet) ) {
        clip.setOutPoint( secOut + halfFrame );
    }
}

/*---------------------------------------------------*/

var tps = 254016000000; // 2.54016e11 ticks per second (Premiere Pro constant)

var projItems = app.project.rootItem.children;
var clip = projItems[2];
clip.addMetadata();
var fps = clip.getFootageInterpretation().frameRate;
var tpf = clip.videoInPoint.frame_rate;
var frameDuration = tpf / tps; // in seconds
var halfFrame = (frameDuration * 0.5);

var inFrame = 201;
var outFrame = 211;
  
var secIn  = framesToSeconds (inFrame,  fps);
var secOut = framesToSeconds (outFrame, fps);

clip.setInPoint ( secIn  );
clip.setOutPoint( secOut );

fixAnyFrameErrors (clip, inFrame, outFrame, fps, halfFrame);
我的意见是:

(我们在设置标记时遇到问题。)

我们的计算是正确的,但Premiere将标记秒设置为8.35999999606,而不是8.36(25fps),标记以8secs 9frames显示,但显示值为8secs 8frames

来自Adobe论坛:

他们建议使用ε来检查一个值是否非常接近计算值。 在本例中,差值为000000000000394-这非常低,应更正为0

我不想知道如果我们使用dropframes的帧率(例如23.976)会发生什么


编辑:在我的例子中,您必须更正现有标记内的时间,因此这不起作用。我将尝试添加半帧…

什么是
clip.videoInPoint.frame\u rate
?剪辑对象没有直接属性
videoInPoint
,并且我找不到任何名为
frame\u rate
的属性……我一定没有包含完整的代码(不希望它太长)。如果我记得那是在我解析了来自“addMetadata()”方法的XML字符串之后。谢谢你提供的信息!我在他们的uservoice中提出了一个bug,我们还将其传输给了企业支持部门。这仍然存在于ppro v14.5中。