Transcoding H264 to H264 - DTS Audio to AAC/AC3 (solved)



Hey guys,

i've got two questions.
So i'm running my PlexConnect and PMS on a Raspberry Pi 3. Everthings works fine so far.
If i watch an episode of a series or a movie (720p / 1080p H264 - AC35.1 - MKV) PMS sends the video and the audio via "Direct Stream" to the Apple TV 3 (so far so good).
When i start a other movies with the same options (720p / 1080p H264 - AC35.1 - MKV) PMS transcodes the video from H264 to H264.
The problem here is that the Raspberry Pi has not enough computing power to transcode video so it stutters and it is not watchable at all. Transcoding Audio from AC3 to AAC is not a problem for the Raspberry.

So why transcode a video from H264 to H264 when its already in H264? Is there anyway to allow PMS only to transcode the audio if necessary? Or needs the Apple TV a specific H264 format in order to play it properly?

Second question:
I know that DTS is not supported by the Apple TV, but is there a away to transcode DTS to AC3 or AAC to get the video running?


I’ve just noticed that DTS automatically converts into AC3. So the second question is solved :slight_smile:


The reason why PMS transcodes should be in the logs. Pls post them here (or send me via PM).


@moody_blue Thanks for your fast response. Here is a part from my log file (if you need the whole log just let me know). The first movie gets streamed directly the second one needs to be transcoded.

I think i figuered it out why PMS transcodes just some of my videos.
The reason is the H264 Level (never heard of the before) but apparently the Apple TV 3 can only play H264 videos level 4.0 or lower (source:
The videos that are level 4.0 and lower dont need to be transcode and can be played direct at the Apple TV.
All other video (mine where level 4.1) need to be transcoded to play at the Apple TV.
So the Apple TV cant play videos wich are above level 4.0. The max bit rate for level 4.0 is 20.000 kbit/s (source: BUT the movies which i want to play that are level 4.1 are below that bitrate (e.g. 15.029 kbit/s). So technically my Apple TV can play thoses videos without transcoding them.

So is there a line in the code to specify the level to when the transcoding starts?

In line 788 (

xargs['X-Plex-Client-Capabilities'] = "protocols=http-live-streaming,http-mp4-streaming,http-streaming-video,http-streaming-video-720p,http-mp4-video,http-mp4-video-720p;videoDecoders=h264{profile:high&resolution:1080&level:41};audioDecoders=mp3,aac{bitrate:160000}"

there is a parameter called level but chaning it does not seem to have an effect for me.


I need the zip with PMS logs, Settings.cfg and ATVSettings.cfg.


Regarding your first question, I forgot to ask the mediainfo of the file. From the logs it looks like The Last Knight (2017) has a bitrate higher then 20MBps, that’s why it’s being downsampled. Can you pls confirm what is the bitrate ?

Regarding your 2nd question, none of the films shown in the logs seemed to have DTS tracks. AC3 was being passed to the ATV because you have Dolby Digital = on. I don’t have any DTS samples to test, but I suppose that they will be transcoded to AC3 when Dolby Digital = on and to stereo if Dolby Digital = off.

Note: if you remux these films to mp4 containner (ffmpeg can do it easily) you will get a better experience because the ATV will then indicate to PMS that it can directplay, so you will be able to use ATV pop-up menus to control navigation through chapters, choose audio tracks, etc. In my case (don’t know why) mp4’s occupy the whole screen of my TV, but if they are transcoded I have two black bars, above and under the film.


So i looked up all my videos that i could not play and none of them had a bitrate that is higher than 20.000 kbit/s.
The Last Knight (2017) for example has a bitrate of 15.893 kbit/s (15.029 kbit/s video + 224 kbit/s audio1 + 640 kbit/s audio2).

<Media videoResolution="1080" id="1889" duration="9278848" bitrate="15893" width="1920" height="1008" aspectRatio="1.85" audioChannels="6" audioCodec="ac3" videoCodec="h264" container="mkv" videoFrameRate="24p" videoProfile="high">
    <Stream id="4080" streamType="1" default="1" codec="h264" index="0" bitrate="15029" bitDepth="8" chromaSubsampling="4:2:0" frameRate="23.976" hasScalingMatrix="0" height="1008" level="41" profile="high" refFrames="4" scanType="progressive" width="1920"/>
    <Stream id="4081" streamType="2" selected="1" default="1" forced="1" codec="ac3" index="1" channels="2" bitrate="224" language="Deutsch" languageCode="ger" audioChannelLayout="stereo" samplingRate="48000"/>
    <Stream id="4082" streamType="2" codec="ac3" index="2" channels="6" bitrate="640" language="English" languageCode="eng" audioChannelLayout="5.1(side)" samplingRate="48000"/>

So technically the Apple TV would be able to play the video. I guess because the level of the H264 Codec is 4.1 Plex thinks the video bitrate is higher than 20.000 kbit/s so it transcodes it even the actual bitrate is lower than 20.000 kbit/s.

I tried a H264 level editor (source: to set the level of a video from 4.1 to 4.0 but it does not change anything.

So i need to change a line in the code where it’s declared when a movie gets transcoded and set the value higher to test this out, but i did not find it yet.


Can you please try with transcodequality = 1080p 40.0Mbps ? This is because PMS, several years ago, respected the 20MBps limit, but now it applies a 1.5x “safety factor”. 1.5 * 15.029 is higher than 20MBps, this is what triggers transcoding.

Profile level used to be part of the decision process, but not anymore.


Yes, it worked!

Thank you!


Thanks for confirming. But I am not satisfied with this “solution” because, if you have a 25MBps film:

  1. PMS will multiply 25 by 1.5=37.5MBps, so it will not transcode
  2. PMS will send the 25MBps to the ATV, and it will hang during playback in scenes with more than 20MBps (requiring an ATV reboot)
  3. If you have a H264 35MBps film in .m4v container PlexConnect will decide to not transcode (it will not ask PMS for decision), and ATV3 will hang during playback in scenes with more than 20MBps
    Changing PlexConnect (to replace transcodequality = 1080p 40.0Mbps with 1080p 30.0Mbps) has the problem that a 40MBps film will be transcoded to 30MBps, so the ATV3 will also hang.

I will contact Plex’s transcoder engineer for advice. When Plex Inc. decided to implement a fudge factor of 1.5x it was for a good reason, but I am not aware of it.


I need a film sample, pls see email


I’ll send you a sample of the video.


Transcoding could have been caused by the fact that PlexConnect was not passing a mediaBufferSize parameter to PMS.

I’ve just created a ‘0.5-dev-200218’ PlexConnect version with this parameter (and other changes). Can you please test it with transcodequality = 1080p 20.0Mbps ?


Sorry i can’t test it atm, because i’m not home. But as soon as i get home i will test it for you.


You can also test with V0.6. Thanks.


I’m so sorry i totally forgot!

I tried the newes GitHub Version and it seems to work find.