LosslessCut can be controlled via a HTTP API, if it is being run with the command line option --http-api. Note that the HTTP API is experimental and may change at any time.
See also CLI.
To enable the API, run LosslessCut from the command line with this flag:
LosslessCut --http-apiExecute a keyboard shortcut action, similar to the --keyboard-action CLI option. This is different from the CLI in that most of the actions (but not all) will wait for the action to finish before responding to the HTTP request.
See Available keyboard actions.
Export the currently opened file:
curl -X POST http://localhost:8080/api/action/exportSeek to time:
curl -X POST http://localhost:8080/api/action/goToTimecodeDirect --json '{"time": "09:11"}'Open one or more files:
curl -X POST http://localhost:8080/api/action/openFiles --json '["/path/to/file.mp4"]'Start the main LosslessCut in one terminal with the HTTP API enabled:
LosslessCut --http-apiThen 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
doneThis special endpoint allows you to wait for a certain event to occur in the app. The endpoint will hang and respond/return only when the event fires. Below are supported events.
Emitted when the export operation starts. The endpoint will return JSON { path: string }.
Emitted when the export operation completes (either success or failure). If successful, the endpoint will return JSON { paths: string[] }.
Run a command after each file that has completed exporting:
while true; do
echo 'Do something with exported file path:' $(curl -s -X POST http://localhost:8080/api/await-event/export-complete | jq -r '.paths[0]')
done