Skip to content

Instantly share code, notes, and snippets.

@kureikei
Created June 13, 2021 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kureikei/beaafd0faaeaa72e6ab9672fc80e3ec9 to your computer and use it in GitHub Desktop.
Save kureikei/beaafd0faaeaa72e6ab9672fc80e3ec9 to your computer and use it in GitHub Desktop.
var file = new File("/Users/kei/Creative Cloud Files/scripts/clip.sbv"); // TODO: 実際のパスに変更
file.open( "w" );
var seq = app.project.activeSequence; // 現在のプロジェクトのアクティブなシーケンス
for (var i = 0; i < seq.videoTracks.length; ++i) { // ビデオトラックから探す
writeClipTimecodes(seq.videoTracks[i]);
}
for (var i = 0; i < seq.audioTracks.length; ++i) { // オーディオトラックから探す
writeClipTimecodes(seq.audioTracks[i]);
}
file.close();
file = null;
function writeClipTimecodes(track) {
for (var i = 0; i < track.clips.length; ++i) { // トラック内のクリップ
var clip = track.clips[i];
if (!clip.isSelected()) { // 選択されていなければスキップ
continue;
}
var start = clip.start;
var end = clip.end;
// .sbv 形式のタイムコードと字幕テキスト
file.writeln(
(Math.floor(start.seconds / 3600)) + ":" +
(Math.floor(start.seconds / 60) % 60) + ":" +
(start.seconds % 60) + "," +
(Math.floor(end.seconds / 3600)) + ":" +
(Math.floor(end.seconds / 60) % 60) + ":" +
(end.seconds % 60));
file.writeln(clip.name); // 字幕テキストは仮にクリップ名とする
file.writeln();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment