手痒,看止境在群里问Hiero有没有一键清除时间轨道视频项之间的间隙,这个功能达芬奇是有的。我一想原理很简单,但没写过Hiero插件,看了下帮助文档跟吴总学习了下,写了个小玩具。

# Usage: Copy to ~/.hiero/Python/Startup
from hiero.core import *
import hiero.core.events
import hiero.ui

try:
    from PySide.QtGui import *
    from PySide.QtCore import *
except:
    from PySide2.QtGui import *
    from PySide2.QtCore import *
    from PySide2.QtWidgets import *


class RemoveEmptyClip(QAction):
    tracks = None

    def __init__(self):
        QAction.__init__(self, "Remove empty clip", None)
        self.triggered.connect(self.removeEmptyClipAction)
        hiero.core.events.registerInterest("kShowContextMenu/kTimeline", self.eventHandler)

    def eventHandler(self, event):
        # Insert the action to the menu
        self.tracks = event.sender.selection()
        event.menu.addAction(self)

    def removeEmptyClipAction(self):
        if self.tracks:
            for track in self.tracks:
                items = track.items()
                endItemFrame = 0
                for item in items:
                    itemObject = TrackItem(item)
                    frameRange = itemObject.timelineOut() - itemObject.timelineIn()

                    if endItemFrame > 0:
                        itemObject.setTimelineIn(endItemFrame)
                        itemObject.setTimelineOut(endItemFrame + frameRange)
                    endItemFrame += frameRange + 1


RemoveEmptyClip()

安装方法

测试 nuke 10 版本以上通过

放到 .hiero/Python/Startup 或者 .nuke/Python/Startup

百度网盘

链接:https://pan.baidu.com/s/1WtGVQs8uRJlotK_JmwTfRA
提取码:q6pb