Skip to content

Running commands ​

Right-click a file, or use the selection bar, and choose Run command to run a program on the selected files. Only the commands every selected file is a kind of are offered. Before anything runs, a confirmation shows where the new files will be written and what they will be called; Run starts them. While they run, a notice at the top right and the status bar show how many are left and how far a conversion with the bundled ffmpeg has got; the notice stays until they are all over, then says how they went. Click the status bar to stop one, show a new file in its folder, or read why one failed.

Meguri comes with conversions for editing software that does not read what phones and cameras record (DaVinci Resolve on Linux does not decode AAC audio): Convert audio to PCM (MOV), which keeps the video as it is, Convert to DNxHR HQ (MOV) and Convert to ProRes 422 (MOV). Each writes a new file next to the original. An existing file is never overwritten: the new one is called clip (1).mov and so on instead.

Convert audio to PCM (MOV) keeps the video as it is, which suits H.264 and H.265, what phones and cameras record. A video that is VP9 or AV1, as many downloaded from the web are, cannot go into a MOV unchanged, so that command fails on it; use Convert to DNxHR HQ (MOV) or Convert to ProRes 422 (MOV), which convert the video too.

Your own commands ​

Write your own commands in commands.json: Settings → Commands → Open file opens it (creating it first) in your editor, and Meguri reloads it whenever you save. The same page lists the commands it read and why it skipped any; a mistake in one command skips only that one. Copy to my commands adds a built-in command to the file, to change from there.

json
{
  "commands": [
    {
      "id": "gif",
      "name": "Make a GIF",
      "program": "{ffmpeg}",
      "args": ["-i", "{path}", "-vf", "fps=10,scale=480:-1", "{output:.gif}"],
      "outputDir": "converted",
      "run": "each",
      "kinds": ["video"]
    }
  ]
}
  • id: a name of your own for the command, used by no other (not starting with builtin.). name is what the menu shows.
  • program: the full path of the program, such as /usr/bin/magick or C:\Tools\tool.exe, or {ffmpeg} / {ffprobe} for the ones Meguri comes with. A bare name like magick is not looked up.
  • args: the arguments, one string each. No shell is involved, so a file name with spaces or quotes reaches the program as one argument, as it is. The program starts in the file's folder.
  • run: "each" runs the program once per file; "all" runs it once with every selected file.
  • kinds: which files it is offered for: "video", "image", "audio".
  • outputDir (optional): where {output:…} writes. A folder inside the file's own ("converted", "converted/small") is created when it is missing. A full path, or a relative one that goes up with .. ("../out"), must exist: on a drive that is not plugged in, the run is refused rather than writing onto your system disk. Without it, the new file goes next to the original.

In args, these stand for the file:

  • {path}: its full path. {dir}: its folder. {name}: its name (clip.mp4). {stem}: its name without the extension (clip). {ext}: the extension with its dot (.mp4). These need "run": "each".
  • {output:.mov}: the new file, with that extension. Meguri has the program write a hidden temporary file and gives it its name only once the program succeeds, so a failed or stopped run leaves nothing behind. One per command, with "run": "each".
  • {paths}: every selected file, one argument each, with "run": "all". It must be an argument of its own.
  • {{ and }}: a brace itself.

A name that starts with - can be taken for an option by the program. {path} is safe, as is {name} on its own (Meguri puts ./ before it); {stem}, or {name} inside a longer argument, is not. Where the program allows it, put -- before the file arguments.

On Windows, .bat and .cmd files cannot be started without a shell, so they are refused. Run a PowerShell script instead: "program": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" with "args": ["-File", "C:\\scripts\\tool.ps1", "{path}"].

Examples ​

Each one is a command to paste into the commands list (put a comma between two of them). Change its id if you add a second copy.

With the bundled ffmpeg ​

A still of the first frame, as PNG, into a stills folder next to each file.

json
{
  "id": "still-png",
  "name": "Save the first frame as PNG",
  "program": "{ffmpeg}",
  "args": ["-hide_banner", "-i", "{path}", "-frames:v", "1", "{output:.png}"],
  "outputDir": "stills",
  "run": "each",
  "kinds": ["video"]
}

The audio alone, as WAV, which every editor reads.

json
{
  "id": "audio-wav",
  "name": "Extract the audio as WAV",
  "program": "{ffmpeg}",
  "args": [
    "-hide_banner",
    "-i",
    "{path}",
    "-vn",
    "-c:a",
    "pcm_s16le",
    "{output:.wav}"
  ],
  "run": "each",
  "kinds": ["video", "audio"]
}

A smaller copy to send: 720p H.264 with AAC audio, into a shared folder.

json
{
  "id": "share-720p",
  "name": "Make a 720p copy to share",
  "program": "{ffmpeg}",
  "args": [
    "-hide_banner",
    "-i",
    "{path}",
    "-vf",
    "scale=-2:720",
    "-c:v",
    "libx264",
    "-preset",
    "veryfast",
    "-crf",
    "26",
    "-c:a",
    "aac",
    "-b:a",
    "128k",
    "{output:.mp4}"
  ],
  "outputDir": "shared",
  "run": "each",
  "kinds": ["video"]
}

A clip turned a quarter clockwise (transpose=2 turns it the other way); the audio is kept as it is.

json
{
  "id": "rotate-cw",
  "name": "Rotate 90° clockwise",
  "program": "{ffmpeg}",
  "args": [
    "-hide_banner",
    "-i",
    "{path}",
    "-vf",
    "transpose=1",
    "-c:v",
    "libx264",
    "-crf",
    "18",
    "-c:a",
    "copy",
    "{output:.mp4}"
  ],
  "run": "each",
  "kinds": ["video"]
}

A photo at most 1920 pixels wide, as JPEG, into one folder for all of them. A full path must exist: create the folder first.

json
{
  "id": "photo-1920",
  "name": "Resize to 1920 px wide (JPEG)",
  "program": "{ffmpeg}",
  "args": [
    "-hide_banner",
    "-i",
    "{path}",
    "-vf",
    "scale='min(1920,iw)':-2",
    "-q:v",
    "3",
    "{output:.jpg}"
  ],
  "outputDir": "/home/you/Pictures/Resized",
  "run": "each",
  "kinds": ["image"]
}

With other programs ​

Change the program's path to where it is on your computer.

HandBrakeCLI with one of its presets.

json
{
  "id": "handbrake-fast-1080p",
  "name": "HandBrake: Fast 1080p30",
  "program": "/usr/bin/HandBrakeCLI",
  "args": ["-i", "{path}", "-o", "{output:.mp4}", "--preset", "Fast 1080p30"],
  "outputDir": "converted",
  "run": "each",
  "kinds": ["video"]
}

ImageMagick, making a photo at most 1600 pixels on its longer side (the > leaves smaller ones as they are).

json
{
  "id": "magick-1600",
  "name": "ImageMagick: fit in 1600 px",
  "program": "/usr/bin/magick",
  "args": ["{path}", "-resize", "1600x1600>", "{output:.jpg}"],
  "run": "each",
  "kinds": ["image"]
}

A script of your own, given every selected file at once ("run": "all"): a file with #!/bin/sh on its first line and made executable runs as it is. It writes what it likes, so Meguri shows its path before it runs.

json
{
  "id": "my-script",
  "name": "Send to my script",
  "program": "/home/you/bin/collect",
  "args": ["{paths}"],
  "run": "all",
  "kinds": ["video", "image", "audio"]
}

On Windows, a PowerShell script for each file. -ExecutionPolicy Bypass lets a script of your own run without changing the policy for the whole computer.

json
{
  "id": "ps-script",
  "name": "Run my PowerShell script",
  "program": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
  "args": [
    "-NoProfile",
    "-ExecutionPolicy",
    "Bypass",
    "-File",
    "C:\\Users\\you\\scripts\\tool.ps1",
    "{path}"
  ],
  "run": "each",
  "kinds": ["video"]
}

A command of your own runs the program you name with your permissions, and that program can do whatever it does, including changing or deleting files. Only add commands you understand.