File

Video Manipulation

Trelae supports non-destructive, queued video transformations. Chain one or more operations and apply them via .save().

  • Video jobs default to async; poll with getVideoStatus(operationId).
  • Optionally run in sync mode: .save({ mode: 'sync' }) (use for short/fast operations only).

Quick Start (async + polling)


Operations

Change Format / Codecs

Convert container, set codecs, CRF, and preset.

Method: file.changeVideoFormat(params)


Trim

Cut by start + duration or start + end.

Method: file.trimVideo({ start?, duration?, end? })


Scale

One dimension → aspect kept. Both dimensions → aspect forced (not kept).

Method: file.scaleVideo({ width?, height?, keepAspect? })


Rotate / Flip

Method: file.rotateFlipVideo({ rotate?, hflip?, vflip? })


Remove Audio

Method: file.removeAudio()


Speed

Change playback rate of video and/or audio.

Method: file.speedVideo({ videoSpeed?, audioSpeed? })


Crop

Method: file.cropVideo({ x, y, width, height })


Mute Segment

Silence audio for a time window.

Method: file.muteSegment({ start, duration })


Visual Fade (in/out)

Method: file.fadeVideo({ type: 'in' | 'out', startTime, duration })


Timed Text Overlay

Method: file.addTextVideo({ text, x, y, fontSize?, fontColor?, fontFile?, startTime?, endTime? })


Add Border

Method: file.addBorderVideo({ color?, top?, bottom?, left?, right? })


Reverse

Method: file.reverseVideo({ video?, audio? })


Audio Fade (in/out)

Method: file.audioFadeVideo({ type, startTime, duration })


Motion Blur

Method: file.motionBlurVideo({ frames?, weights?, outputFps? })


Grayscale

Method: file.grayscaleVideo()


Color EQ

Method: file.colorEQVideo({ brightness?, contrast?, saturation?, gamma? })


Hue Rotate

Method: file.hueRotateVideo({ degrees, saturation? })


Box Blur (time-bounded)

Method: file.boxBlurVideo({ lumaRadius?, lumaPower?, startTime?, endTime? })


Sharpen

Method: file.sharpenVideo({ amount?, size? })


Volume (gain)

Method: file.volumeVideo({ gain })


Sync vs Async

  • Async (default): returns immediately with { type: 'video', status, operationId }. Poll via getVideoStatus().
  • Sync: await file.trimVideo({...}).save({ mode: 'sync' }). Prefer for quick ops; long jobs should be async.

Parameter Reference (Cheat Sheet)

All operations are validated at runtime; invalid combinations will throw.
Defaults are shown in bold when applicable.

Enumerations & Allowed Values

Formats (for changeFormat.format)
mp4 · m4v · mov · mkv · webm · avi · flv · f4v · ogg · ogv · ts · m2ts · mts · mpg · mpeg · ps · vob · 3gp · 3g2 · asf · wmv · mxf · gxf · dv · nut · y4m · apng · gif

Video Codecs (for changeFormat.videoCodec)
libx264 · h264 · h264_nvenc · h264_qsv · h264_amf ·
libx265 · hevc · hevc_nvenc · hevc_qsv · hevc_amf ·
libvpx · vp8 · libvpx-vp9 ·
prores · prores_ks · dnxhd · dnxhr · mpeg4 · msmpeg4 · copy

Audio Codecs (for changeFormat.audioCodec)
aac · libmp3lame · mp3 · libopus · libvorbis · ac3 · eac3 · flac · alac · pcm_s16le · pcm_s24le · copy

Presets (x264/x265)
ultrafast · superfast · veryfast · faster · fast · medium · slow · slower · veryslow

Rotate (for rotateFlip.rotate)
“90” · “180” · “270”


Operations & Parameters

changeFormat
ParamTypeDefault / RangeNotes
formatstringSee Formats above.
videoCodecstringUse copy to stream-copy video.
audioCodecstringUse copy to stream-copy audio.
crfnumber0..51Lower = higher quality (x264/x265).
presetstringmediumSee Presets above.
trim
ParamTypeDefault / RangeNotes
startnumber≥ 0With duration or with end.
durationnumber> 0Mutually exclusive with end.
endnumber> startMutually exclusive with duration.
scale
ParamTypeDefault / RangeNotes
widthnumber?> 0If only one of width/height is set → keepAspect forced true.
heightnumber?> 0If both are set → keepAspect forced false (exact reshape).
keepAspectboolean?autoOverridden by rules above.
rotateFlip
ParamTypeDefaultNotes
rotate“90” | “180” | “270”Clockwise.
hflipbooleanfalseHorizontal flip.
vflipbooleanfalseVertical flip.
removeAudio

Removes all audio streams from the output (no parameters).

speed
ParamTypeDefault / RangeNotes
videoSpeednumber?> 0e.g. 0.5, 1.25, 2.
audioSpeednumber?> 0If omitted, backend may auto-sync A/V as needed.
crop
ParamTypeDefault / RangeNotes
xnumber≥ 0Left origin (px).
ynumber≥ 0Top origin (px).
widthnumber> 0Pixels.
heightnumber> 0Pixels.
muteSegment
ParamTypeDefault / RangeNotes
startnumber≥ 0Seconds.
durationnumber> 0Seconds.
fade (visual)
ParamTypeDefault / RangeNotes
type“in” | “out”Visual fade.
startTimenumber≥ 0Seconds.
durationnumber> 0Seconds.
addText (visual)
ParamTypeDefault / RangeNotes
textstringOverlay string.
x / ynumberpxPosition.
fontSizenumber?24Pixels.
fontColorstring?whiteAny valid color string.
fontFilestring?Absolute path to .ttf on server.
startTimenumber?≥ 0Optional show window start (s).
endTimenumber?> startOptional show window end (s).
addBorder
ParamTypeDefault / RangeNotes
colorstring?blackBorder color.
top/bottomnumber?≥ 0Thickness px.
left/rightnumber?≥ 0Thickness px.
reverse
ParamTypeDefaultNotes
videoboolean?trueReverse video track.
audioboolean?falseReverse audio track.
audioFade
ParamTypeDefault / RangeNotes
type“in” | “out”Audio fade.
startTimenumber≥ 0Seconds.
durationnumber> 0Seconds.
motionBlur
ParamTypeDefault / RangeNotes
framesnumber?5, 2..64Frames to blend.
weightsstring?e.g. "1 2 3 2 1".
outputFpsnumber?≤ 240Override output FPS.
grayscale

Desaturates frames (no parameters).

colorEQ
ParamTypeDefault / RangeNotes
brightnessnumber?0, −1..1
contrastnumber?1, 0..10
saturationnumber?1, 0..10
gammanumber?1, 0.1..10
hueRotate
ParamTypeDefault / RangeNotes
degreesnumber−360..360Hue rotation.
saturationnumber?1Optional gain.
boxBlur
ParamTypeDefault / RangeNotes
lumaRadiusstring?e.g. "2", "4:2".
lumaPowernumber?1..16Strength.
startTimenumber?≥ 0Optional start (s).
endTimenumber?> startOptional end (s).
sharpen
ParamTypeDefault / RangeNotes
amountnumber?1, 0..5Sharpen amount.
sizenumber?5, odd 3..11Kernel size.
volume
ParamTypeDefault / RangeNotes
gainnumber1, 0..10Linear gain factor

Tips & Gotchas

  • Sync vs Async — Use save({ mode: 'sync' }) only for short jobs. Long encodes should be async with status polling.
  • Scale rules — One dimension → aspect kept; both → forced reshape. The SDK auto-sets keepAspect.
  • Copy codecsvideoCodec: 'copy' / audioCodec: 'copy' only when the output container supports the input streams.
  • CRF — Lower CRF → higher quality (and larger files). Typical range 18–28 for H.264/H.265.