# place.stream.media.finalizeLivestream

> Turn a finished livestream into a VOD. The server concatenates the MUXL segments it recorded for the livestream(s) into a single content blob, derives the playback sidecars, and publishes the place.stream.media.track records. By default it leaves a draft VOD the streamer publishes later via place.stream.vod.publishDraft; with publish set it publishes the place.stream.video record as soon as the VOD is finalized. The caller must be the streamer, or a moderator they have granted livestream.manage; every record is written with the streamer's session.

- Kind: procedure
- Authority: media.stream.place
- Lexicon: 1
- Published by [stream.place](https://lexicon.garden/identity/did:plc:rbvrr34edl5ddpuwcubjiost), not the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:rbvrr34edl5ddpuwcubjiost/place.stream.media.finalizeLivestream)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:rbvrr34edl5ddpuwcubjiost/place.stream.media.finalizeLivestream/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:rbvrr34edl5ddpuwcubjiost/place.stream.media.finalizeLivestream/analytics)

## Procedure (`place.stream.media.finalizeLivestream`)

Type: procedure · POST

### Input (application/json)

- `description` (string): Description of the video record.
  - Constraints: maxLength: 10000
- `endLivestream` (boolean): Also end any of the livestream records that were never stopped, so the streamer's page stops reading as live.
  - Constraints: default: false
- `livestream` (string · at-uri): AT-URI of the place.stream.livestream record to finalize into a VOD. Either this or livestreams is required.
- `livestreams` (array): Several livestream records whose recordings make up one VOD: a streamer who started a new record mid-stream splits the recording across them. Recordings are concatenated in the records' creation order, whatever order they are listed in. All must belong to one streamer.
  - `items` (string · at-uri)
- `publish` (boolean): Publish the place.stream.video record as soon as the VOD is finalized, instead of leaving a draft.
  - Constraints: default: false
- `title` (string): Title of the video record; the first livestream's title when empty.
  - Constraints: maxLength: 1000

### Output (application/json)

- `draftUri` (string): The ats:// URI of the draft VOD created for this finalize, when publish is not set. The draft reaches status 'ready' when processing completes.
- `ended` (array): Livestream records that are now ended (already, or by endLivestream).
  - `items` (string · at-uri)
- `livestreams` (array): The livestream records the VOD is made of, in recording order.
  - `items` (string · at-uri)
- `objects` (integer): How many recorded objects will be concatenated.
- `uploadId` (string, required): Identifier for the finalize job. Retained for backwards compatibility; the draft flow no longer requires the client to poll getUploadStatus.

### Errors

- `LivestreamNotFound`: No livestream with the given URI is known to this node, or the livestreams belong to different streamers.
- `NoRecording`: The livestream has no recorded MUXL segments to finalize (recording was not enabled, or none completed).
- `NotPermitted`: The caller is neither the streamer nor a moderator with livestream.manage from them.

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Turn a finished livestream into a VOD. The server concatenates the MUXL segments it recorded for the livestream(s) into a single content blob, derives the playback sidecars, and publishes the place.stream.media.track records. By default it leaves a draft VOD the streamer publishes later via place.stream.vod.publishDraft; with publish set it publishes the place.stream.video record as soon as the VOD is finalized. The caller must be the streamer, or a moderator they have granted livestream.manage; every record is written with the streamer's session.",
      "errors": [
        {
          "description": "No livestream with the given URI is known to this node, or the livestreams belong to different streamers.",
          "name": "LivestreamNotFound"
        },
        {
          "description": "The livestream has no recorded MUXL segments to finalize (recording was not enabled, or none completed).",
          "name": "NoRecording"
        },
        {
          "description": "The caller is neither the streamer nor a moderator with livestream.manage from them.",
          "name": "NotPermitted"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "description": {
              "description": "Description of the video record.",
              "maxLength": 10000,
              "type": "string"
            },
            "endLivestream": {
              "default": false,
              "description": "Also end any of the livestream records that were never stopped, so the streamer's page stops reading as live.",
              "type": "boolean"
            },
            "livestream": {
              "description": "AT-URI of the place.stream.livestream record to finalize into a VOD. Either this or livestreams is required.",
              "format": "at-uri",
              "type": "string"
            },
            "livestreams": {
              "description": "Several livestream records whose recordings make up one VOD: a streamer who started a new record mid-stream splits the recording across them. Recordings are concatenated in the records' creation order, whatever order they are listed in. All must belong to one streamer.",
              "items": {
                "format": "at-uri",
                "type": "string"
              },
              "type": "array"
            },
            "publish": {
              "default": false,
              "description": "Publish the place.stream.video record as soon as the VOD is finalized, instead of leaving a draft.",
              "type": "boolean"
            },
            "title": {
              "description": "Title of the video record; the first livestream's title when empty.",
              "maxLength": 1000,
              "type": "string"
            }
          },
          "required": [],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "draftUri": {
              "description": "The ats:// URI of the draft VOD created for this finalize, when publish is not set. The draft reaches status 'ready' when processing completes.",
              "type": "string"
            },
            "ended": {
              "description": "Livestream records that are now ended (already, or by endLivestream).",
              "items": {
                "format": "at-uri",
                "type": "string"
              },
              "type": "array"
            },
            "livestreams": {
              "description": "The livestream records the VOD is made of, in recording order.",
              "items": {
                "format": "at-uri",
                "type": "string"
              },
              "type": "array"
            },
            "objects": {
              "description": "How many recorded objects will be concatenated.",
              "type": "integer"
            },
            "uploadId": {
              "description": "Identifier for the finalize job. Retained for backwards compatibility; the draft flow no longer requires the client to poll getUploadStatus.",
              "type": "string"
            }
          },
          "required": [
            "uploadId"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "id": "place.stream.media.finalizeLivestream",
  "lexicon": 1
}
```
