Skip to main content
Participating Frequently
November 30, 2012
Question

Can I read/write inpoint and outpoint of clips in a Video Group with scripting?

  • November 30, 2012
  • 1 reply
  • 2829 views

I am a Prefessional 2d Storyboarder and I just got Photoshop CS6 through the Creative Cloud. I am very Impressed by the new Video Group .

There is a lot of function I would like to customize  For instance there is a go to next Frame. I would like to script which go to first frame of the next clip in the video group layer and select this layer. So I can draw my next storyboard panel on ot.

so Is it possible though to access and Manipulate the video Group Information Through Scripting?

For instance this

app.activeDocument.activeLayer.typename;

return "LayerSet"

So It seems like I cannot tell an odinairy LayerSet from a "Video Group" Layer Set. Is this Correct?

Then if I go throught the Properties of the first layer in the Video group like this

var firstLayer = app.activeDocument.activeLayer.layers[0];

    

   for (prop in firstLayer){

            alert(prop);

     }

It seems there is no inpoint or outpint . So I guess it is nor possible to read/write inpint and outpoint of Clip in Viedeo Group, or is there another way?

Kind Regards Mads

This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
November 30, 2012

You would need to use the ScriptListener plugin to see what code is generated when you do those actions.

You should be able to look at all the keys available of the selected layers and see what might be of use to you.

Here is some of Mikes code that you could run from ExtendScript Toolkit on a selected layer.

#target photoshop

var ref = new ActionReference();

ref.putEnumerated( zTID("Lyr "), zTID("Ordn"), zTID("Trgt") );

var desc = executeActionGet(ref);

$.writeln(desc);

var c = desc.count

if(desc.typename == 'ActionReference'){

    var c = desc.count;

    for(var i=0;i<c;i++){ //enumerate reference. use getForm() to determine which get method to use

      $.writeln('AR '+zeroPad( i+1, 2 )+' = '+desc.getReference(i).getIndex());

    }

}

if(desc.typename == 'ActionList'){

    var c = desc.count;

    for(var i=0;i<c;i++){ //enumerate list

     $.writeln('AL '+zeroPad( i+1, 2 )+' = '+desc.getType(i)/* added desc.getPath(i) for aliastype */ +' - ' + typeIDToStringID(desc.getClass (i)));

    }

}

if(desc.typename == 'ActionDescriptor'){

    var c = desc.count;

    for(var i=0;i<c;i++){ //enumerate descriptor's keys

      $.writeln('AD '+zeroPad( i+1, 2 )+' = '+IDTz(desc.getKey(i)) +' : '+desc.getType(desc.getKey(i)));

    }

}

function IDTz(id){

     try {

          var res = typeIDToStringID( id );

          if(res == '' ){

               var res = typeIDToCharID( id );

          }

     }catch(e){}

     return res;

}

function zTID( s ){

     if( s.length == 4 ) var res = charIDToTypeID( s );

     if( s.length > 4 ) var res = stringIDToTypeID( s );

     return res;

}

function zeroPad(num,pad) {

     var z = Math.pow(10,Number(pad))

     return num <= z ? ((Number( num) + z).toString().substr(1)): num

}

Participating Frequently
November 30, 2012

So you are verifying there is no scriptcode to directly get/Set information about the timeline in the Video Group?

I thought so. Have have briefly Loooked aty the Scriptlistener output. It didnt seem to give the neccessaty output. For instance Which is the current frame and what layer is present at a specific time.

But I will ook into it with the code you have provided and another post if I find something. thank you for the help.

Paul Riggott
Inspiring
November 30, 2012

There is no easy way, here are a few functions that might be of use....

function gotoFrame(Seconds,Frame,frameRate) {

    var desc69 = new ActionDescriptor();

        var ref33 = new ActionReference();

        ref33.putProperty( charIDToTypeID('Prpr'), stringIDToTypeID('time') );

        ref33.putClass( stringIDToTypeID('timeline') );

    desc69.putReference( charIDToTypeID('null'), ref33 );

        var desc70 = new ActionDescriptor();

        desc70.putInteger( stringIDToTypeID('seconds'), Seconds );

        desc70.putInteger( stringIDToTypeID('frame'),Frame );

        desc70.putDouble( stringIDToTypeID('frameRate'), frameRate );

    desc69.putObject( charIDToTypeID('T   '), stringIDToTypeID('timecode'), desc70 );

    executeAction( charIDToTypeID('setd'), desc69, DialogModes.NO );

};

function gotoNextFrame(toNextSecond) {

if(toNextSecond == undefined) toNextSecond = false;

    var desc = new ActionDescriptor();

    desc.putBoolean( stringIDToTypeID('toNextWholeSecond'), toNextSecond);

    executeAction( stringIDToTypeID('nextFrame'), desc, DialogModes.NO );

};

function gotoPreviousFrame(toNextSecond) {

if(toNextSecond == undefined) toNextSecond = false;

var desc = new ActionDescriptor();

desc.putBoolean( stringIDToTypeID('toNextWholeSecond'), toNextSecond);

executeAction( stringIDToTypeID('previousFrame'), desc, DialogModes.NO );

};

function getCurrentFrame(){

   try{

      var ref = new ActionReference();

      ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('currentFrame'));

      ref.putClass(stringIDToTypeID('timeline'));

      var desc=new ActionDescriptor();

      desc.putReference(charIDToTypeID('null'), ref);        

      var TC=executeAction(charIDToTypeID('getd'), desc, DialogModes.NO);

      return TC.getInteger(stringIDToTypeID('currentFrame'));

   }catch(e){return null;}

};

function trimStartOfClip(seconds, frame, framerate) {

var desc45 = new ActionDescriptor();

var desc46 = new ActionDescriptor();

desc46.putInteger( stringIDToTypeID('seconds'), seconds );

desc46.putInteger( stringIDToTypeID('frame'), frame );

desc46.putDouble( stringIDToTypeID('frameRate'), framerate );

desc45.putObject( stringIDToTypeID('timeOffset'), stringIDToTypeID('timecode'), desc46 );

executeAction( stringIDToTypeID('moveInTime'), desc45, DialogModes.NO );

};

function trimEndOfClip(seconds, frame, framerate) {

var desc42 = new ActionDescriptor();

var desc43 = new ActionDescriptor();

desc43.putInteger( stringIDToTypeID('seconds'), seconds);

desc43.putInteger( stringIDToTypeID('frame'), frame );

desc43.putDouble( stringIDToTypeID('frameRate'), framerate );

desc42.putObject( stringIDToTypeID('timeOffset'), stringIDToTypeID('timecode'), desc43 );

executeAction( stringIDToTypeID('moveOutTime'), desc42, DialogModes.NO );

};

//trimEndOfClip(-10,0,200);

function videoInfo(){

var Info= new Array(); 

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

var desc = executeActionGet(ref);

if(desc.hasKey (stringIDToTypeID('videoLayer'))){

var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('videoLayer'));

var footageInfo = desc.getObjectValue(stringIDToTypeID('footageInfo'));

var duration = footageInfo.getObjectValue(stringIDToTypeID('duration'));

var FilmDuration  = duration.getInteger (stringIDToTypeID('numerator')) / duration.getInteger (stringIDToTypeID('denominator'));

var fRate = footageInfo.getObjectValue(stringIDToTypeID('frameRate'));

var frameRate  = fRate.getInteger (stringIDToTypeID('numerator')) / fRate.getInteger (stringIDToTypeID('denominator'));

var Path = footageInfo.getString( stringIDToTypeID('path'));

var Alpha = footageInfo.getBoolean( stringIDToTypeID('hasAlpha'));

Info.push([[frameRate],[FilmDuration],[Alpha],[Path]]);

return Info;

    }

return null;

};