> ## Documentation Index
> Fetch the complete documentation index at: https://rendi.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Chained FFmpeg Commands

> Submit multiple FFmpeg commands where following commands can depend on output of previous commands.         Running chained FFmpeg commands is faster than running each command separately because we re-use system         and network resources between the multiple ffmpeg commands. Processing quota is shared between the commands, and is more efficient than running each command separately.

<Note>
  Prefer chained commands over multiple separate `run-ffmpeg-command` calls for multi-step pipelines — one round-trip, lower latency, and outputs from earlier commands can feed later ones.
</Note>


## OpenAPI

````yaml POST /v1/run-chained-ffmpeg-commands
openapi: 3.1.0
info:
  title: FFmpeg Command API
  description: API for running FFmpeg in a cloud environment
  version: 1.0.0
servers:
  - url: https://api.rendi.dev
    description: Rendi - FFmpeg API
security: []
paths:
  /v1/run-chained-ffmpeg-commands:
    post:
      tags:
        - API
        - FFmpeg Commands
      summary: Run Chained FFmpeg Commands which share input and output files
      description: >-
        Submit multiple FFmpeg commands where following commands can depend on
        output of previous commands.         Running chained FFmpeg commands is
        faster than running each command separately because we re-use
        system         and network resources between the multiple ffmpeg
        commands. Processing quota is shared between the commands, and is more
        efficient than running each command separately.
      operationId: run_chained_ffmpeg_commands_v1_run_chained_ffmpeg_commands_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FFmpegChainedCommandsRequest'
        required: true
      responses:
        '200':
          description: Successfully submitted chained FFmpeg commands
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunCommandResponse'
              example:
                command_id: 123e4567-e89b-12d3-a456-426614174000
        '401':
          description: Invalid API key
          content:
            application/json:
              example:
                detail: Invalid authorization key
        '403':
          description: Account quota exceeded or plan does not support chained commands
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Rate limit exceeded
      security:
        - APIKeyHeader: []
components:
  schemas:
    FFmpegChainedCommandsRequest:
      properties:
        input_files:
          additionalProperties:
            type: string
          type: object
          title: Input Files
          description: |-
            Dictionary mapping file aliases to their publicly accessible paths, 
                    file name should appear in the end of the url, keys are alphanumeric, with underscore allowed, must start with 'in_'. 
                    You can use public file urls, google drive, dropbox, rendi stored files, s3 stored files, etc. as long as they are publicly accessible.
          examples:
            - in_1: >-
                https://storage.rendi.dev/sample/big_buck_bunny_720p_5sec_intro.mp4
              in_2: >-
                https://storage.rendi.dev/sample/big_buck_bunny_720p_5sec_outro.mp4
        output_files:
          additionalProperties:
            type: string
          type: object
          title: Output Files
          description: >-
            Dictionary mapping file aliases to their desired output file names,
            keys are alphanumeric, with underscore allowed, must start with
            'out_'
          examples:
            - out_1: output_one.mp4
              out_2: output_two.mp4
        max_command_run_seconds:
          type: number
          exclusiveMinimum: 0
          title: Max Command Run Seconds
          description: >-
            Maximum allowed runtime in seconds for a single FFmpeg command, the
            default is 300 seconds
          examples:
            - 300
        vcpu_count:
          type: integer
          exclusiveMinimum: 0
          title: Vcpu Count
          description: >-
            Number of virtual CPUs to use for a single ffmpeg command, the
            default is 8, up to your account's maximum. Multiple commands can
            run in parallel as long as their total vCPU usage doesn't exceed
            your quota.
          examples:
            - 8
        metadata:
          anyOf:
            - additionalProperties:
                anyOf:
                  - type: string
                  - type: integer
                  - type: number
                  - type: boolean
              type: object
              maxProperties: 10
              minProperties: 0
            - type: 'null'
          title: Metadata
          description: >-
            Metadata to be stored with the command, useful for webhooks and
            custom tracking and reporting
          examples:
            - key: value
        ffmpeg_commands:
          items:
            type: string
          type: array
          title: Ffmpeg Commands
          description: >-
            FFmpeg command strings using {{alias}} placeholders for input and
            output files. Each string is a separate ffmpeg command. Can contain
            up to 10 commands. The output files will be stored in storage for
            later access.

            Input files can be used in all specified commands. Output files from
            previous commands can be used as input files in later commands. If
            you wish to use an output file from a previous command as input file
            in a later command, make sure to use `-i` right before the output
            file alias.

            Input file keys should start with 'in_' prefix, for example:
            in_video1. Output file keys should start with 'out_' prefix, for
            example: out_1.

            If you're using an automation platform where curly brackets are used
            special as characters (like make.com, zapier, or other) add
            backslashes before the curly brackets, for example, replace {{in_1}}
            with backslashes and brackets \\{\\{in_1\\}\\}.
          examples:
            - - >-
                -i {{in_1}} -i {{in_2}} -filter_complex
                "[0:v][1:v]hstack=inputs=2[v]" -map "[v]" {{out_1}}
              - '-i {{out_1}} -ss 00:17 -vframes 1 {{out_2}}'
      type: object
      required:
        - input_files
        - output_files
        - ffmpeg_commands
      title: FFmpegChainedCommandsRequest
      description: >-
        Request model for submitting chained FFmpeg commands.


        This model allows submitting multiple FFmpeg commands that run
        sequentially. Input files can be shared between commands. Output files
        from earlier commands

        can be used as inputs to later commands.
      example:
        ffmpeg_commands:
          - >-
            -i {{in_1}} -i {{in_2}} -filter_complex
            "[0:v][1:v]hstack=inputs=2[v]" -map [v] {{out_1}}
          - '-i {{out_1}} -vframes 1 {{out_2}}'
        input_files:
          in_1: https://storage.rendi.dev/sample/big_buck_bunny_720p_5sec_intro.mp4
          in_2: https://storage.rendi.dev/sample/big_buck_bunny_720p_5sec_outro.mp4
        max_command_run_seconds: 300
        metadata:
          key: value
        output_files:
          out_1: output_concatenated.mp4
          out_2: thumbnail.jpg
        vcpu_count: 8
    RunCommandResponse:
      properties:
        command_id:
          type: string
          format: uuid
          title: Command Id
          description: Unique identifier for the submitted command
          examples:
            - 123e4567-e89b-12d3-a456-426614174000
      type: object
      required:
        - command_id
      title: RunCommandResponse
      description: >-
        Response model for command submission.


        Contains the unique identifier assigned to the submitted command that
        can be used

        to poll for status and retrieve results.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-KEY

````