Transcode at full speed

Some users of my application wants to be able to download media and transcode them at the same time.
While I have no problem controlling transcoding and every aspect of the API it seems that now, the transcoder is automatically limiting to requestedbitrate (*2), why not for actually streaming, but for downloading this is slow when the media could transcode at way higher speeds.

Is there some parameters to bypass this feature and transcode at full speed?

1 Like

Not possible. PMS just gets the request to transcode. It doesn’t know if its for streaming or downloading.

If there is a limit, then it’s either something on the client end, you’ve put a speed limit on the server, or your remote access isn’t working and the client is connecting through Plex’s Relay servers, which are limited.

Nope, I’ve made a tons of test and the bandwidth is always requested maxvideobirate * 2 at max.

There’s no limits anywhere I coded all the client part and it’s direct access. The speed are linear with maxvideobirate and the server can transcode at 20x and more easily.

So with maxVideoBitrate at 700Kb I’ll download at 1.4Mb max, with 2000Kb I’ll download at 4Mb max and with 300Kb I’ll download at 600Kb max and so on for anything.
I’m requesting mkv/aac/h264 with http protocol.

I’ve seen some docs explaining that this is made to allow more transcoding sessions and referring to the *2 if media was not fully analyzed.

Oh sorry. I didn’t get that *2 meant times 2. I thought that was 2 Mbps.

Not correct. The x2 is what Plex will assume the required bandwidth is to play a file. There is no limit on the speed that this is transferred. The only bandwidth controls PMS uses are if you’ve set the upload speed limit.

Can you PM more details on what you are doing? I’m wondering if you are doing something unexpected/unintended.

I’m doing the same thing I do since ages to transcode for playing but applied to download.

So


--> [935] GET http://192.168.1.80:32400/video/:/transcode/universal/decision?path=%2Flibrary%2Fmetadata%2F36999&X-Plex-Client-Profile-Extra=add-direct-play-profile%28type%3DvideoProfile%26container%3Dmkv%26videoCodec%3Dh264%26audioCodec%3Daac%26protocol%3D*%29%2Badd-transcode-target%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Bappend-transcode-target-codec%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Badd-direct-play-profile%28type%3DmusicProfile%26container%3Dmp3%26videoCodec%3D*%26audioCodec%3Dmp3%26protocol%3D*%29%2Badd-transcode-target%28type%3DmusicProfile%26container%3Dmp3%26audioCodec%3Dmp3%26protocol%3Dhttp%26context%3Dstreaming%29&protocol=http&maxVideoBitrate=750&canThrottle=0&directPlay=0&maxAudioBitrate=750&directStream=1&X-Plex-Platform=Android&X-Plex-Session-Identifier=9049af4f-bc44-4e7c-a395-c3fbaaba2993&fastSeek=1
<-- [935] 200 OK http://192.168.1.80:32400/video/:/transcode/universal/decision?path=%2Flibrary%2Fmetadata%2F36999&X-Plex-Client-Profile-Extra=add-direct-play-profile%28type%3DvideoProfile%26container%3Dmkv%26videoCodec%3Dh264%26audioCodec%3Daac%26protocol%3D*%29%2Badd-transcode-target%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Bappend-transcode-target-codec%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Badd-direct-play-profile%28type%3DmusicProfile%26container%3Dmp3%26videoCodec%3D*%26audioCodec%3Dmp3%26protocol%3D*%29%2Badd-transcode-target%28type%3DmusicProfile%26container%3Dmp3%26audioCodec%3Dmp3%26protocol%3Dhttp%26context%3Dstreaming%29&protocol=http&maxVideoBitrate=750&canThrottle=0&directPlay=0&maxAudioBitrate=750&directStream=1&X-Plex-Platform=Android&X-Plex-Session-Identifier=9049af4f-bc44-4e7c-a395-c3fbaaba2993&fastSeek=1 (1204ms, unknown-length body)
<-- [935] {"MediaContainer":{"size":1,"allowSync":"1","directPlayDecisionCode":3000,"directPlayDecisionText":"App cannot direct play this item. Direct play is disabled.","generalDecisionCode":1001,"generalDecisionText":"Direct play not available; Conversion OK.","identifier":"com.plexapp.plugins.library","librarySectionID":"8","librarySectionTitle":"TV Shows","librarySectionUUID":"130e39f0-4ac1-44d3-a3bd-26e942ea27f8","mediaTagPrefix":"/system/bundle/media/flags/","mediaTagVersion":"1601635484","transcodeDecisionCode":1001,"transcodeDecisionText":"Direct play not available; Conversion OK.","Metadata":[{"addedAt":"1527363851","art":"/library/metadata/36997/art/1587996476","contentRating":"TV-PG","duration":"2843168","grandparentArt":"/library/metadata/36996/art/1587996476","grandparentGuid":"com.plexapp.agents.thetvdb://250749?lang=en","grandparentKey":"/library/metadata/36996","grandparentRatingKey":"36996","grandparentTheme":"/library/metadata/36996/theme/1587996476","grandparentThumb":"/library/metadata/36996/thumb/1587996476","grandparentTitle":"3%","guid":"com.plexapp.agents.thetvdb://250749/1/2?lang=en","index":"2","key":"/library/metadata/36999","lastViewedAt":"1595787291","librarySectionID":"8","librarySectionKey":"/library/sections/8","librarySectionTitle":"TV Shows","originallyAvailableAt":"2016-11-25","parentGuid":"com.plexapp.agents.thetvdb://250749/1?lang=en","parentIndex":"1","parentKey":"/library/metadata/36997","parentRatingKey":"36997","parentThumb":"/library/metadata/36997/thumb/1587996476","parentTitle":"Season 1","rating":"8.0","ratingKey":"36999","summary":"Fernando's medical exam yields a stunning discovery, a logic puzzle stokes tension in the group, and Aline tries to find out what Ezequiel is hiding.","thumb":"/library/metadata/36999/thumb/1587996780","title":"Chapter 02: Coins","type":"episode","updatedAt":"1587996780","viewOffset":"2316000","year":"2016","Media":[{"id":"43468","videoProfile":"main","audioChannels":"2","audioCodec":"aac","bitrate":"711","container":"mkv","duration":"2843168","height":"270","videoCodec":"h264","videoFrameRate":"24p","videoResolution":"SD","width":"480","selected":true,"Part":[{"deepAnalysisVersion":"4","id":"44397","requiredBandwidths":"5070,4497,4347,4347,4347,4347,4347,4347","videoProfile":"main","bitrate":"711","container":"mkv","duration":"2843168","height":"270","width":"480","decision":"transcode","selected":true,"Stream":[{"bitrate":"581","codec":"h264","default":"1","displayTitle":"720p (H.264)","extendedDisplayTitle":"720p (H.264)","frameRate":"23.975999999999999","height":"270","id":"85598","requiredBandwidths":"4686,4113,3985,3985,3985,3985,3985,3985","streamType":"1","width":"480","decision":"transcode","location":"direct"},{"bitrate":"130","bitrateMode":"cbr","channels":"2","codec":"aac","default":"1","displayTitle":"Português (AC3 5.1)","extendedDisplayTitle":"Brazilian Portuguese (Português AC3 5.1)","id":"85599","language":"Português","languageCode":"por","requiredBandwidths":"384,384,384,384,384,384,384,384","selected":"1","streamType":"2","decision":"transcode","location":"direct"}]}]}],"Writer":[{"filter":"writer=84412","id":"84412","tag":"Cássio Koshikumo"},{"filter":"writer=84413","id":"84413","tag":"Denis Nielsen"}]}]}}
--> [229] GET http://192.168.1.80:32400/video/:/transcode/universal/start.mp4?path=%2Flibrary%2Fmetadata%2F36999&X-Plex-Client-Profile-Extra=add-direct-play-profile%28type%3DvideoProfile%26container%3Dmkv%26videoCodec%3Dh264%26audioCodec%3Daac%26protocol%3D*%29%2Badd-transcode-target%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Bappend-transcode-target-codec%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Badd-direct-play-profile%28type%3DmusicProfile%26container%3Dmp3%26videoCodec%3D*%26audioCodec%3Dmp3%26protocol%3D*%29%2Badd-transcode-target%28type%3DmusicProfile%26container%3Dmp3%26audioCodec%3Dmp3%26protocol%3Dhttp%26context%3Dstreaming%29&protocol=http&maxVideoBitrate=750&canThrottle=0&directPlay=0&maxAudioBitrate=750&directStream=1&X-Plex-Platform=Android&X-Plex-Session-Identifier=9049af4f-bc44-4e7c-a395-c3fbaaba2993&fastSeek=1&path=%2Flibrary%2Fmetadata%2F36999&X-Plex-Client-Profile-Extra=add-direct-play-profile%28type%3DvideoProfile%26container%3Dmkv%26videoCodec%3Dh264%26audioCodec%3Daac%26protocol%3D*%29%2Badd-transcode-target%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Bappend-transcode-target-codec%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Badd-direct-play-profile%28type%3DmusicProfile%26container%3Dmp3%26videoCodec%3D*%26audioCodec%3Dmp3%26protocol%3D*%29%2Badd-transcode-target%28type%3DmusicProfile%26container%3Dmp3%26audioCodec%3Dmp3%26protocol%3Dhttp%26context%3Dstreaming%29&protocol=http&maxVideoBitrate=750&canThrottle=0&directPlay=0&maxAudioBitrate=750&directStream=1&X-Plex-Platform=Android&X-Plex-Session-Identifier=9049af4f-bc44-4e7c-a395-c3fbaaba2993&fastSeek=1&X-Plex-Token=REDACTED&download=1
<-- [229] 200 OK http://192.168.1.80:32400/video/:/transcode/universal/start.mp4?path=%2Flibrary%2Fmetadata%2F36999&X-Plex-Client-Profile-Extra=add-direct-play-profile%28type%3DvideoProfile%26container%3Dmkv%26videoCodec%3Dh264%26audioCodec%3Daac%26protocol%3D*%29%2Badd-transcode-target%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Bappend-transcode-target-codec%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Badd-direct-play-profile%28type%3DmusicProfile%26container%3Dmp3%26videoCodec%3D*%26audioCodec%3Dmp3%26protocol%3D*%29%2Badd-transcode-target%28type%3DmusicProfile%26container%3Dmp3%26audioCodec%3Dmp3%26protocol%3Dhttp%26context%3Dstreaming%29&protocol=http&maxVideoBitrate=750&canThrottle=0&directPlay=0&maxAudioBitrate=750&directStream=1&X-Plex-Platform=Android&X-Plex-Session-Identifier=9049af4f-bc44-4e7c-a395-c3fbaaba2993&fastSeek=1&path=%2Flibrary%2Fmetadata%2F36999&X-Plex-Client-Profile-Extra=add-direct-play-profile%28type%3DvideoProfile%26container%3Dmkv%26videoCodec%3Dh264%26audioCodec%3Daac%26protocol%3D*%29%2Badd-transcode-target%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Bappend-transcode-target-codec%28type%3DvideoProfile%26context%3Dstreaming%26videoCodec%3Dh264%26protocol%3Dhttp%26container%3Dmkv%26audioCodec%3Daac%29%2Badd-direct-play-profile%28type%3DmusicProfile%26container%3Dmp3%26videoCodec%3D*%26audioCodec%3Dmp3%26protocol%3D*%29%2Badd-transcode-target%28type%3DmusicProfile%26container%3Dmp3%26audioCodec%3Dmp3%26protocol%3Dhttp%26context%3Dstreaming%29&protocol=http&maxVideoBitrate=750&canThrottle=0&directPlay=0&maxAudioBitrate=750&directStream=1&X-Plex-Platform=Android&X-Plex-Session-Identifier=9049af4f-bc44-4e7c-a395-c3fbaaba2993&fastSeek=1&X-Plex-Token=REDACTED&download=1 (298ms, unknown-length body)

With that configuration I download at

Downloading: 849.6 kB @ 559.7 kB/s
Downloading: 3.2 MB @ 1.5 MB/s
Downloading: 4.9 MB @ 932.2 kB/s
Downloading: 6.8 MB @ 1.2 MB/s

Change just maxVideoBitrate to 350 and only that and result is

Downloading: 791.9 kB @ 375.7 kB/s
Downloading: 1.9 MB @ 789.7 kB/s
Downloading: 3.0 MB @ 708.0 kB/s
Downloading: 3.9 MB @ 513.7 kB/s
Downloading: 4.8 MB @ 578.2 kB/s
Downloading: 5.5 MB @ 500.5 kB/s
Downloading: 6.6 MB @ 744.8 kB/s

I’ll let you guess the value for the 2 next attempts:

Downloading: 1.4 MB @ 934.7 kB/s
Downloading: 5.5 MB @ 2.8 MB/s
Downloading: 9.4 MB @ 2.5 MB/s
Downloading: 13.4 MB @ 2.1 MB/s
Downloading: 16.7 MB @ 2.2 MB/s
Downloading: 19.3 MB @ 1.7 MB/s
Downloading: 22.6 MB @ 2.2 MB/s
Downloading: 25.5 MB @ 1.9 MB/s
Downloading: 6.6 MB @ 4.4 MB/s
Downloading: 16.7 MB @ 6.4 MB/s
Downloading: 26.2 MB @ 4.8 MB/s
Downloading: 34.0 MB @ 5.1 MB/s
Downloading: 43.2 MB @ 6.0 MB/s
Downloading: 52.2 MB @ 6.0 MB/s

I’m still not clear on how you are turning that transcode request into a download. But from your numbers it appears that there is a latency issue. Are you downloading from a server that is fairly far away? If you can run a trace route that should tell you the latency. Latency will have a higher impact on smaller files so files made with a lower bitrate will transfer slower than files with a higher bitrate.

I’m on local network with wifi 5ghz at 1 meter from the access point with server to NAS on aggregated 2 GB and server to access point at 1GB.

There’s nearly no latency…

About download I just read the bytes at maximum possible speed, exactly the same as without transcoding and can reach 40MB on that phone when direct downloading.

I don’t really see the correlation between media byte rate and bytes read per second and specially not when it’s so linear with direct link between.

Edit just made tests locally on the server with 1000

100 68.8M    0 68.8M    0     0  5488k      0 --:--:--  0:00:12 --:--:-- 5868k

with 7000

100  171M    0  171M    0     0  16.6M      0 --:--:--  0:00:10 --:--:-- 16.6M

So even locally the speed is impacted but strangely at lower ratio it’s not 2* but a little better.

That’s the part I don’t get. Without a transcode, it’s just 1 file. When transcoded, it’s 100s or 1000s of smaller files. How are you requesting these files? Are you requesting them as they are being created? If so there is overhead to generate these files so I’m just wondering if that is what you are running into.

I’m requesting mkv/aac/h264 with http protocol not hls.

So I do not request other files I just read the data from the transcoding url that properly return the mkv content that i write to a file that can then be read. (No m3u8 and all the chunks to deal with)
Maybe Plex generate a tons of intermediary files and automatically aggregate them and it’s the cause, but from my memory it was not the case before (long time ago) and transcoding did generate a single file that it served.

Even if I switched to hls I’m not sure I have control over segments size so I doubt it would be better.

That shouldn’t be possible, or at least not normally. You are doing something different than what Plex normally does.

I’ve been using Plex for 10 years and never known PMS to do this. I’m really lost on how you accomplished generating a single mkv file with a URL command. You can use the Plex Transcoder manually to do this, but I’m not aware of an API command that can do this.

Well it’s supported by the API it’s just a matter of using the proper transcoding profiles. You have all the parameters in my previous posts. the protocol parameter is here for that.

There quite a few devices that does not support hls and it was always possible to transcode this way. The major downside is that that transcoding way does not support seek and it’s necessary to restart transcoding at new seek point.

Ok. I got confirmation that this is possible. I learned something new.

Regardless, PMS does not set any speed limits. If you can reproduce and provide the PMS log we can investigate more.

Busy week end but will follow up next week with logs in PM. And I believe you that it’s not PMS but there’s something with the transcoder that induce this strange behaviour.

It’s probably just some parameters to fix but can’t figure them out.

What exactly do you need?

Just the PMS log after downloading the file.

Lacking time but after quickly testing with Emby and BubbleUPnP I have the same linear issue with them on low bitrate.
I suspect this is ffmepg related, so not sure there’s something to address on PMS directly.

Did you get anywhere? Is this for your Yatse app?

When you’re doing this, what does the ffmpeg invocation on the server look like? I’m curious about the output - if ffmpeg is writing to a file and being externally throttled, or if it’s writing to something like a pipe and pausing because a queue is full. The fact it goes faster when you have zero latency is interesting.

Yes it’s for Yatse and I’ve stopped searching after seeing other servers behaved the same.

Can try to look into it next week again.