marzeq/vedit
clone
Language reference
vedit programmes are postfix: literals and sources push values, while operations consume values
from the top of the stack and push results. Signatures below show the stack from left to right,
with the rightmost value at the top. For example, VIDEO DURATION -> VIDEO means that the duration
is popped first, followed by the video.
Comments begin with # outside a quoted path. Each source, literal, or operation occupies one line.
Value types
| Type | Meaning |
|---|---|
VIDEO |
A video stream that can be edited independently. |
AUDIO |
An audio stream that can be edited independently. |
COMBINED |
Ordered media tracks and attachments, plus chapters and container tags. |
SUBTITLES |
A text, ASS/SSA, or bitmap subtitle track; its concrete kind is probed. |
BURN_STYLE |
Validated appearance settings used when rendering subtitles into video. |
INDEX |
A non-negative integer used to address tracks in a combined value. |
DURATION |
A non-negative time value in seconds internally. |
SCALAR |
A finite floating-point number used for volume and speed. |
BOOL |
A compile-time Boolean used by logic and structured control flow. |
STRING |
A quoted metadata key, value, title, or language. |
CHAPTER |
A chapter interval and title waiting to be added. |
ATTACHMENT |
An external attachment waiting to be added. |
Sources and literals
| Form | Signature | Description |
|---|---|---|
video "path" |
() -> VIDEO |
Push the first video stream from an input. |
audio "path" |
() -> AUDIO |
Push the first audio stream from an input. |
combined "path" |
() -> COMBINED |
Push every video, audio, and subtitle stream from one input. |
subtitles "path" |
() -> SUBTITLES |
Push a subtitle input. |
duration 5s |
() -> DURATION |
Push seconds. Decimals are accepted. |
duration 250ms |
() -> DURATION |
Push milliseconds. |
duration 01:23.500 |
() -> DURATION |
Push a minutes:seconds duration. |
scalar 0.7 |
() -> SCALAR |
Push a finite floating-point value. |
index 0 |
() -> INDEX |
Push a zero-based track index. |
burn-style "size=42; color=#FFFFFF" |
() -> BURN_STYLE |
Push validated burn settings. |
string "Japanese" |
() -> STRING |
Push a metadata string. |
attachment "font.ttf" |
() -> ATTACHMENT |
Push an external attachment; common font and image MIME types are inferred. |
true |
() -> BOOL |
Push true. |
false |
() -> BOOL |
Push false. |
Paths must be quoted and may contain spaces or # characters.
Quoted strings support positional interpolation: video "$1" substitutes the first script
argument, while video "clips/$2.mp4" inserts the second argument into a larger string. $0 and
references to missing arguments are rejected. Source paths must remain quoted.
Stack operations
| Operation | Signature | Effect |
|---|---|---|
dup |
A -> A A |
Duplicate the top value. |
drop |
A -> () |
Discard the top value. |
swap |
A B -> B A |
Exchange the top two values. |
over |
A B -> A B A |
Copy the second value to the top. |
rot |
A B C -> B C A |
Rotate the third value to the top. |
A, B, and C may be values of any type. Duplicated media is automatically routed through an
FFmpeg split or asplit only when multiple reachable consumers require it.
Combined media
| Operation | Signature | Description |
|---|---|---|
get-video |
COMBINED -> VIDEO |
Extract the first video track. |
get-audio |
COMBINED -> AUDIO |
Extract the first audio track. |
get-subtitles |
COMBINED -> SUBTITLES |
Extract the first subtitle track. |
split |
COMBINED -> VIDEO AUDIO |
Extract the first video and audio tracks, with audio on top. |
mux |
VIDEO AUDIO -> COMBINED |
Combine independently edited video and audio. Ordering is strict. |
attach-subtitles |
COMBINED SUBTITLES -> COMBINED |
Append subtitles; alias of add-subtitles. |
video-to-combined |
VIDEO -> COMBINED |
Wrap a video with empty audio and subtitle collections. |
The compatibility extractors select track zero and discard the remaining combined value. Indexed operations preserve or modify the collection:
| Operation | Signature | Description |
|---|---|---|
video-at |
COMBINED INDEX -> COMBINED VIDEO |
Copy an indexed video track. |
audio-at |
COMBINED INDEX -> COMBINED AUDIO |
Copy an indexed audio track. |
subtitles-at |
COMBINED INDEX -> COMBINED SUBTITLES |
Copy an indexed subtitle track. |
take-video |
COMBINED INDEX -> COMBINED VIDEO |
Remove and return an indexed video track. |
take-audio |
COMBINED INDEX -> COMBINED AUDIO |
Remove and return an indexed audio track. |
take-subtitles |
COMBINED INDEX -> COMBINED SUBTITLES |
Remove and return an indexed subtitle track. |
drop-video |
COMBINED INDEX -> COMBINED |
Remove an indexed video track. |
drop-audio |
COMBINED INDEX -> COMBINED |
Remove an indexed audio track. |
drop-subtitles |
COMBINED INDEX -> COMBINED |
Remove an indexed subtitle track. |
add-video |
COMBINED VIDEO -> COMBINED |
Append a video track. |
add-audio |
COMBINED AUDIO -> COMBINED |
Append an audio track. |
add-subtitles |
COMBINED SUBTITLES -> COMBINED |
Append a subtitle track. |
replace-video |
COMBINED INDEX VIDEO -> COMBINED |
Replace an indexed video track. |
replace-audio |
COMBINED INDEX AUDIO -> COMBINED |
Replace an indexed audio track. |
replace-subtitles |
COMBINED INDEX SUBTITLES -> COMBINED |
Replace an indexed subtitle track. |
move-video |
COMBINED FROM TO -> COMBINED |
Reposition a video track. |
move-audio |
COMBINED FROM TO -> COMBINED |
Reposition an audio track. |
move-subtitles |
COMBINED FROM TO -> COMBINED |
Reposition a subtitle track. |
Indexes are zero-based. Invalid indexes fail during compilation. Per-type collection order determines the final mapping order and therefore each type's default track.
combined also retains chapters, arbitrary container tags, and every attachment from the source.
video-to-combined carries that source-side data with the video. mux uses the video's global
metadata and chapters and unions attachments from both operands.
Metadata, chapters, and attachments
| Operation | Signature | Description |
|---|---|---|
set-language |
TRACK STRING -> TRACK |
Set a video, audio, or subtitle language tag. |
set-title |
TRACK STRING -> TRACK |
Set a video, audio, or subtitle title. |
set-default |
TRACK BOOL -> TRACK |
Set or clear its default disposition. |
set-forced |
TRACK BOOL -> TRACK |
Set or clear its forced disposition. |
chapter |
START END STRING -> CHAPTER |
Construct a chapter; END must be after START. |
add-chapter |
COMBINED CHAPTER -> COMBINED |
Append a chapter. |
drop-chapter |
COMBINED INDEX -> COMBINED |
Remove a chapter. |
move-chapter |
COMBINED FROM TO -> COMBINED |
Reorder chapters. |
add-attachment |
COMBINED ATTACHMENT -> COMBINED |
Append an external attachment. |
drop-attachment |
COMBINED INDEX -> COMBINED |
Remove an attachment. |
move-attachment |
COMBINED FROM TO -> COMBINED |
Reorder attachments. |
set-tag |
COMBINED KEY VALUE -> COMBINED |
Set or replace a global container tag. |
Track metadata follows its track through indexed and timeline operations. Existing disposition flags such as hearing-impaired, visual-impaired, commentary, and original are preserved. Timeline operations clip, rebase, shift, or scale chapters with the media. Concatenation keeps the left container tags, appends right chapters at the left duration, and unions attachments. Attachments currently require Matroska output.
Time and stream editing
Timeline operations accept bare tracks and combined values. On a combined value they transform every video, audio, and subtitle track together.
| Operation | Signature | Description |
|---|---|---|
length |
VIDEO -> DURATION |
Push the known video duration. |
AUDIO -> DURATION |
Push the known audio duration. | |
COMBINED -> DURATION |
Push the longest known contained-track duration. | |
SUBTITLES -> DURATION |
Push the known subtitle duration. | |
slice |
VIDEO START LENGTH -> VIDEO |
Keep LENGTH beginning at START and reset timestamps. |
AUDIO START LENGTH -> AUDIO |
Audio form of slice. |
|
SUBTITLES START LENGTH -> SUBTITLES |
Subtitle form of slice. |
|
COMBINED START LENGTH -> COMBINED |
Slice every contained track. | |
take |
VIDEO LENGTH -> VIDEO |
Keep at most the first LENGTH. |
AUDIO LENGTH -> AUDIO |
Audio form of take. |
|
SUBTITLES LENGTH -> SUBTITLES |
Subtitle form of take. |
|
COMBINED LENGTH -> COMBINED |
Take from every contained track. | |
concat |
VIDEO VIDEO -> VIDEO |
Append the second video to the first. |
AUDIO AUDIO -> AUDIO |
Append the second audio to the first. Mixed types are rejected. | |
SUBTITLES SUBTITLES -> SUBTITLES |
Append subtitle timelines. | |
COMBINED COMBINED -> COMBINED |
Concatenate corresponding tracks by type and index. | |
delay |
VIDEO DURATION -> VIDEO |
Shift video timestamps later. |
AUDIO DURATION -> AUDIO |
Insert an audio delay. | |
SUBTITLES DURATION -> SUBTITLES |
Shift subtitle timestamps later. | |
COMBINED DURATION -> COMBINED |
Delay every contained track. |
length fails at compilation if no duration can be determined. Source durations come from ffprobe;
edited durations are propagated without creating temporary media.
Combined concatenation requires equal video, audio, and subtitle counts on both operands. Subtitle
codecs are handled internally as plain text, ASS/SSA, or bitmap (PGS, DVD/VobSub, DVB, XSUB).
Untouched compatible streams are mapped with stream copy. Edited text stays text, edited ASS/SSA
stays ASS, and edited bitmap subtitles use Matroska intermediates with stream copy. Subtitle concat
requires matching codecs. ASS cue ends are clipped exactly after slice and take; bitmap timing is
packet-based. ASS/SSA and bitmap subtitles require Matroska output (standalone ASS is also accepted)
rather than being silently converted to a lossy or incompatible representation.
Subtitle burning
| Operation | Signature | Description |
|---|---|---|
burn-subtitles |
VIDEO SUBTITLES -> VIDEO |
Burn text subtitles using renderer defaults. |
VIDEO SUBTITLES BURN_STYLE -> VIDEO |
Burn text subtitles using explicit appearance settings. |
Burning accepts VIDEO, not COMBINED; extract or take a video track first. Plain text and ASS/SSA
are supported. Bitmap subtitle codecs such as PGS, DVD, DVB, and XSUB are rejected. Font attachments
found beside the subtitle stream are extracted into a temporary libass font directory. A
burn-style is a semicolon-separated list containing:
| Property | Values |
|---|---|
font |
A font-family name. |
size |
A positive font size. |
color |
#RGB, #RRGGBB, or #RRGGBBAA. |
outline-color |
A color in the same formats. |
outline-width |
A non-negative width. |
shadow |
A non-negative shadow depth. |
align |
top-left, top-center, top-right, center-left, center, center-right, bottom-left, bottom-center, or bottom-right. |
margin |
A non-negative vertical margin. |
Unknown properties and malformed values fail during compilation. Styles are translated to validated libass overrides; raw ASS syntax is not accepted. On ASS/SSA, inline override tags remain part of the subtitle events.
Audio operations
| Operation | Signature | Description |
|---|---|---|
volume |
AUDIO SCALAR -> AUDIO |
Multiply audio volume by the scalar. |
mix |
AUDIO AUDIO -> AUDIO |
Mix two streams; the result lasts as long as the longer input. |
silence |
DURATION -> AUDIO |
Generate stereo 48 kHz silence of the requested duration. |
Speed and fades
| Operation | Signature | Description |
|---|---|---|
speed |
VIDEO SCALAR -> VIDEO |
Change video speed using timestamps. |
AUDIO SCALAR -> AUDIO |
Change audio speed using one or more atempo stages. |
|
SUBTITLES SCALAR -> SUBTITLES |
Scale subtitle timestamps. | |
COMBINED SCALAR -> COMBINED |
Change every contained track's speed. | |
fade-in |
VIDEO DURATION -> VIDEO |
Fade video in from the start. |
AUDIO DURATION -> AUDIO |
Fade audio in from the start. | |
fade-out |
VIDEO DURATION -> VIDEO |
Fade video out over the final duration. |
AUDIO DURATION -> AUDIO |
Fade audio out over the final duration. |
Speed must be greater than zero. Fades preserve stream duration. fade-out requires a known input
duration so its start time can be calculated.
Arithmetic and comparisons
| Operation | Signature | Description |
|---|---|---|
add |
SCALAR SCALAR -> SCALAR |
Add scalars. |
DURATION DURATION -> DURATION |
Add durations. | |
sub |
SCALAR SCALAR -> SCALAR |
Subtract the right scalar from the left. |
DURATION DURATION -> DURATION |
Subtract durations; a negative result is rejected. | |
mul |
SCALAR SCALAR -> SCALAR |
Multiply scalars. |
DURATION SCALAR -> DURATION |
Scale a duration. | |
div |
SCALAR SCALAR -> SCALAR |
Divide scalars. |
DURATION SCALAR -> DURATION |
Divide a duration by a scalar. | |
eq, ne |
T T -> BOOL |
Test equality or inequality for matching SCALAR, DURATION, or BOOL values. |
lt, le, gt, ge |
T T -> BOOL |
Compare matching SCALAR or DURATION values. |
and, or |
BOOL BOOL -> BOOL |
Boolean conjunction or disjunction. |
not |
BOOL -> BOOL |
Boolean negation. |
T must be the same type on both sides. Media values are not comparable. Division by zero,
non-finite arithmetic, and negative duration results are rejected.
Conditionals
Conditionals use structured if, optional else, and end markers:
video "$1"
dup
length
duration 10s
gt
if
duration 10s
take
else
# The original video remains unchanged.
end
if consumes a BOOL. Both branches begin with the same remaining stack and must leave identical
stack types. Both branches are typechecked, but only the selected branch is compiled, probed, and
added to the FFmpeg graph. Omitting else is equivalent to an empty false branch, so the true branch
must preserve the stack shape in that case.
Conceptually, if both branches transform S into T:
S BOOL if ... else ... end -> T
Unrollable loops
Loops use Forth-style begin, while, and repeat markers:
video "$1"
scalar 0
begin
dup
scalar 3
lt
while
swap
duration 1s
take
swap
scalar 1
add
repeat
drop
At begin, let the current stack shape be S. The condition section must transform S into
S BOOL. while consumes that Boolean. The body must transform S back into exactly S before
repeat. When the condition becomes false, the loop leaves S on the stack.
Loops execute during compilation and are fully unrolled into the FFmpeg graph. Consequently, every condition must be computable from literals, arithmetic, Boolean operations, and known probed media durations. There is no frame-time or sample-time control flow. A loop that attempts more than 10,000 iterations is rejected.
Programme result
A valid programme must leave exactly one VIDEO, AUDIO, SUBTITLES, or COMBINED value on the
stack. Helper values such as BURN_STYLE, STRING, CHAPTER, ATTACHMENT, DURATION, INDEX,
SCALAR, and BOOL cannot be final results. A combined result maps every
track in per-type collection order.
Final FFmpeg encoding arguments
By default, final video and audio streams use -c:v libx264 -c:a aac.
| Instruction | Effect |
|---|---|
encoding "-c:v libx265 -crf 18 -c:a libopus" |
Replace the complete default video/audio encoding argument vector. A later encoding overwrites the earlier one. |
ffmpeg-args "-movflags +faststart" |
Append final FFmpeg output arguments. Repeated calls accumulate in programme order. |
The strings are split on whitespace without shell evaluation. Single-quoted groups inside the
outer double-quoted language literal form one argument, for example
ffmpeg-args "-metadata comment='processed episode'". Empty encoding "" suppresses the default
video/audio codec arguments entirely. Appended arguments are placed immediately before the output
path, so advanced users may deliberately override earlier FFmpeg options. Both instructions are
compile-time configuration and do not consume or produce stack values. Their results appear in
-n output. Subtitle codec selection, mapping, metadata, chapters, and attachments remain
compiler-managed unless appended arguments explicitly supersede an FFmpeg option.