SyntaxHighlighter

ラベル after effects の投稿を表示しています。 すべての投稿を表示
ラベル after effects の投稿を表示しています。 すべての投稿を表示

2015年12月29日火曜日

openDirectory


var currentDate         = dateAcquisition()[0] +"_"+ dateAcquisition()[1] +"_"+ dateAcquisition()[2] ;
var currentTime         = dateAcquisition()[3] +"_"+ dateAcquisition()[4];
//カレントのAepファイルのパス "-project project_path"
var aepProjectFileAbsolutePath  = app.project.file.absoluteURI;
//カレントのAepファイルのバージョン
var aepFileVersion              = fileNameVersionExtension(aepProjectFileAbsolutePath)[4];
//年月日取得
function dateAcquisition() {
  //今日の日時示
  var now   = new Date();
  var year  = now.getYear();      // 年
  var month = now.getMonth() + 1; // 月
  var day   = now.getDate();      // 日
  var hour  = now.getHours();     // 時
  var min   = now.getMinutes();   // 分
  var sec   = now.getSeconds();   // 秒
  if(year < 2000) { year += 1900; }
  // 数値が1桁の場合、頭に0を付けて2桁で表示する指定
  if(month  < 10) { month = "0" + month; }
  if(day    < 10) { day   = "0" + day; }
  if(hour   < 10) { hour  = "0" + hour; }
  if(min    < 10) { min   = "0" + min; }
  if(sec    < 10) { sec   = "0" + sec; }
  return [ year , month , day , hour , min , sec ];
}
//ファイル名と拡張子とバージョン取得
function fileNameVersionExtension(AbsolutePath) {
  //拡張子込ファイル名
  var filePathAry           = AbsolutePath.split("/");
  var filePathAryLength     = filePathAry.length -1;
  var fileFullName          = filePathAry[filePathAryLength];
  //ファイル名とファイルタイプ(拡張子)
  var fileNameAry           = fileFullName.split(".");
  var fileNameAryLength     = fileNameAry.length -1;
  var fileName              = fileNameAry[0];
  var fileExtension         = fileNameAry[fileNameAryLength];
  //ファイルネーム要素
  var fileNameElement       = fileName.split("_");
  var fileVersionAryLength  = fileNameElement.length -1;
  var fileVersion           = fileNameElement[fileVersionAryLength];
  return [fileFullName , fileName , fileExtension , fileNameElement , fileVersion ];
}

function openDirectory() {
  var aepPathObj            = new Folder(app.project.file.path);

  var imagesDir             = app.project.file.path +"/"+ "images";
  var imagesDirObj          = new Folder( imagesDir );
  var outputDir             = app.project.file.path +"/"+ "images" +"/"+ aepFileVersion;
  var outputDirObj          = new Folder( outputDir );

  var userTempDirObj        = new Folder ( Folder.temp) ;
  var aerenderDir           = (userTempDirObj.toString() + "/afterEffect/aerender/");
  var aerenderDirObj        = new Folder( aerenderDir );
  var aeBatDir              = (userTempDirObj.toString() + "/afterEffect/aerender/batch/");
  var aeBatchDirObj         = new Folder( aeBatDir );
  var aeTodayBatchDirObj    = new Folder( aeBatDir + currentDate );
  var aepDir                = (userTempDirObj.toString() + "/afterEffect/aerender/project/");
  var aepDirObj             = new Folder( aepDir );
  var aepTodayDirObj        = new Folder( aepDir + currentDate );
  return [ aepPathObj , imagesDirObj , outputDirObj , userTempDirObj , aerenderDirObj , aeBatchDirObj , aeTodayBatchDirObj , aepDirObj , aepTodayDirObj];
}

function openAepCopyDir() {
  if (openDirectory()[8].exists == true) {
    openDirectory()[8].execute();
  }else {
    if (openDirectory()[7].exists == true) {
      openDirectory()[7].execute();
    }else {
      if (openDirectory()[4].exists == true) {
        openDirectory()[4].execute();
      }else {
        if (openDirectory()[3].exists == true) {
          openDirectory()[3].execute();
        }else {
          alert("ないっす!!!((((;゚Д゚))))ガクガクブルブル");
        }
      }
    }
  }
}

function openAepBatDir() {
  if (openDirectory()[6].exists == true) {
    openDirectory()[6].execute();
  }else {
    if (openDirectory()[5].exists == true) {
      openDirectory()[5].execute();
    }else {
      if (openDirectory()[4].exists == true) {
        openDirectory()[4].execute();
      }else {
        if (openDirectory()[3].exists == true) {
          openDirectory()[3].execute();
        }else {
          alert("ないっす!!!((((;゚Д゚))))ガクガクブルブル");
        }
      }
    }
  }
}

function openImagesDir() {
  if (openDirectory()[2].exists == true) {
    openDirectory()[2].execute();
  }else {
    if (openDirectory()[1].exists == true) {
      openDirectory()[1].execute();
    }else {
      if (openDirectory()[0].exists == true) {
        openDirectory()[0].execute();
      }else {
        alert("ないっす!!!((((;゚Д゚))))ガクガクブルブル");
      }
    }
  }
}

function openAepDir() {
  if (openDirectory()[0].exists == true) {
    openDirectory()[0].execute();
  }else {
    alert("ないっす!!!((((;゚Д゚))))ガクガクブルブル");
  }
}

function inputPromptOpenDirectory() {
  var selectChoice = prompt("0-2を入力してください\n"+
                    "0:カレントAEPファイルのフォルダを開く\n"+
                    "1:カレントイメージフォルダを開く\n"+
                    "2:バッチファイルフォルダを開く"
                    ,"0"
                    ,"OpenDirectory");
  if (selectChoice != null) {
    if (selectChoice == 0) {
      openAepDir();
    }else if (selectChoice == 1) {
      openImagesDir();
    }else if (selectChoice == 2) {
      openAepBatDir();
    }else if (selectChoice == 3) {
      openAepCopyDir();
    }else {
      alert("むりっす:-p");
    }
  }else {
    alert("キャンセルされました");
  }
}
inputPromptOpenDirectory()

2015年12月27日日曜日

setRenderOutput

レンダーキューでアクティブなキューの設定をする(ディレクトリも作成)

//年月日取得
function dateAcquisition(){
  //今日の日時示
  var now   = new Date();
  var year  = now.getYear();      // 年
  var month = now.getMonth() + 1; // 月
  var day   = now.getDate();      // 日
  var hour  = now.getHours();     // 時
  var min   = now.getMinutes();   // 分
  var sec   = now.getSeconds();   // 秒
  if(year < 2000) { year += 1900; }
  // 数値が1桁の場合、頭に0を付けて2桁で表示する指定
  if(month  < 10) { month = "0" + month; }
  if(day    < 10) { day   = "0" + day; }
  if(hour   < 10) { hour  = "0" + hour; }
  if(min    < 10) { min   = "0" + min; }
  if(sec    < 10) { sec   = "0" + sec; }
  return [ year , month , day , hour , min , sec ];
}
//ファイル名と拡張子とバージョン取得
function fileNameVersionExtension(AbsolutePath){
  //拡張子込ファイル名
  var filePathAry           = AbsolutePath.split("/");
  var filePathAryLength     = filePathAry.length -1;
  var fileFullName          = filePathAry[filePathAryLength];
  //ファイル名とファイルタイプ(拡張子)
  var fileNameAry           = fileFullName.split(".");
  var fileNameAryLength     = fileNameAry.length -1;
  var fileName              = fileNameAry[0];
  var fileExtension         = fileNameAry[fileNameAryLength];
  //ファイルネーム要素
  var fileNameElement       = fileName.split("_");
  var fileVersionAryLength  = fileNameElement.length -1;
  var fileVersion           = fileNameElement[fileVersionAryLength];
  return [fileFullName , fileName , fileExtension , fileNameElement , fileVersion ];
}
//コマンドラインオプション
function commandLineOption(i){
  //コンポジション名 "-comp comp_name"
  var compositonName              = app.project.renderQueue.item(i).comp.name;
  //コンポジションのフレームレート
  var compositonFrameRate         = app.project.renderQueue.item(i).comp.frameRate;
  //コンポジションのデュレーション
  var compositonDuration          = app.project.renderQueue.item(i).comp.duration * compositonFrameRate;
  //コンポジションのスタートフレーム "-s start_frame"
  var compostionStartTime         = app.project.renderQueue.item(i).comp.displayStartTime * compositonFrameRate;
  //コンポジションのエンドフレーム "-e end_frame"
  var compostionEndTime           = (compostionStartTime + compositonDuration) - 1;
  //ワークエリアのスタートフレーム "-s start_frame"
  var compostionWorkAreaStart     = app.project.renderQueue.item(i).comp.workAreaStart * compositonFrameRate;
  //ワークエリアのデュレーション
  var compositonWorkAreaDuration  = app.project.renderQueue.item(i).comp.workAreaDuration * compositonFrameRate;
  //コンポジションのエンドフレーム "-e end_frame"
  var compostionWorkAreaEndTime   = (compostionWorkAreaStart + compositonWorkAreaDuration) - 1;
  //レンダリング出力先 "-output  output_path"
  var renderPath                  = app.project.renderQueue.item(i).outputModule(1).file;
  //レンダリング出力先その2 ※Absoluteをつけないと配列にならない
  var renderAbsolutePath          = app.project.renderQueue.item(i).outputModule(1).file.absoluteURI;
  return [ compositonName , compostionStartTime , compostionEndTime , compostionWorkAreaStart , compostionWorkAreaEndTime , renderAbsolutePath ]
}
//コンプレイヤネーム
function compostionLayerName(i){
  var compositonName      = commandLineOption(i)[0];
  var compNameElement     = compositonName.split("_");
  var compNameAryLength   = compNameElement.length -1;
  var compLayerName       = compNameElement[compNameAryLength];
  return [ compLayerName ];
}
//
function makeOutputDir(i){
  var compLayerName = compostionLayerName(i)[0];
  var folder        = app.project.file.path +"/"+ "images" +"/"+ aepFileVersion  +"/"+ compLayerName;
  folderObj = new Folder(folder);
  folderObj.create();
  return [ folder ];
}
//
function setRenderOutput(i,selectChoice){
  //パディング指定部分の文字列
  var frameCountPadding           = new RegExp("%5B#{1,7}%5D","i");
  //ムービもしくはサウンドファイルの拡張子の文字列
  var movieSoundFile              = new RegExp("(aif|avi|f4v|flv|mp4|m4v|mp3|mpg|mxf|mov|wav)$","i");
  //イメージファイルの拡張子文字列
  var sequenceImageFile           = new RegExp("dpx|cin|iff|jpg|exr|png|psd|hdr|sgi|tif|tga","i");
  var curRnedSet                  = app.project.renderQueue.item(i).outputModule(1);
  var renderAbsolutePath          = app.project.renderQueue.item(i).outputModule(1).file.absoluteURI;
  var fileNeme                    = fileNameVersionExtension(renderAbsolutePath);
  var renderOutputFolder          = makeOutputDir(i)[0];
  if (selectChoice == 0) {
    if ((frameCountPadding.test(fileNeme[0]) == 1)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    }
    else if ((frameCountPadding.test(fileNeme[0]) == 0)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    }
    else if (movieSoundFile.test(fileNeme[0]) == 1) {
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetMovieSound );
    }
    //
  }else if (selectChoice == 1) {
    curRnedSet.applyTemplate(outputModuleProject);
    curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    //
  }else if (selectChoice == 2) {
    if ((frameCountPadding.test(fileNeme[0]) == 1)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
      curRnedSet.applyTemplate(outputModuleImage);
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    }
    else if ((frameCountPadding.test(fileNeme[0]) == 0)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
      curRnedSet.applyTemplate(outputModuleImage);
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    }
    else if (movieSoundFile.test(fileNeme[0]) == 1) {
      curRnedSet.applyTemplate(outputModuleMovieSound);
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetMovieSound );
    }
  }else {
  }
}
//
function inputPromptSetRenderOutput(){
  var selectChoice = prompt("0-2を入力してください\n"+
                    "0:出力モジュールは変更せず出力先を設定\n"+
                    "1:出力モジュールを一括設定して出力先を設定!\n"+
                    "2:出力モジュールを設定して出力先を設定(ファイル判別)"
                    ,"0"
                    ,"setRenderPath");
  if (selectChoice != null){
    for (i = 1 ; i <= renderQueNumberItem ; i++){
        var renderQueActiveCompostion   = app.project.renderQueue.item(i).render;
        var renderAbsolutePath          = app.project.renderQueue.item(i).outputModule(1).file.absoluteURI;
        var fileNeme                    = fileNameVersionExtension(renderAbsolutePath);
        if (renderQueActiveCompostion == 1) {
          makeOutputDir(i);
          setRenderOutput(i,selectChoice);
        }
        else if(renderQueActiveCompostion == 0) {
          //alert("レンダーキューにアクティブなアイテムがねーっす:-q")
        }
    }
    if (selectChoice <= 2) {
      alert("設定しました");
    }else {
      alert("むりっす:-p");
    }
  }else {
    alert("キャンセルされました")
  }
}

//日時
var currentDate                 = dateAcquisition()[0] +"_"+ dateAcquisition()[1] +"_"+ dateAcquisition()[2] ;
//時刻
var currentTime                 = dateAcquisition()[3] +"_"+ dateAcquisition()[4];
//カレントのAepファイルのパス "-project project_path"
var aepProjectFileAbsolutePath  = app.project.file.absoluteURI;
//カレントのAepファイルの名前
var afterEffectsFileNeme        = fileNameVersionExtension(aepProjectFileAbsolutePath);
//レンダーキューのアイテム数
var renderQueNumberItem         = app.project.renderQueue.numItems;
//カレントのAepファイルのバージョン
var aepFileVersion              = fileNameVersionExtension(aepProjectFileAbsolutePath)[4];
//出力モジュール
var outputModuleImage           = "TIFF シーケンス (アルファ付き)"   //"Photoshop"
var outputModuleMovieSound      = "ロスレス圧縮(アルファ付き)"     //"H.264"
var outputModuleProject         = "Photoshop"                    //"TIFF シーケンス (アルファ付き)"
//ファイル名
var fileNameSetImage            = "[compName]_" + aepFileVersion + "_[####].[fileExtension]";
var fileNameSetMovieSound       = "[compName]_" + aepFileVersion + ".[fileExtension]";
inputPromptSetRenderOutput();

2015年12月24日木曜日

aerenderDiv

//aerender スキップフレーム版

var currentDate         = dateAcquisition()[0] +"_"+ dateAcquisition()[1] +"_"+ dateAcquisition()[2] ;
var currentTime         = dateAcquisition()[3] +"_"+ dateAcquisition()[4];
var randnum             = Math.floor( Math.random() * 100000 );
var userTempDir         = new Folder (Folder.temp);
//カレントのAepファイルのパス "-project project_path"
var aepProjectFileAbsolutePath  = app.project.file.absoluteURI;
//カレントのAepファイルの名前
var afterEffectsFileNeme        = fileNameExtension(aepProjectFileAbsolutePath);
//カレントaerenderのファイルのパス
var aeRenderAbsolutePath        = '"C:\\Program Files\\Adobe\\Adobe After Effects '+ applicationVersion() +'\\Support Files\\aerender.exe"';
//レンダーキューのアイテム数
var renderQueNumberItem         = app.project.renderQueue.numItems
//メモリの使用量とキャッシュの使用量 "-mem_usage image_cache_percent max_mem_percent"

//年月日取得
function dateAcquisition(){
  //今日の日時示
  var now   = new Date();
  var year  = now.getYear();      // 年
  var month = now.getMonth() + 1; // 月
  var day   = now.getDate();      // 日
  var hour  = now.getHours();     // 時
  var min   = now.getMinutes();   // 分
  var sec   = now.getSeconds();   // 秒
  if(year < 2000) { year += 1900; }
  // 数値が1桁の場合、頭に0を付けて2桁で表示する指定
  if(month  < 10) { month = "0" + month; }
  if(day    < 10) { day   = "0" + day; }
  if(hour   < 10) { hour  = "0" + hour; }
  if(min    < 10) { min   = "0" + min; }
  if(sec    < 10) { sec   = "0" + sec; }
  return [ year , month , day , hour , min , sec ];
}
//afterEffectsの確認
function applicationVersion(){
  var applicationBuildNumber  = app.buildName;
  var applicationVersion      = applicationBuildNumber.substring(0,4);
  if (applicationVersion == 10.0) {
    var applicationVersionCharacter = "CS5";
    return applicationVersionCharacter;
  }else if (applicationVersion == 10.5){
    var applicationVersionCharacter = "CS5.5";
    return applicationVersionCharacter;
  }else if ((applicationVersion == 11.0)||(applicationVersion == 11.1)){
    var applicationVersionCharacter = "CS6";
    return applicationVersionCharacter;
  }else if ((applicationVersion == 13.0)||(applicationVersion == 13.1)){
    var applicationVersionCharacter = "CC 2014";
    return applicationVersionCharacter;
  }else{
    return "バージョンを確認してください";
  }
}
//ファイル名と拡張子取得
function fileNameExtension(AbsolutePath){
  //拡張子込ファイル名
  var filePathAry           = AbsolutePath.split("/");
  var filePathAryLength     = filePathAry.length -1;
  var fileFullName          = filePathAry[filePathAryLength];
  //ファイル名とファイルタイプ(拡張子)
  var fileNameAry           = fileFullName.split(".");
  var fileNameAryLength     = fileNameAry.length -1;
  var fileName              = fileNameAry[0];
  var fileExtension         = fileNameAry[fileNameAryLength];
  return [fileFullName , fileName , fileExtension];
}
//プロジェクトファイルをtempへコピー
function copyAepFileToTemp(copySourceAep,copyDestinationDir){
  var currentAepFile              = new File( copySourceAep );
  var copyAepFile                 = new File( afterEffectsProjDir + currentDate +"/"+ afterEffectsFileNeme[0] );
  currentAepFile.copy(copyAepFile);
}
//ログファイル書き出し先 "-log logfile_path"
function createPathAepLogDir(){
  var afterEffectsLogDir          = (userTempDir.toString() + "/afterEffect/aerender/log/" + currentDate);
  var createAfterEffectsLogDir    = new Folder( afterEffectsLogDir ).create();
  return [ createAfterEffectsLogDir , afterEffectsLogDir ];
}
//プロジェクトファイルコピー先
function createPathAepProjDir(){
  var afterEffectsProjDir         = (userTempDir.toString() + "/afterEffect/aerender/project/");
  var createAfterEffectsAepDir    = new Folder( afterEffectsProjDir + currentDate ).create();
  return [ createAfterEffectsAepDir , afterEffectsProjDir ];
}
//バッチファイル書き出し先
function createPathAepBatDir(){
  var afterEffectsBatDir          = (userTempDir.toString() + "/afterEffect/aerender/batch/");
  var createAfterEffectsBatDir    = new Folder( afterEffectsBatDir + currentDate ).create();
  return [ createAfterEffectsBatDir , afterEffectsBatDir ];
}
//バッチファイル作成
function createPathBatchFile(afterEffectsBatDir){
  var afterEffectsBatFileName     = ("aerender" +"_" + afterEffectsFileNeme[1] +"_" + currentTime +"_"+ randnum + ".bat");
  var afterEffectsBatFilePath     = afterEffectsBatDir + currentDate +"/"+ afterEffectsBatFileName;
  var afterEffectsBatFile         = new File( afterEffectsBatFilePath );
  return [ afterEffectsBatFile , afterEffectsBatFilePath , afterEffectsBatFileName ];
}
//バッチファイルにコマンド追記
function addCommandToBatchFile(afterEffectsBatFile){
  var batFile =  new File(afterEffectsBatFile);
  var aepFileName = fileNameExtension(aepProjectFileAbsolutePath)[0];
  batFile.open("w");
  batFile.writeln("@echo off");
  batFile.writeln("title" +" "+ aepFileName +" "+ applicationVersion() +" "+ "batch start at"+" "+  "%time%");
  for  ( i = 0; i < batCommandLineAry.length; i++){
      batFile.writeln(batCommandLineAry[i]) + "\n";
  }
  batFile.close();
}
//コマンドラインオプション
function commandLineOption(i){
  //コンポジション名 "-comp comp_name"
  var compositonName              = app.project.renderQueue.item(i).comp.name;
  //コンポジションのフレームレート
  var compositonFrameRate         = app.project.renderQueue.item(i).comp.frameRate;
  //コンポジションのデュレーション
  var compositonDuration          = app.project.renderQueue.item(i).comp.duration * compositonFrameRate;
  //コンポジションのスタートフレーム "-s start_frame"
  var compostionStartTime         = app.project.renderQueue.item(i).comp.displayStartTime * compositonFrameRate;
  //コンポジションのエンドフレーム "-e end_frame"
  var compostionEndTime           = (compostionStartTime + compositonDuration) - 1;
  //ワークエリアのスタートフレーム "-s start_frame"
  var compostionWorkAreaStart     = app.project.renderQueue.item(i).comp.workAreaStart * compositonFrameRate;
  //ワークエリアのデュレーション
  var compositonWorkAreaDuration  = app.project.renderQueue.item(i).comp.workAreaDuration * compositonFrameRate;
  //コンポジションのエンドフレーム "-e end_frame"
  var compostionWorkAreaEndTime           = (compostionWorkAreaStart + compositonWorkAreaDuration) - 1;
  //レンダリング出力先 "-output  output_path"
  var renderPath                  = app.project.renderQueue.item(i).outputModule(1).file;
  //レンダリング出力先その2 ※Absoluteをつけないと配列にならない
  var renderAbsolutePath          = app.project.renderQueue.item(i).outputModule(1).file.absoluteURI;
  return [ compositonName , compostionStartTime , compostionEndTime , compostionWorkAreaStart , compostionWorkAreaEndTime , renderAbsolutePath ]
}
//分割しない場合のコマンドライン
function indivisibleFileComandLine(i){
  var comp = commandLineOption(i)[0];
  var indivisibleFile = "start /wait"
    +" "+ '"' + comp +" "+ applicationVersion() +" "+ "rendering start at"+" "+ "%time%"+'"'
    +" "+ aeRenderAbsolutePath
    +" "+ "-project" + " " + aepProjectFileAbsolutePath
    +" "+ "-rqindex" + " " + i
    +" "+ "-sound ON"
    +" "+ "-continueOnMissingFootage";
  batCommandLineAry.push(indivisibleFile);
}
//分割する場合のコマンドライン
function divideFileComandLine(i){
  var comp = commandLineOption(i)[0];
  var divideNum = numDiv
  for (k = 1 ; k <= divideNum ; k++){
    if (k < divideNum) {
      var indivisibleFile = "start"
        +" "+ '"' + comp +" "+ applicationVersion() +" "+ "rendering start at"+" "+ "%time%"+'"'
        +" "+ aeRenderAbsolutePath
        +" "+ "-project" + " " + aepProjectFileAbsolutePath
        +" "+ "-rqindex" + " " + i
        +" "+ "-RStemplate" + " " + "マルチマシン設定"
        +" "+ "-continueOnMissingFootage";
        batCommandLineAry.push(indivisibleFile);
    }else if (k == divideNum) {
      var indivisibleFile = "start /wait"
        +" "+ '"' + comp +" "+ applicationVersion() +" "+ "rendering start at"+" "+ "%time%"+'"'
        +" "+ aeRenderAbsolutePath
        +" "+ "-project" + " " + aepProjectFileAbsolutePath
        +" "+ "-rqindex" + " " + i
        +" "+ "-RStemplate" + " " + "マルチマシン設定"
        +" "+ "-sound ON"
        +" "+ "-continueOnMissingFootage";
        batCommandLineAry.push(indivisibleFile);
    }else {
      batCommandLineAry.push(":-q")
    }
  }
}
//レンダーキューのアクティブキュー情報取得バッチファイルへ書き出し
function renderQueueToBatchFile(){
  //パディング指定部分の文字列
  var frameCountPadding           = new RegExp("%5B#{1,7}%5D","i");
  //ムービもしくはサウンドファイルの拡張子の文字列
  var movieSoundFile              = new RegExp("(aif|avi|f4v|flv|mp4|m4v|mp3|mpg|mxf|mov|wav)$","i");
  //イメージファイルの拡張子文字列
  var sequenceImageFile           = new RegExp("dpx|cin|iff|jpg|exr|png|psd|hdr|sgi|tif|tga","i");
  
  for (i = 1 ; i <= renderQueNumberItem ; i++){
      var renderQueActiveCompostion   = app.project.renderQueue.item(i).render;
      var renderAbsolutePath          = app.project.renderQueue.item(i).outputModule(1).file.absoluteURI;
      var fileNeme                    = fileNameExtension(renderAbsolutePath);
      if (renderQueActiveCompostion == 1) {
          //alert (fileNeme[0] + "を" +"レンダーするっす:-p");
          if ((frameCountPadding.test(fileNeme[0]) == 1)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
            if (numDiv == 0){
              //alert("レンダリングしないっす:-q");
            }else if (numDiv == 1) {
              //alert("レンダリングするっす:-q");
              indivisibleFileComandLine(i);
            }else if (numDiv >= 2 && numDiv <= 12) {
              //alert("レンダリングするっす:-q");
              divideFileComandLine(i);
            }
          }
          else if ((frameCountPadding.test(fileNeme[0]) == 0)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
              indivisibleFileComandLine(i);
          }
          else if (movieSoundFile.test(fileNeme[0]) == 1) {
              indivisibleFileComandLine(i);
          }
      }
      else if(renderQueActiveCompostion == 0) {
      //alert ("レンダーキューにアクティブなアイテムがねーっす:-q")
      }
  }
}
//入力ダイアログ
function inputPrompt(){
  var text = prompt("並列でレンダリングする数を入力してください \n 2-8 をお勧めします","4");
  if (text != null){
    //alert("並列数は"+text+"です")
  }else {
    alert("キャンセルされました")
  }
  return [ text ];
}
//レンダリング条件分岐
function renderingBranch(){
  if (numDiv == 0){
    alert("レンダリングしないっす:-q");
  }else if (numDiv == 1) {
    renderQueueToBatchFile();
    createBatchFile;
    addCommandToBatchFile(afterEffectsBatFile);
    alert("並列レンダリングしないっす:-q");
  }else if (numDiv >= 2 && numDiv <= 8) {
    renderQueueToBatchFile();
    createBatchFile;
    addCommandToBatchFile(afterEffectsBatFile);
    alert("並列レンダリングするっす:-D");
  }else if (numDiv >= 9 && numDiv <= 12) {
    renderQueueToBatchFile();
    createBatchFile;
    addCommandToBatchFile(afterEffectsBatFile); 
    alert("お勧めしないぴょん:-p");
  }else if (numDiv >= 13) {
    alert("むりっす(;´・ω・)");
  }
}
//メイン
var numDiv = inputPrompt()[0];
var batCommandLineAry   = new Array();
var afterEffectsBatFile = createPathBatchFile(createPathAepBatDir()[1])[1];
var batFile =  new File(afterEffectsBatFile);
var createBatchFile     = createPathBatchFile(createPathAepBatDir()[1]);

renderingBranch();
batFile.execute();

2014年4月28日月曜日

プロジェクト設定

//プロジェクト設定スクリプト CS6
//=============================================================================================
//Pref_SCRIPTING_FILE_NETWORK_SECURITYの値判定

function isSecurityPrefSet(){
    var securitySetting = app.preferences.getPrefAsLong("Main Pref Section", "Pref_SCRIPTING_FILE_NETWORK_SECURITY");
    return (securitySetting == 1);
    }

//=============================================================================================

if (isSecurityPrefSet() == true){
/*  プロジェクト設定  */

//=============================================================================================
/*  時間の表示形式   */

//タイムコード
//app.project.timeDisplayType = TimeDisplayType.TIMECODE;
//alert (app.project.timeDisplayType)
/*  タイムコード指定時フッテージの開始時間
FTCS_START_0
FTCS_USE_SOURCE_MEDIA
*/
//app.project.footageTimecodeDisplayStartType = FootageTimecodeDisplayStartType.FTCS_USE_SOURCE_MEDIA;

//フレーム
app.project.timeDisplayType = TimeDisplayType.FRAMES;

/*  フレーム指定時にフィート+フレームのオンオフ
0
1
*/
app.project.framesUseFeetFrames = 0;

/*  フレーム指定時にフィート+フレームのタイプ指定 
MM16
MM35
*/
//app.project.feetFramesFilmType = FeetFramesFilmType.MM35;

/*  プロジェクト設定ダイアログの「フレーム数」の設定
FC_START_0
FC_START_1
FC_TIMECODE_CONVERSION で指定
*/
app.project.framesCountType = FramesCountType.FC_START_1;

//=============================================================================================
/*  カラー設定   */
/*  プロジェクトの色深度
8
16
32
*/
app.project.bitsPerChannel = 8;

/*  ガンマ1.0でカラーをブレンド
0
1
*/
app.project.linearBlending = 0;


//=============================================================================================
/*  環境設定  */

/*  読み込み設定_シーケンスフッテージ
"24.000000"
"30.000000"
*/
app.preferences.savePrefAsString("Import Options Preference Section", "Import Options Default Sequence FPS","24.000000");
/*  一般設定_ツールヒントを表示
00
01
*/    
app.preferences.savePrefAsBool("Main Pref Section", "Pref_TOOL_TIPS",01);

/*  一般設定_JavaScriptデバッガーを使用
"0"
"1"
*/ 
app.preferences.savePrefAsString("Main Pref Section", "Pref_JAVASCRIPT_DEBUGGER","1");

/*  ディスプレイ設定_情報パネルとフローチャートにレンダリングの進行状況を表示
00
01
*/ 
app.preferences.savePrefAsBool("Main Pref Section", "Pref_SHOW_INFO_FLOATER_PROGRESS",01);

//app.preferences.saveToDisk();
//app.preferences.reload();
//=============================================================================================
/*  プロジェクト設定  */

//プロジェクト設定の「時間の表示形式」に相当。タイムコードかフレームかの設定
var tDisplayType = app.project.timeDisplayType;
//タイムコード指定時フッテージの開始時間
var pfTimecodeDsiplayStartType = app.project.footageTimecodeDisplayStartType;
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
//フレーム指定時のフィート+フレームのオン・オフ設定
var pFramesUseFeetFrames = app.project.framesUseFeetFrames;
//フレーム指定時のフィート+フレームのタイプの設定
var pFeetFramesFilmType  = app.project.feetFramesFilmType;
//フレーム指定時の「フレーム数」の設定
var pFramesCountType = app.project.framesCountType;
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
//プロジェクトの色深度
var pBitPerChannel = app.project.bitsPerChannel;
//ガンマ1.0でカラーをブレンド
var pLinearBlending = app.project.linearBlending;
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
/*  環境設定  */

//読み込み設定_シーケンスフッテージ
var pPrefImportFps = app.preferences.getPrefAsString("Import Options Preference Section", "Import Options Default Sequence FPS");
//一般設定_ツールヒントを表示
var pPrefToolTips =app.preferences.getPrefAsBool("Main Pref Section", "Pref_TOOL_TIPS");
//一般設定_JavaScriptデバッガーを使用
var pPrefJavascriptDebugger = app.preferences.getPrefAsString("Main Pref Section", "Pref_JAVASCRIPT_DEBUGGER");
//ディスプレイ設定_情報パネルとフローチャートにレンダリングの進行状況を表示
var pPrefShowInfoProgress = app.preferences.getPrefAsBool("Main Pref Section", "Pref_SHOW_INFO_FLOATER_PROGRESS");

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------

if  (tDisplayType == 1812){
    var tDisplayType = "表示形式>>>タイムコード";
    if (pfTimecodeDsiplayStartType == 2012){
        var  pfTimecodeDsiplayStartType = "メディアのデータを使用";
        }
    else if (pfTimecodeDsiplayStartType == 2013){
        var  pfTimecodeDsiplayStartType = "00:00:00:00";
        }
    }
else if (tDisplayType == 1813){
        var tDisplayType = "表示形式>>>フレーム";
        if  (pFramesUseFeetFrames == true){
            var pFramesUseFeetFrames = "オン";
            if (pFeetFramesFilmType == 2213){
                var pFeetFramesFilmType = "35mm";
                }
            else if (pFeetFramesFilmType == 2212){
                var pFeetFramesFilmType = "16mm";
                }       
            }
        else if (pFramesUseFeetFrames == false){
            var pFramesUseFeetFrames = "オフ";
            }
        }

if (pFramesCountType ==  2413){
    var pFramesCountType = "1から開始"
    }
else if (pFramesCountType ==  2412){
    var pFramesCountType = "0から開始"
    }
else if (pFramesCountType ==  2414){
    var pFramesCountType = "タイムコード変換"
    }

if (tDisplayType == "表示形式>>>タイムコード"){
    var timeDisplay = tDisplayType +"\n"
    + "フレーム数"+">>>"+ pfTimecodeDsiplayStartType;
    }
else if (tDisplayType = "表示形式>>>フレーム"){
    if (pFramesUseFeetFrames == "オン"){
        var timeDisplay = tDisplayType +"\n"
        + "フィート+フレーム" +  ">>>" + pFramesUseFeetFrames +"\n"
        + "表示形式" + ">>>" + pFeetFramesFilmType + "\n" 
        + "フレーム数"+">>>"+ pFramesCountType;
        }
    else if (pFramesUseFeetFrames == "オフ"){
        var timeDisplay =  tDisplayType +"\n"
        + "フィート+フレーム" +  ">>>" + pFramesUseFeetFrames +"\n"
        + "フレーム数"+">>>"+ pFramesCountType;
         }
    }
 //-------------------------------------------------------------------------------------------------------------------------------------------------------------------

if (pBitPerChannel == 8){
    var pBitPerChannel = "色深度>>>8bit/チャンネル";
    }
else if (pBitPerChannel == 16){
    var pBitPerChannel = "色深度>>>16bit/チャンネル";
    }
else if (pBitPerChannel == 32){
    var pBitPerChannel = "色深度>>>32bit/チャンネル(浮動小数点数)";
    }

if (pLinearBlending == true){
    var pLinearBlending = "ガンマ値1.0でカラーをブレンド>>>オン";
    }
else if  (pLinearBlending == false){
    var pLinearBlending = "ガンマ値1.0でカラーをブレンド>>>オフ";
    }


var colorSetting = pBitPerChannel + "\n" + pLinearBlending

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
var importFPS = "環境設定>>>読み込み設定>>>"+pPrefImportFps+" FPS";

if (pPrefToolTips == true){
    var toolTips = "環境設定>>>一般設定>>>ツールヒントを表示>>>オン";
    }
else if  (pPrefToolTips == false){
    var toolTips = "環境設定>>>一般設定>>>ツールヒントを表示>>>オフ";
    }

if (pPrefJavascriptDebugger == "1"){
    var javascriptDebugger = "環境設定>>>一般設定>>>Javascriptデバッガーを使用>>>オン";
    }
else if  (pPrefJavascriptDebugger == "0"){
    var javascriptDebugger = "環境設定>>>一般設定>>>Javascriptデバッガーを使用>>>オフ";
    }

if (pPrefShowInfoProgress == true){
    var showInfoProgress = "環境設定>>>ディスプレイ設定>>>情報パネルに進行状況を表示>>>オン";
    }
else if  (pPrefShowInfoProgress == false){
    var showInfoProgress = "環境設定>>>ディスプレイ設定>>>情報パネルに進行状況を表示>>>オフ";
    }


alert 
(
"=============================================================="
+ "\n" 
+ "プロジェクト設定\n"
+ "\n"
+ "++++++時間の表示形式++++++\n"
+ timeDisplay + "\n"
+ "\n"
+ "++++++++カラー設定+++++++++\n"
+ colorSetting + "\n"
+ "\n"
+ "++++++++環境設定++++++++++\n"
+ "\n" 
+ importFPS
+ "\n" 
+toolTips
+ "\n" 
+javascriptDebugger
+ "\n" 
+showInfoProgress
+ "\n" 
+"=============================================================="
)


}
else{
alert ("環境設定>\n一般設定>\nスクリプトによるファイルへの書き込みとネットワークへのアクセス許可\n↑\nのチェックをオンにしてください、スクリプト実行時に必要な場合があります");

}

2014年4月21日月曜日

Launch Pad.jsxを複数起動する方法

Launch Pad.jsxを複数起動する方法
launchPad_scriptsFoloderの部分をすべて置換、スクリプト本体の名前も同様にリネームします
スクリプト本体の置き場所はLaunch Pad.jsxと同じで下記にしておかないとフローティングパネル化しないと思います
C:\Program Files\Adobe\Adobe After Effects CS[各バージョン]\Support Files\Scripts\ScriptUI Panels
初回起動時にLaunch Padに表示するスクリプトの場所を聞かれます

2014年4月8日火曜日

タイムリマップのオンオフ

control = thisComp.layer("expNull").effect("timeRemapOnOff")("チェックボックス") ;

if (control == 1){
value;
}else{
time;
}

2013年7月4日木曜日

メモ_番号歯抜けでも連番ファイルを順に読み込む

importFile()を使ってimportOptions.forceAlphabetical を true にすると番号歯抜けでも順に読み込める

2013年6月27日木曜日

フッテージのドライブレター変更

var numItems = app.project.numItems;

for(i = 1; i <= numItems; i++) {
    if(app.project.item(i).typeName == "フッテージ") {
        if( !app.project.item(i) ) continue;
        var cItem = app.project.item(i).file;
        if( !cItem ) continue;
        var cItemPath = cItem.path;
        var cItemName = cItem.name;
        //拡張子
        var fooPattern = /(.+)(\.[^.]+$)/;
        var tExt = cItemName.match(fooPattern)[2];
        var cItemExt = tExt;
        //alert (cItemExt);
        //alert (cItemName);
        var psdExt = "psd"
        var cItemFullPath = cItemPath + "/" + cItemName;
        // 置換処理++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        var rFilePath = cItemPath.replace(/y/, "x");
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        var rFileFullPath = rFilePath + "/" + cItemName;
        //alert (rFileFullPath)
        var cItemMainSource = app.project.item(i).mainSource;
        var cFrameRate = cItemMainSource.conformFrameRate;
        var dFrameRate = cItemMainSource.displayFrameRate;
        var nFrameRate = cItemMainSource.nativeFrameRate;
        //alert (cFrameRate +"_"+ dFrameRate +"_"+ nFrameRate);
       if( cItemMainSource.isStill == true ) {
           if ( cItemExt == ".psd" ){
               //alert ("psdファイルはスキップします")
               }
           else if ( cItemExt == ".PSD" ){
               //alert ("PSDファイルはスキップします")              
               }
           else{
           var cFootageImageName = (rFileFullPath);
           var cFootageImageName = decodeURI(cFootageImageName);
           //alert (cFrameRate +"_"+ dFrameRate +"_"+ nFrameRate);
           //alert (cFootageImageName , "イメージ")
           app.project.item(i).replace(new File(cFootageImageName));
                }
           }
       else{
           if( cFrameRate == 0 ){
               var cFootageMsName = (rFileFullPath);
               var cFootageMsName = decodeURI(cFootageMsName);
               //alert (cFrameRate +"_"+ dFrameRate +"_"+ nFrameRate);
               //alert (cFootageMsName , "ムービかサウンド")
               app.project.item(i).replace(new File(cFootageMsName));
               }
               else{
                   var cFootageSeqName = (rFileFullPath);
                   var cFootageSeqName = decodeURI(cFootageSeqName);
                   //alert (cFrameRate +"_"+ dFrameRate +"_"+ nFrameRate);
                   //alert (cFootageSeqName , "連番イメージ")
                   try{
                   app.project.item(i).replaceWithSequence(new File(cFootageSeqName),false);
                   } catch(err) {
                       var msg = cFootageSeqName + "はファイルが無いようです";
                       alert(msg);
                    }
                }
            }
        }
    }


alert ("ドライブレターの変更終了")

2013年6月24日月曜日

フッテージをローカルにコピー

//今日の日時示
var now = new Date();
var year = now.getYear(); // 年
var month = now.getMonth() + 1; // 月
var day = now.getDate(); // 日
var hour = now.getHours(); // 時
var min = now.getMinutes(); // 分
var sec = now.getSeconds(); // 秒

if(year < 2000) { year += 1900; }

// 数値が1桁の場合、頭に0を付けて2桁で表示する指定
if(month < 10) { month = "0" + month; }
if(day < 10) { day = "0" + day; }
if(hour < 10) { hour = "0" + hour; }
if(min < 10) { min = "0" + min; }
if(sec < 10) { sec = "0" + sec; }

var batRcopyDir = "c:\\aeBat\\rcopy\\";
var dateDir = year +"_"+  month  + "_" + day;
var curTime = hour + "_" + min;

Folder(batRcopyDir + dateDir).create();

//rcopyのオプションとbatの変数
var copyOpt = '/S /TS /TEE /ETA /R:0 /XD old tmp temp *ログ /XF log.txt Thumbs.db /XO /NP /LOG+:C:%homepath%\\roboCopyLog\\%yy%%mm%%dd%\\log"_%tt%_%ff%_%bb%".txt';
var batTitle = "@title rcopyToX" 
var batPause = "@pause"
var batYyyy = "@set yyyy=%date:~0,4%"
var batYy = "@set yy=%date:~2,2%"
var batMm = "@set mm=%date:~5,2%"
var batDd = "@set dd=%date:~8,2%"
var batTt = "@set tt=%time:~0,2%"
var batFf = "@set ff=%time:~3,2%"
var batBb = "@set bb=%time:~6,2%"

var batRcopyLogDir = '@mkdir C:%homepath%\\roboCopyLog\\%yy%%mm%%dd%'
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
var aepFullFileName = app.project.file.name;

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
var batRcopyEnv = batTitle +" "+aepFullFileName +"_"+ "Footages" + "\n" + batPause + "\n" + batYyyy + "\n" + batYy + "\n" + batMm + "\n" + batDd + "\n" + batTt + "\n" + batFf + "\n" + batBb + "\n" + batRcopyLogDir;

alert (copyOpt);
alert (batRcopyEnv);

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

var rcopy = "robocopy";
var randnum = Math.floor( Math.random() * 100000 );

var aepFileName = aepFullFileName.replace(aepExtension,"")
var batRcopyFile = new File(  batRcopyDir + dateDir + "\\"+ "rcopy" +"_" + aepFileName +"_" + curTime +"_"+ randnum + ".bat");

batRcopyFile.open("w");
batRcopyFile.writeln(batRcopyEnv)

// 置換対象文字列
var numItems = app.project.numItems;
//myArray = new Array(numItems);
for(i = 1; i <= numItems; i++) {
    if(app.project.item(i).typeName == "フッテージ") {
        if( !app.project.item(i) ) continue;
        var cItem = app.project.item(i).file;
        if( !cItem ) continue;
        //alert (cItem);
        var cItemPath = cItem.path;
        var cItemName = cItem.name;
        var cItemStr = String (cItem);
        var cItemPathStr = String (cItemPath);
        var cItemNameStr = String (cItemName);
        // 置換処理
        var cItemPathStr = cItemPathStr.replace(/\/y\//g, "y:\\");
        var cItemPathStr = cItemPathStr.replace(/\//g, "\\");
        var dFilePathStr = cItemPathStr.replace(/y:\\/g, "x:\\");
        //alert (cItemPathStr);
        //alert (dFilePathStr);
        var copyFootage = (rcopy +" "+ cItemPathStr +" "+ dFilePathStr +" "+ copyOpt)
        batRcopyFile.writeln(copyFootage)
        }
    }
batRcopyFile.writeln(batPause)
batRcopyFile.close();

batRcopyFile.execute();

2013年6月14日金曜日

GUIからaerender

//今日の日時示
var now = new Date();
var year = now.getYear(); // 年
var month = now.getMonth() + 1; // 月
var day = now.getDate(); // 日
var hour = now.getHours(); // 時
var min = now.getMinutes(); // 分
var sec = now.getSeconds(); // 秒

if(year < 2000) { year += 1900; }

// 数値が1桁の場合、頭に0を付けて2桁で表示する指定
if(month < 10) { month = "0" + month; }
if(day < 10) { day = "0" + day; }
if(hour < 10) { hour = "0" + hour; }
if(min < 10) { min = "0" + min; }
if(sec < 10) { sec = "0" + sec; }

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
var curTime = hour + "_" + min;
var batDir = "c:\\aeRenderBat\\";
var dateDir = year +"_"+  month  + "_" + day;

Folder( batDir + dateDir ).create();

//var aeVersion = app.version;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

str = app.buildName
nStr = str.substring(0,4)
//alert (nStr)
if (nStr == 10.0) {
    nStr = "CS5"
    alert(nStr)    
    }else if (nStr == 10.5){
        nStr = "CS5.5"
        alert(nStr)
        }else if (nStr == 11.0){
            nStr = "CS6"
            alert(nStr) 
            }else{
                alert (バージョンを確認してください)
                }
            
var randnum = Math.floor( Math.random() * 100000 );
var aeRender = '"C:\\Program Files\\Adobe\\Adobe After Effects '+ nStr +'\\Support Files\\aerender.exe"';
var projectFile = app.project.file.absoluteURI;
var aepExtension = ".aep"
var aepFullFileName = app.project.file.name;
var aepFileName = aepFullFileName.replace(aepExtension,"")
var proj =  "-project";
var batFile = new File(  batDir + dateDir + "\\"+ "aerender" +"_" + aepFileName +"_" + curTime +"_"+ randnum + ".bat");

//alert (aeRender+ proj + projectFile);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
batFile.open("w");
batFile.writeln('title' + " " + 'AfterEffects' + " " + nStr + " " + 'rendering' + " " + aepFullFileName)
batFile.writeln( aeRender + " " + '-mem_usage 10 20'  + " " +  proj  + " " + projectFile)
batFile.close();

batFile.execute();
//