Skip to main content
GET
/
{transcodeType}
/
:
/
transcode
/
universal
/
start.
{extension}
PlexGO
package main

import(
	"context"
	"github.com/LukeHagar/plexgo/models/components"
	"github.com/LukeHagar/plexgo"
	"github.com/LukeHagar/plexgo/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := plexgo.New(
        plexgo.WithAccepts(components.AcceptsApplicationXML),
        plexgo.WithClientIdentifier("abc123"),
        plexgo.WithProduct("Plex for Roku"),
        plexgo.WithVersion("2.4.1"),
        plexgo.WithPlatform("Roku"),
        plexgo.WithPlatformVersion("4.3 build 1057"),
        plexgo.WithDevice("Roku 3"),
        plexgo.WithModel("4200X"),
        plexgo.WithDeviceVendor("Roku"),
        plexgo.WithDeviceName("Living Room TV"),
        plexgo.WithMarketplace("googlePlay"),
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
    )

    res, err := s.Transcoder.StartTranscodeSession(ctx, operations.StartTranscodeSessionRequest{
        TranscodeType: components.TranscodeTypeMusic,
        Extension: operations.ExtensionMpd,
        AdvancedSubtitles: components.AdvancedSubtitlesBurn.ToPointer(),
        AudioBoost: plexgo.Pointer[int64](50),
        AudioChannelCount: plexgo.Pointer[int64](5),
        AutoAdjustQuality: components.BoolIntOne.ToPointer(),
        AutoAdjustSubtitle: components.BoolIntOne.ToPointer(),
        DirectPlay: components.BoolIntOne.ToPointer(),
        DirectStream: components.BoolIntOne.ToPointer(),
        DirectStreamAudio: components.BoolIntOne.ToPointer(),
        DisableResolutionRotation: components.BoolIntOne.ToPointer(),
        HasMDE: components.BoolIntOne.ToPointer(),
        Location: operations.StartTranscodeSessionQueryParamLocationWan.ToPointer(),
        MediaBufferSize: plexgo.Pointer[int64](102400),
        MediaIndex: plexgo.Pointer[int64](0),
        MusicBitrate: plexgo.Pointer[int64](5000),
        Offset: plexgo.Pointer[float64](90.5),
        PartIndex: plexgo.Pointer[int64](0),
        Path: plexgo.Pointer("/library/metadata/151671"),
        PeakBitrate: plexgo.Pointer[int64](12000),
        PhotoResolution: plexgo.Pointer("1080x1080"),
        Protocol: operations.StartTranscodeSessionQueryParamProtocolDash.ToPointer(),
        SecondsPerSegment: plexgo.Pointer[int64](5),
        SubtitleSize: plexgo.Pointer[int64](50),
        VideoBitrate: plexgo.Pointer[int64](12000),
        VideoQuality: plexgo.Pointer[int64](50),
        VideoResolution: plexgo.Pointer("1080x1080"),
        XPlexClientProfileExtra: plexgo.Pointer("add-limitation(scope=videoCodec&scopeName=*&type=upperBound&name=video.frameRate&value=60&replace=true)+append-transcode-target-codec(type=videoProfile&context=streaming&videoCodec=h264%2Chevc&audioCodec=aac&protocol=dash)"),
        XPlexClientProfileName: plexgo.Pointer("generic"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.ResponseStream != nil {
        // handle response
    }
}
"#EXTM3U\n#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3538000,RESOLUTION=1280x720,FRAME-RATE=60.000000\nsession/32635662-0d05-4acd-8f72-512cc64396d4/base/index.m3u8\n"

Authorizations

X-Plex-Token
string
header
required

The token which identifies the user accessing the PMS. This can be either:

  • A traditional access token obtained from plex.tv
  • A JWT token obtained through the JWT authentication flow

JWT tokens provide better security with:

  • Short-lived tokens (7 days expiration)
  • Public-key cryptography (ED25519)
  • Better clock synchronization
  • Individual device revocation capability

Headers

accepts
enum<string>
default:application/xml

Indicates the client accepts the indicated media types

Available options:
application/json,
application/xml
X-Plex-Client-Identifier
string
required

Unique per client.

X-Plex-Product
string

The name of the client product

Example:

"Plex for Roku"

X-Plex-Version
string

The version of the client application

Example:

"2.4.1"

X-Plex-Platform
string

Client Platform

X-Plex-Platform-Version
string

Client Platform Version

X-Plex-Device
string

Device the client is running on

X-Plex-Model
string

Model of the device the client is running on

X-Plex-Device-Vendor
string

The device vendor

Example:

"Roku"

X-Plex-Device-Name
string

A friendly name for the client

Example:

"Living Room TV"

X-Plex-Marketplace
string

The marketplace on which the client application is distributed

Example:

"googlePlay"

X-Plex-Client-Profile-Extra
string
X-Plex-Client-Profile-Name
string

Which built in Client Profile to use in the decision. Generally should only be used to specify the Generic profile.

X-Plex-Session-Identifier
string

Unique per client playback session. Used if a client can playback multiple items at a time (such as a browser with multiple tabs)

Path Parameters

transcodeType
enum<string>
required

Type of transcode media

Available options:
video,
music,
audio,
subtitles
extension
enum<string>
required

Extension

Available options:
m3u8,
mpd

Query Parameters

transcodeSessionId
string

Transcode session UUID

advancedSubtitles
enum<string>

Indicates how incompatible advanced subtitles (such as ass/ssa) should be included: * 'burn' - Burn incompatible advanced text subtitles into the video stream * 'text' - Transcode incompatible advanced text subtitles to a compatible text format, even if some markup is lost

Available options:
burn,
text,
unknown
audioBoost
integer

Percentage of original audio loudness to use when transcoding (100 is equivalent to original volume, 50 is half, 200 is double, etc)

Required range: x >= 1
audioChannelCount
integer

Target video number of audio channels.

Required range: 1 <= x <= 8
autoAdjustQuality
enum<integer>

Indicates the client supports ABR.

Available options:
0,
1
autoAdjustSubtitle
enum<integer>

Indicates if the server should adjust subtitles based on Voice Activity Data.

Available options:
0,
1
directPlay
enum<integer>

Indicates the client supports direct playing the indicated content.

Available options:
0,
1
directStream
enum<integer>

Indicates the client supports direct streaming the video of the indicated content.

Available options:
0,
1
directStreamAudio
enum<integer>

Indicates the client supports direct streaming the audio of the indicated content.

Available options:
0,
1
disableResolutionRotation
enum<integer>

Indicates if resolution should be adjusted for orientation.

Available options:
0,
1
hasMDE
enum<integer>

Ignore client profiles when determining if direct play is possible. Only has an effect when directPlay=1 and both mediaIndex and partIndex are specified and neither are -1

Available options:
0,
1
location
enum<string>

Network type of the client, can be used to help determine target bitrate.

Available options:
lan,
wan,
cellular
mediaBufferSize
integer

Buffer size used in playback (in KB). Clients should specify a lower bound if not known exactly. This value could make the difference between transcoding and direct play on bandwidth constrained networks.

mediaIndex
integer

Index of the media to transcode. -1 or not specified indicates let the server choose.

musicBitrate
integer

Target bitrate for audio only files (in kbps, used to transcode).

Required range: x >= 0
offset
number

Offset from the start of the media (in seconds).

partIndex
integer

Index of the part to transcode. -1 or not specified indicates the server should join parts together in a transcode

path
string

Internal PMS path of the media to transcode.

peakBitrate
integer

Maximum bitrate (in kbps) to use in ABR.

Required range: x >= 0
photoResolution
string

Target photo resolution.

protocol
enum<string>

Indicates the network streaming protocol to be used for the transcode session: * 'http' - include the file in the http response such as MKV streaming * 'hls' - hls stream (RFC 8216) * 'dash' - dash stream (ISO/IEC 23009-1:2022)

Available options:
http,
hls,
dash
secondsPerSegment
integer

Number of seconds to include in each transcoded segment

subtitleSize
integer

Percentage of original subtitle size to use when burning subtitles (100 is equivalent to original size, 50 is half, ect)

Required range: x >= 1
subtitles
enum<string>

Indicates how subtitles should be included: * 'auto' - Compute the appropriate subtitle setting automatically * 'burn' - Burn the selected subtitle; auto if no selected subtitle * 'none' - Ignore all subtitle streams * 'sidecar' - The selected subtitle should be provided as a sidecar * 'embedded' - The selected subtitle should be provided as an embedded stream * 'segmented' - The selected subtitle should be provided as a segmented stream

Available options:
auto,
burn,
none,
sidecar,
embedded,
segmented,
unknown
videoBitrate
integer

Target video bitrate (in kbps).

Required range: x >= 0
videoQuality
integer

Target photo quality.

Required range: 0 <= x <= 99
videoResolution
string

Target maximum video resolution.

Response

MPD file (see ISO/IEC 23009-1:2022), m3u8 file (see RFC 8216), or binary http stream

The response is of type file.