1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-21 18:02:35 +01:00
lossless-cut/api.md
Mikael Finstad 533074ddae
allow passing arguments to api actions
also rename shortcuts to actions in api (breaking)

closes #2087
2024-08-05 01:22:34 +02:00

1.3 KiB

HTTP API

LosslessCut can be controlled via a HTTP API, if it is being run with the command line option --http-api. See also CLI. Note that the HTTP API is experimental and may change at any time.

Programmatically opening a file

This must be done with the CLI.

Enabling the API

LosslessCut --http-api

API endpoints

POST /api/action/:action

Execute a keyboard shortcut action, similar to the --keyboard-action CLI option. This is different from the CLI in that most of the actions will wait for the action to finish before responding to the HTTP request (but not all).

Available keyboard actions

Example

Export the currently opened file:

curl -X POST http://localhost:8080/api/action/export

Seek to time:

curl -X POST http://localhost:8080/api/action/goToTimecodeDirect --json '{"time": "09:11"}'

Batch example

Start the main LosslessCut in one terminal with the HTTP API enabled:

LosslessCut --http-api

Then run the script in a different terminal:

for PROJECT in /path/to/folder/with/projects/*.llc
    LosslessCut $PROJECT
    sleep 5 # wait for the file to open
    curl -X POST http://localhost:8080/api/action/export
    curl -X POST http://localhost:8080/api/action/closeCurrentFile
done