# Plex Transcode API

**URL:** <https://forums.plex.tv/t/plex-transcode-api/7312>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [January 9, 2011, 9:37pm UTC](https://forums.plex.tv/t/plex-transcode-api/7312 "2011-01-09T21:37:16Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![dtmetz](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@dtmetz](https://forums.plex.tv/u/dtmetz)\
**Post date:** [May 23, 2011, 3:23am UTC](https://forums.plex.tv/t/plex-transcode-api/7312/21 "2011-05-23T03:23:15Z")

</div>

I’m trying to follow the C# example in Javascript to match what was posted on the blog, but I keep getting a 400 Bad Request and the log file says:  
  
Had trouble breaking X-Plex-Access-Code=3W3wnpyaxPEIfbV+mSg5fPFU3HZHWqRbh9aYfmDAbFU=  
  
  
  
My javascript is basically the example given in the blog post but constructs the URL and redirects to it.

```auto

<br />
<br />
<script type="text/javascript" src="base64.js"></script><br />
<script type="text/javascript" src="jssha256.js"></script><br />
<script><br />
<br />
function move() {<br />
<br />
part = '/library/parts/1/Jake%20and%20Amir_%20Karate.m4v';<br />
part = encodeURI(part);<br />
myurl = "/video/:/transcode/segmented/start.m3u8?identifier=com.plexapp.plugins.library&ratingKey=97007888&offset=0&quality=5&url=http%3A%2F%2Flocalhost%3A32400" + part + "&3g=0&httpCookies=&userAgent=";<br />
<br />
publicKey = "KQMIY6GATPC63AIMC4R2";<br />
privateKey = decode64("k3U6GLkZOoNIoSgjDshPErvqMIFdE0xMTx8kgsrhnC0=");<br />
time = Math.round(new Date().getTime() / 1000);<br />
<br />
msg = myurl+"@"+time;<br />
redirectURL = msg;<br />
HMAC_SHA256_init(privateKey);<br />
HMAC_SHA256_write(msg);<br />
mac = HMAC_SHA256_finalize();<br />
token = encode64(array_to_string(mac));<br />
<br />
<br />
window.location = 'http://localhost:32400' + redirectURL + "&X-Plex-Access-Key=" + publicKey + "&X-Plex-Access-Time="+ time + "&X-Plex-Access-Code=" + token; <br />
}<br />
<br />
</script><br />
<br />
<body onload="timer=setTimeout('move()',0)"><br />
<br />

```

  
  
It produces something like  

```auto

http://localhost:32400/video/:/transcode/segmented/start.m3u8?identifier=com.plexapp.plugins.library&ratingKey=97007888&offset=0&quality=5&url=http%3A%2F%2Flocalhost%3A32400/library/parts/1/Jake%2520and%2520Amir_%2520Karate.m4v&3g=0&httpCookies=&userAgent=@1306120533&X-Plex-Access-Key=KQMIY6GATPC63AIMC4R2&X-Plex-Access-Time=1306120533&X-Plex-Access-Code=3W3wnpyaxPEIfbV+mSg5fPFU3HZHWqRbh9aYfmDAbFU=

```

  
  
And in the log file I get  
  

```auto

<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - Request: GET /video/:/transcode/segmented/start.m3u8?identifier=com.plexapp.plugins.library&ratingKey=97007888&offset=0&quality=5&url=http%3A%2F%2Flocalhost%3A32400/library/parts/1/Jake%2520and%2520Amir_%2520Karate.m4v&3g=0&httpCookies=&userAgent=@1306120533&X-Plex-Access-Key=KQMIY6GATPC63AIMC4R2&X-Plex-Access-Time=1306120533&X-Plex-Access-Code=3W3wnpyaxPEIfbV+mSg5fPFU3HZHWqRbh9aYfmDAbFU= [::1] (1 live)<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * identifier => com.plexapp.plugins.library<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * ratingKey => 97007888<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * offset => 0<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * quality => 5<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * url => http://localhost:32400/library/parts/1/Jake%20and%20Amir_%20Karate.m4v<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * 3g => 0<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * httpCookies => <br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * userAgent => @1306120533<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * X-Plex-Access-Key => KQMIY6GATPC63AIMC4R2<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * X-Plex-Access-Time => 1306120533<br />
May 22, 2011 22:15:33 [0xb038d000] ERROR - Had trouble breaking X-Plex-Access-Code=3W3wnpyaxPEIfbV+mSg5fPFU3HZHWqRbh9aYfmDAbFU=<br />
May 22, 2011 22:15:33 [0xb038d000] ERROR - ERROR: Parsing request failed.<br />
May 22, 2011 22:15:33 [0xb0c08000] DEBUG - Request: GET /favicon.ico [::1] (1 live)<br />
May 22, 2011 22:15:33 [0xb0c08000] DEBUG - Content-Length of /Users/dan/Library/Application Support/Plex/Plex Media Server.app/Contents/Resources/Graphics/favicon.ico is 1150.<br />

```

  
  
Any ideas on what I'm doing wrong here?

---

<div class="post-metadata">

**Author:** ![yannick\_s](https://avatars.discourse-cdn.com/v4/letter/y/f14d63/32.png) [@yannick\_s](https://forums.plex.tv/u/yannick_s)\
**Post date:** [June 24, 2011, 9:57pm UTC](https://forums.plex.tv/t/plex-transcode-api/7312/22 "2011-06-24T21:57:58Z")

</div>

> [@](#):
>
> ```auto
> 
> <br />
> /Users/dave/Library/Application Support/Plex Media Server/Plug-ins/System.bundle/Contents/Resources/transcode-presets/video-embedded-h264.ffpreset<br />
> 
> ```
> 
>   
>   
> Is this file present? (Obvious question, I know)  
>   
> Verified I seem to see the same issue locally. No time to look at it right now, though :(

  
  
I've got a similar problem when testing transcoding against the linux server.  
Under Linux the problem seems to be that it generates the following ffmpeg parameter:   
-vpre /home/user/Library/Application Support/Plex Media Server/Plug-ins/System.bundle/Contents/Resources/transcode-presets/video-embedded-h264.ffpreset  
which is interpreted as different parameters because the path contains spaces which are not escaped/put between quotes.  
Is it a Linux specific problem? Is there any workaround? Any way to make Plex use a path without spaces?  
  
Yannick

---

<div class="post-metadata">

**Author:** ![JiK](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@JiK](https://forums.plex.tv/u/JiK)\
**Post date:** [January 5, 2013, 9:24pm UTC](https://forums.plex.tv/t/plex-transcode-api/7312/23 "2013-01-05T21:24:25Z")

</div>

I know this topic has been silent for more than a year now. But I do have a question about the transcode API. Is it possible to set the offset time for where the transcode has to start? I have a working transcode URL generator in python and a way of playing them. All it needs now is to start from a given offset.

---

<div class="post-metadata">

**Author:** ![xcrunner\_1](https://avatars.discourse-cdn.com/v4/letter/x/bc8723/32.png) [@xcrunner\_1](https://forums.plex.tv/u/xcrunner_1)\
**Post date:** [March 8, 2013, 6:51pm UTC](https://forums.plex.tv/t/plex-transcode-api/7312/24 "2013-03-08T18:51:36Z")

</div>

Would you be interested in releasing the python source by chance? I am looking into a similar project for more reliable dlna streaming to certain devices.

---

<div class="post-metadata">

**Author:** ![JiK](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@JiK](https://forums.plex.tv/u/JiK)\
**Post date:** [March 8, 2013, 7:27pm UTC](https://forums.plex.tv/t/plex-transcode-api/7312/25 "2013-03-08T19:27:32Z")

</div>

> Would you be interested in releasing the python source by chance? I am looking into a similar project for more reliable dlna streaming to certain devices.

I'ts part of a bigger app that was used as a interface-less plex client for the raspberry pi, before&nbsp;porting plex HT to the pi was started. The code responsible for the transcode url can be found on github, the direct link to the file is:&nbsp;[https://github.com/megawubs/pyplex/blob/master/plexAPI/info.py,](https://github.com/megawubs/pyplex/blob/master/plexAPI/info.py,) it's part of my modifications on the existing python plex-api.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 8:57pm UTC](https://forums.plex.tv/t/plex-transcode-api/7312/26 "2019-12-20T20:57:05Z")

</div>

Closed on December 20, 2019, 8:57pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

[Previous page](https://forums.plex.tv/t/plex-transcode-api/7312.md?page=1)
