Document toolboxDocument toolbox

Vidispine

Overriding Presets When Transcoding

Sometimes you want to override your presets when transcoding. This can be done with a set function, using the corresponding element names from XML. Say that you are starting with the following preset document: 

<TranscodePresetDocument xmlns="http://xml.vidispine.com/schema/vidispine"> <format>mp4</format> <video> <codec>h264</codec> <bitrate>512000</bitrate> <scaling> <width>1280</width> <heigth>720</height> </scaling> </video> <audio> <codec>aac</codec> </audio> </TranscodePresetDocument>

 

 and then you want to change width, height and codec, you can use the following code: 

preset.getVideo().getScaling().setWidth(480); preset.getVideo().getScaling().setHeight(640); preset.getVideo().setCodec("h264");

 

 If your preset document doesn't have the a <code>scaling</code> element set in the first place, you must create it in the Javascript code: 

var scaling = new com.vidispine.generated.ScalingType(); preset.getVideo().setScaling(scaling); preset.getVideo().getScaling().setWidth(480); preset.getVideo().getScaling().setHeight(640);

 

 Then, how do I find what get and set are connected to a specific XML attribute? Let's use the following audio preset as an example: 

 

 The starting point here would be the API documentation, looking at the generated packages. Here we look at the TranscodePresetType, following that one to AudioTranscodePresetType, and then further to AudioTranscodePresetMixType. Also, you see that get AudioTranscodePresetType has a getMix(), that returns a List, so the code should look like: