---
title: "Execute Commands"
description: "Execute custom ffmpeg, imagemagick, and graphicsmagick commands."
canonical_url: "https://cloudconvert.com/docs/operations/execute-commands"
---
# Execute Commands

> Execute custom ffmpeg, imagemagick, and graphicsmagick commands.

To execute a custom command, [create a job](https://cloudconvert.com/docs/raw/api-reference/jobs.md#create-job) with a `command` task.

Currently, `ffmpeg`, `imagemagick`, and `graphicsmagick` commands are supported.

Files from input tasks are available in `/input/{taskName}/`. For example, files from a task named `import-1` are available in `/input/import-1/`.

The arguments are separated by spaces. Put paths which contain spaces in double quotes, for example `-i "/input/import-1/my video.mp4"`.

All files written to `/output/` are available to following tasks such as export tasks.

## Task Parameters

### command task parameters

- `operation` _string_ required: Value is `command`.
- `input` _string or array of task names_: The input task name(s) for this task.
- `engine` _string_ required: The engine to use for the command.
- `engine_version` _string_: Use a specific engine version for the conversion.
- `capture_output` _boolean_: Capture the console output of the command and return it in the results object.
- `timeout` _integer_: Timeout in seconds after the task will be cancelled. By default, tasks time out after 5 hours.

Additional operation-specific parameters can be available depending on the input format and output format. Use the [operations API](https://cloudconvert.com/docs/raw/api-reference/operations.md#list-operations) to identify these dynamic parameters, for example by filtering for `command` and including `options`: `GET https://api.cloudconvert.com/v2/operations?filter[operation]=command&include=options`.

### Example job

Raw request:

```json
{
    "tasks": {
        "import-my-file": {
            "operation": "import/url",
            "url": "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4",
            "filename": "input.mp4"
        },
        "execute-command": {
            "operation": "command",
            "input": "import-my-file",
            "engine": "ffmpeg",
            "command": "ffmpeg",
            "arguments": "-i /input/import-my-file/input.mp4 -vcodec libx264 -acodec copy /output/output.mp4"
        },
        "export-my-file": {
            "operation": "export/url",
            "input": "execute-command"
        }
    }
}
```

CLI:

```bash
# Install the CloudConvert CLI: npm install -g cloudconvert-cli
$ cloudconvert command \
    --engine=ffmpeg \
    --command=ffmpeg \
    --arguments='-i /input/import-my-file/input.mp4 -vcodec libx264 -acodec copy /output/output.mp4' \
    input.mp4
```

cURL:

```bash
$ curl -X POST "https://api.cloudconvert.com/v2/jobs" \
    -H "Authorization: Bearer API_KEY" \
    -H "Content-type: application/json" \
    -d '{
    "tasks": {
        "import-my-file": {
            "operation": "import/url",
            "url": "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4",
            "filename": "input.mp4"
        },
        "execute-command": {
            "operation": "command",
            "input": "import-my-file",
            "engine": "ffmpeg",
            "command": "ffmpeg",
            "arguments": "-i /input/import-my-file/input.mp4 -vcodec libx264 -acodec copy /output/output.mp4"
        },
        "export-my-file": {
            "operation": "export/url",
            "input": "execute-command"
        }
    }
}' 
```

PHP:

```php
use \CloudConvert\CloudConvert;
use \CloudConvert\Models\Job;
use \CloudConvert\Models\Task;

$cloudconvert = new CloudConvert(['api_key' => 'API_KEY']);

$job = (new Job())
   ->addTask(
       (new Task('import/url', 'import-my-file'))
         ->set('url', 'https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4')
         ->set('filename', 'input.mp4')
     )
   ->addTask(
       (new Task('command', 'execute-command'))
         ->set('input', 'import-my-file')
         ->set('engine', 'ffmpeg')
         ->set('command', 'ffmpeg')
         ->set('arguments', '-i /input/import-my-file/input.mp4 -vcodec libx264 -acodec copy /output/output.mp4')
     )
   ->addTask(
       (new Task('export/url', 'export-my-file'))
         ->set('input', 'execute-command')
     ); 

$cloudconvert->jobs()->create($job);
```

Node.js:

```js
import CloudConvert from 'cloudconvert';

const cloudConvert = new CloudConvert('api_key');

let job = await cloudConvert.jobs.create({
    "tasks": {
        "import-my-file": {
            "operation": "import/url",
            "url": "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4",
            "filename": "input.mp4"
        },
        "execute-command": {
            "operation": "command",
            "input": "import-my-file",
            "engine": "ffmpeg",
            "command": "ffmpeg",
            "arguments": "-i /input/import-my-file/input.mp4 -vcodec libx264 -acodec copy /output/output.mp4"
        },
        "export-my-file": {
            "operation": "export/url",
            "input": "execute-command"
        }
    }
});
```

Python:

```python
import cloudconvert

cloudconvert.configure(api_key='API_KEY')

cloudconvert.Job.create(payload={
    'tasks': {
        'import-my-file': {
            'operation': 'import/url',
            'url': 'https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4',
            'filename': 'input.mp4'
        },
        'execute-command': {
            'operation': 'command',
            'input': 'import-my-file',
            'engine': 'ffmpeg',
            'command': 'ffmpeg',
            'arguments': '-i /input/import-my-file/input.mp4 -vcodec libx264 -acodec copy /output/output.mp4'
        },
        'export-my-file': {
            'operation': 'export/url',
            'input': 'execute-command'
        }
    }
})
```

<tip to="https://cloudconvert.com/job-builder?operation=command">

Use the **Job Builder** to generate and try out command jobs.

</tip>

#### Example Response

You can find an example result of a executed command with `capture_output` set to `true` below:

<code-collapse name="Example Response">

```json
{
    "data": {
        "id": "32920a36-ccb1-4623-ab76-4d6287a38238",
        "tag": "jobbuilder",
        "status": "finished",
        "created_at": "2026-03-17T09:26:08+00:00",
        "started_at": "2026-03-17T09:26:08+00:00",
        "ended_at": "2026-03-17T09:26:20+00:00",
        "tasks": [
            {
                "id": "f70e5848-edcf-4233-a546-eaf6595f4440",
                "name": "task-1",
                "job_id": "32920a36-ccb1-4623-ab76-4d6287a38238",
                "status": "finished",
                "credits": 1,
                "code": null,
                "message": null,
                "percent": 100,
                "operation": "command",
                "engine": "ffmpeg",
                "engine_version": "6.1.4",
                "result": {
                    "command": "ffmpeg -stats_period 10 -i \/input\/import-my-file\/input.mp4 -vcodec libx264 -acodec copy \/output\/output.mp4",
                    "output": "ffmpeg version 6.1.4 Copyright (c) 2000-2025 the FFmpeg developers\r\n  built with gcc 12 (Debian 12.2.0-14+deb12u1)\r\n  configuration: --disable-decoder=amrnb --disable-gnutls --disable-liblensfun --disable-libopencv --disable-podpages --disable-sndio --disable-stripping --enable-avfilter --enable-chromaprint --enable-frei0r --enable-gcrypt --enable-gpl --enable-ladspa --enable-libaom --enable-libaribb24 --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdavs2 --enable-libdc1394 --enable-libdrm --enable-libfdk-aac --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libilbc --enable-libjack --enable-libjxl --enable-libkvazaar --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librabbitmq --enable-librist --enable-librsvg --enable-librubberband --enable-libshine --enable-libsmbclient --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-nonfree --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-openssl --enable-postproc --enable-pthreads --enable-shared --enable-version3 --incdir=\/usr\/include\/x86_64-linux-gnu --libdir=\/usr\/lib\/x86_64-linux-gnu --prefix=\/usr --toolchain=hardened --enable-vaapi --enable-libvpl --cc=x86_64-linux-gnu-gcc --cxx=x86_64-linux-gnu-g++ --disable-altivec --shlibdir=\/usr\/lib\/x86_64-linux-gnu\r\n  libavutil      58. 29.100 \/ 58. 29.100\r\n  libavcodec     60. 31.102 \/ 60. 31.102\r\n  libavformat    60. 16.100 \/ 60. 16.100\r\n  libavdevice    60.  3.100 \/ 60.  3.100\r\n  libavfilter     9. 12.100 \/  9. 12.100\r\n  libswscale      7.  5.100 \/  7.  5.100\r\n  libswresample   4. 12.100 \/  4. 12.100\r\n  libpostproc    57.  3.100 \/ 57.  3.100\r\nffmpeg stats and -progress period set to 10.\r\nInput #0, mov,mp4,m4a,3gp,3g2,mj2, from '\/input\/import-my-file\/input.mp4':\r\n  Metadata:\r\n    major_brand     : isom\r\n    minor_version   : 512\r\n    compatible_brands: mp41\r\n    creation_time   : 1970-01-01T00:00:00.000000Z\r\n    title           : Big Buck Bunny\r\n    artist          : Blender Foundation\r\n    composer        : Blender Foundation\r\n    date            : 2008\r\n    encoder         : Lavf52.14.0\r\n  Duration: 00:09:56.46, start: 0.000000, bitrate: 867 kb\/s\r\n  Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 \/ 0x31637661), yuv420p(progressive), 320x180 [SAR 1:1 DAR 16:9], 702 kb\/s, 24 fps, 24 tbr, 24 tbn (default)\r\n    Metadata:\r\n      creation_time   : 1970-01-01T00:00:00.000000Z\r\n      handler_name    : VideoHandler\r\n      vendor_id       : [0][0][0][0]\r\n  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a \/ 0x6134706D), 48000 Hz, stereo, fltp, 159 kb\/s (default)\r\n    Metadata:\r\n      creation_time   : 1970-01-01T00:00:00.000000Z\r\n      handler_name    : SoundHandler\r\n      vendor_id       : [0][0][0][0]\r\nStream mapping:\r\n  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))\r\n  Stream #0:1 -> #0:1 (copy)\r\nPress [q] to stop, [?] for help\r\n\u001b[libx264 @ 0x558930d41280] \u001busing SAR=1\/1\r\n\u001b[libx264 @ 0x558930d41280] \u001busing cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512\r\n\u001b[libx264 @ 0x558930d41280] \u001bprofile High, level 1.2, 4:2:0, 8-bit\r\n\u001b[libx264 @ 0x558930d41280] \u001b264 - core 164 - H.264\/MPEG-4 AVC codec - Copyleft 2003-2023 - http:\/\/www.videolan.org\/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00\r\nOutput #0, mp4, to '\/output\/output.mp4':\r\n  Metadata:\r\n    major_brand     : isom\r\n    minor_version   : 512\r\n    compatible_brands: mp41\r\n    date            : 2008\r\n    title           : Big Buck Bunny\r\n    artist          : Blender Foundation\r\n    composer        : Blender Foundation\r\n    encoder         : Lavf60.16.100\r\n  Stream #0:0(und): Video: h264 (avc1 \/ 0x31637661), yuv420p(progressive), 320x180 [SAR 1:1 DAR 16:9], q=2-31, 24 fps, 12288 tbn (default)\r\n    Metadata:\r\n      creation_time   : 1970-01-01T00:00:00.000000Z\r\n      handler_name    : VideoHandler\r\n      vendor_id       : [0][0][0][0]\r\n      encoder         : Lavc60.31.102 libx264\r\n    Side data:\r\n      cpb: bitrate max\/min\/avg: 0\/0\/0 buffer size: 0 vbv_delay: N\/A\r\n  Stream #0:1(und): Audio: aac (LC) (mp4a \/ 0x6134706D), 48000 Hz, stereo, fltp, 159 kb\/s (default)\r\n    Metadata:\r\n      creation_time   : 1970-01-01T00:00:00.000000Z\r\n      handler_name    : SoundHandler\r\n      vendor_id       : [0][0][0][0]\r\nframe=    0 fps=0.0 q=0.0 size=       0kB time=00:00:00.61 bitrate=   0.6kbits\/s speed= 111x    \rframe=13554 fps=1355 q=28.0 size=   23808kB time=00:09:27.46 bitrate= 343.7kbits\/s speed=56.7x    \r\u001b[out#0\/mp4 @ 0x558930dd7040] \u001bvideo:13178kB audio:11645kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.519816%\r\nframe=14315 fps=1384 q=-1.0 Lsize=   25200kB time=00:09:56.33 bitrate= 346.2kbits\/s speed=57.7x    \r\n\u001b[libx264 @ 0x558930d41280] \u001bframe I:152   Avg QP:18.65  size: 11881\r\n\u001b[libx264 @ 0x558930d41280] \u001bframe P:7288  Avg QP:22.88  size:  1260\r\n\u001b[libx264 @ 0x558930d41280] \u001bframe B:6875  Avg QP:27.84  size:   364\r\n\u001b[libx264 @ 0x558930d41280] \u001bconsecutive B-frames: 30.8% 12.7%  8.8% 47.8%\r\n\u001b[libx264 @ 0x558930d41280] \u001bb I  I16..4: 32.0% 17.3% 50.7%\r\n\u001b[libx264 @ 0x558930d41280] \u001bb P  I16..4:  1.3%  1.9%  1.6%  P16..4: 32.6%  8.4%  6.5%  0.0%  0.0%    skip:47.6%\r\n\u001b[libx264 @ 0x558930d41280] \u001bb B  I16..4:  0.3%  0.6%  0.5%  B16..8: 24.8%  3.3%  1.2%  direct: 1.3%  skip:68.0%  L0:41.6% L1:47.3% BI:11.1%\r\n\u001b[libx264 @ 0x558930d41280] \u001b8x8 transform intra:34.6% inter:49.7%\r\n\u001b[libx264 @ 0x558930d41280] \u001bcoded y,uvDC,uvAC intra: 61.2% 75.5% 47.0% inter: 13.1% 14.2% 3.2%\r\n\u001b[libx264 @ 0x558930d41280] \u001bi16 v,h,dc,p: 26% 27% 21% 27%\r\n\u001b[libx264 @ 0x558930d41280] \u001bi8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 18% 23%  5%  5%  7%  6%  6%  7%\r\n\u001b[libx264 @ 0x558930d41280] \u001bi4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 16% 14%  4%  6%  6%  6%  5%  6%\r\n\u001b[libx264 @ 0x558930d41280] \u001bi8c dc,h,v,p: 50% 23% 18%  9%\r\n\u001b[libx264 @ 0x558930d41280] \u001bWeighted P-Frames: Y:2.2% UV:1.3%\r\n\u001b[libx264 @ 0x558930d41280] \u001bref P L0: 72.4% 13.7%  9.6%  4.2%  0.1%\r\n\u001b[libx264 @ 0x558930d41280] \u001bref B L0: 89.9%  8.0%  2.1%\r\n\u001b[libx264 @ 0x558930d41280] \u001bref B L1: 96.5%  3.5%\r\n\u001b[libx264 @ 0x558930d41280] \u001bkb\/s:180.98",
                    "files": [
                        {
                            "filename": "output.mp4",
                            "size": 25805127
                        }
                    ]
                },
                "created_at": "2026-03-17T09:26:08+00:00",
                "started_at": "2026-03-17T09:26:09+00:00",
                "ended_at": "2026-03-17T09:26:20+00:00",
                "retry_of_task_id": null,
                "copy_of_task_id": null,
                "region": "eu-central",
                "depends_on_task_ids": [
                    "66f4488e-1f69-4342-84fe-ad5c6a18dc3c"
                ],
                "links": {
                    "self": "https:\/\/api.cloudconvert.com\/v2\/tasks\/f70e5848-edcf-4233-a546-eaf6595f4440"
                }
            }
        ]
    }
}
```

</code-collapse>


## Sitemap

See the full [sitemap](https://cloudconvert.com/docs/sitemap.md) for all pages.
