有没有办法确定剪辑是音频还是视频作为项目项目



我正在使用Adobe提供的SDK编写Premiere插件。我希望我的功能能够对媒体是纯音频还是视频(有或没有音频(敏感,例如是.wav还是.mp4。我希望在任何剪辑出现在任何时间线上之前发生这种情况,所以我不能使用track.mediaType属性。

当媒体是一个项目项目,但在文档中找不到任何内容时,我试图这样做(https://premiere-scripting-guide.readthedocs.io/4%20-%20Project%20Item%20object/projectItem.html?highlight=mediaType(

现在,这就是我正在做的:

GetProjectItemType: function (projectItem){
if (projectItem.name.includes("wav") || projectItem.name.includes("mp3") || projectItem.name.includes("AIFF") )
return "Audio"; 
else
return "Video"; 
}

有一个函数可以在Adobe CEP/Samples 中引用

项目项目类型

https://github.com/Adobe-CEP/Samples/blob/f86975c3689e29df03e7d815c3bb874045b7f991/PProPanel/jsx/PPRO/Premiere.jsx#L1614

前任。

if ((projectItem.type === ProjectItemType.CLIP) || (projectItem.type === ProjectItemType.FILE)) {
}

这可以帮助您区分其他项目项,如Bins、Clips和Files,您可以将其与当前的实现结合使用,以确保您拥有音频或视频项目项,而不是bin

我使用getProjectColumnsMetadata((并检查音频和视频信息,如果它们设置为"quot;我认为它们是视频/音频剪辑。

// JSON polyfill
"object" != typeof JSON && (JSON = {}), function () { "use strict"; var rx_one = /^[],:{}s]*$/, rx_two = /\(?:["\/bfnrt]|u[0-9a-fA-F]{4})/g, rx_three = /"[^"\nr]*"|true|false|null|-?d+(?:.d*)?(?:[eE][+-]?d+)?/g, rx_four = /(?:^|:|,)(?:s*[)+/g, rx_escapable = /[\"u0000-u001fu007f-u009fu00adu0600-u0604u070fu17b4u17b5u200c-u200fu2028-u202fu2060-u206fufeffufff0-uffff]/g, rx_dangerous = /[u0000u00adu0600-u0604u070fu17b4u17b5u200c-u200fu2028-u202fu2060-u206fufeffufff0-uffff]/g, gap, indent, meta, rep; function f(t) { return t < 10 ? "0" + t : t } function this_value() { return this.valueOf() } function quote(t) { return rx_escapable.lastIndex = 0, rx_escapable.test(t) ? '"' + t.replace(rx_escapable, function (t) { var e = meta[t]; return "string" == typeof e ? e : "\u" + ("0000" + t.charCodeAt(0).toString(16)).slice(-4) }) + '"' : '"' + t + '"' } function str(t, e) { var r, n, o, u, f, a = gap, i = e[t]; switch (i && "object" == typeof i && "function" == typeof i.toJSON && (i = i.toJSON(t)), "function" == typeof rep && (i = rep.call(e, t, i)), typeof i) { case "string": return quote(i); case "number": return isFinite(i) ? String(i) : "null"; case "boolean": case "null": return String(i); case "object": if (!i) return "null"; if (gap += indent, f = [], "[object Array]" === Object.prototype.toString.apply(i)) { for (u = i.length, r = 0; r < u; r += 1)f[r] = str(r, i) || "null"; return o = 0 === f.length ? "[]" : gap ? "[n" + gap + f.join(",n" + gap) + "n" + a + "]" : "[" + f.join(",") + "]", gap = a, o } if (rep && "object" == typeof rep) for (u = rep.length, r = 0; r < u; r += 1)"string" == typeof rep[r] && (o = str(n = rep[r], i)) && f.push(quote(n) + (gap ? ": " : ":") + o); else for (n in i) Object.prototype.hasOwnProperty.call(i, n) && (o = str(n, i)) && f.push(quote(n) + (gap ? ": " : ":") + o); return o = 0 === f.length ? "{}" : gap ? "{n" + gap + f.join(",n" + gap) + "n" + a + "}" : "{" + f.join(",") + "}", gap = a, o } } "function" != typeof Date.prototype.toJSON && (Date.prototype.toJSON = function () { return isFinite(this.valueOf()) ? this.getUTCFullYear() + "-" + f(this.getUTCMonth() + 1) + "-" + f(this.getUTCDate()) + "T" + f(this.getUTCHours()) + ":" + f(this.getUTCMinutes()) + ":" + f(this.getUTCSeconds()) + "Z" : null }, Boolean.prototype.toJSON = this_value, Number.prototype.toJSON = this_value, String.prototype.toJSON = this_value), "function" != typeof JSON.stringify && (meta = { "b": "\b", "t": "\t", "n": "\n", "f": "\f", "r": "\r", '"': '\"', "\": "\\" }, JSON.stringify = function (t, e, r) { var n; if (indent = gap = "", "number" == typeof r) for (n = 0; n < r; n += 1)indent += " "; else "string" == typeof r && (indent = r); if ((rep = e) && "function" != typeof e && ("object" != typeof e || "number" != typeof e.length)) throw new Error("JSON.stringify"); return str("", { "": t }) }), "function" != typeof JSON.parse && (JSON.parse = function (text, reviver) { var j; function walk(t, e) { var r, n, o = t[e]; if (o && "object" == typeof o) for (r in o) Object.prototype.hasOwnProperty.call(o, r) && (void 0 !== (n = walk(o, r)) ? o[r] = n : delete o[r]); return reviver.call(t, e, o) } if (text = String(text), rx_dangerous.lastIndex = 0, rx_dangerous.test(text) && (text = text.replace(rx_dangerous, function (t) { return "\u" + ("0000" + t.charCodeAt(0).toString(16)).slice(-4) })), rx_one.test(text.replace(rx_two, "@").replace(rx_three, "]").replace(rx_four, ""))) return j = eval("(" + text + ")"), "function" == typeof reviver ? walk({ "": j }, "") : j; throw new SyntaxError("JSON.parse") }) }();
// Get the column value matching the column name
function getColumnValue(obj, columnName) {
for (var i = 0; i < obj.length; i++) {
if (obj[i].ColumnName === columnName) {
return obj[i].ColumnValue;
}
}
return null;
}
function hasAudio(projectItem) {
var hasAudio = getColumnValue(JSON.parse(projectItem.getProjectColumnsMetadata()), "Audio Info");
retrun typeof hasAudio != undefined && hasAudio != "" && hasAudio.length > 0;
}
function hasVideo(projectItem) {
var hasVideo = getColumnValue(JSON.parse(projectItem.getProjectColumnsMetadata()), "Video Info");
return typeof hasVideo != undefined && hasVideo != "" && hasVideo.length > 0;
}

最新更新