Automatic Pre-Encoding of new titles

Hi folks,

after timbering my TrueNAS Core together, setting everything up and getting my Plex-Jail fluidly working i´m now at the tuning possibilities. A Server should serve, not create work.
So i wondered if there is an option to pre-encode files automatically.
Though i have a 12mbps-upload-connection and no graphics-card but lots of hdd-space, i want my plex-server to automatically scan the new file and based on the bitrate of the new file i want it to start a pre-encode.

Following Scenario:

I mounted my movie-folder via SMB to plex and it scans the media nicely. Every now and then i add a movie. Sometimes 720p, sometimes 1080p, sometimes 4k.
let´s say we have several 1080p-movie with about 20k/7k/3k bps bitrate.

Scenario1:
20mbps > 9mbps → pre-encode to 8mbps and 4mbps with server-presets

Scenario2:
7mbps < 9mbps → no pre-encode(next function)
7mbps > 5mbps → pre-encode to 4mbps with server presets

Scenario3:
3mbps < 9mbps -->no pre-encode(next function)
3mbps < 5mbps → no pre-encode(no further inspection for pre-encoding)

Though i have a goal and some knowledge of control-structures i have no clue how to start this project on Plex. I hope someone could give me a hint or guide me to good solution for this.

Regards
Kable93

Apply “Optimize” jobs to the whole library.
For each quality level, you create one job.
If the source file already has a quality equally or below that of the destination quality, nothing will be transcoded.
(only if video and audio codecs are already compatible, i.e. AVC/H.264 and audio AAC)

1 Like

It checks if the present data is allready under 4mbps/8mbps? i thought it maybe scales up.
Theres many stupid encoding-techniques out there.

But thanks for the fast response. i´ll look into it.

apparently it still encodes a version, original 7,6 mbps, with 8mbps. So this is not the solution to my problem.

Careful: this is just the average bandwidth of the file. It can easily have passages where the momentary bandwidth is way above 8 mbps.
Hence the transcode, where the parameters make sure that even the momentary bandwith peaks stay within the boundary of 8 mbps.

(see post scriptum(Thats a good point. But apparently even if i encode a title with way lower bitrate (3mbps) it just copys the file over in the plex-media-folder, hence taking away hdd-space. I have no problem using space. But i´m not giving it away for free.
This is no solution. Why duplicate when it is not needed?))
And why look at the peak-bitrate? There´s a technique called buffering we could use to dampen those peaks. Cause of this i set the encode-bitrate to 8mbps and not 10 or 12.

PS: i compared again before posting but wanted to let those thoughts been written i made. It changes the file-type from .mkv to .mp4. is there a way to let it unchanged, maybe by changing optimizing to another preset like windows or android? I mostly use mkv-files.

Because we are talking about optimizing files for streaming. There are some important differences between streaming and playing files directly off a network file share.

This won’t help for all use cases. There are different devices which only have a small buffer, so there is no way you can let it buffer for e.g. 10 minutes beforehand.

What is the make up of your source files?
Please post the first ~20 lines from the Plex XML info of one such a file. Where you feel it got converted unnecessarily.

hmm…somehow it does not show me the xml-file thoug it opened a new tab and i can see the web-souce-text with additional data.
i hope the attached txt fits as well.skyscraper.txt (5.7 KB)

<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="1" allowSync="1" identifier="com.plexapp.plugins.library" librarySectionID="7" librarySectionTitle="Filme" librarySectionUUID="c3dda61f-fdad-439f-958a-87fcd9d059e3" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1612639587">
<Video ratingKey="1830" key="/library/metadata/1830" guid="plex://movie/5d776d33fb0d55001f599cde" studio="Flynn Picture Company" type="movie" title="Skyscraper" librarySectionTitle="Filme" librarySectionID="7" librarySectionKey="/library/sections/7" contentRating="PG-13" summary="Eine neue berufliche Herausforderung in Hongkong wird zum Albtraum f&#252;r den Kriegsveteranen und ehemaligen FBI-Einsatzchef Will Sawyer, der im The Pearl, dem mit 240 Stockwerken h&#246;chsten Wolkenkratzer der Welt, f&#252;r Sicherheit sorgen soll. Kaum hat Will sein Amt angetreten, kommt es zur Katastrophe: Die 96. Etage steht pl&#246;tzlich in Flammen. In den Stockwerken dar&#252;ber ist seine Familie eingeschlossen, ohne eine realistische Chance auf Rettung. Zu seinem Entsetzen wird er auch noch beschuldigt, die Feuersbrunst selbst entfacht zu haben! Verzweifelt versucht Sawyer, die Brandstifter zu finden, seine Familie aus dem flammenden Inferno zu retten und seine Unschuld zu beweisen." rating="4.8" audienceRating="6.9" year="2018" tagline="Don&#39;t look down" thumb="/library/metadata/1830/thumb/1615393316" art="/library/metadata/1830/art/1615393316" duration="6144544" originallyAvailableAt="2018-07-12" addedAt="1585566913" updatedAt="1615393316" audienceRatingImage="rottentomatoes://image.rating.upright" chapterSource="media" hasPremiumPrimaryExtra="1" ratingImage="rottentomatoes://image.rating.rotten">
<Media id="4743" duration="6144544" bitrate="4980" width="1916" height="796" aspectRatio="2.35" audioChannels="2" audioCodec="ac3" videoCodec="h264" videoResolution="1080" container="mkv" videoFrameRate="24p" videoProfile="high" title="Original">
<Part accessible="1" exists="1" id="4743" key="/library/parts/4743/1585566913/file.mkv" duration="6144544" file="/media/Filme/Skyscraper1080/pso-skyscraper_web.1080p.repack.mkv" size="3825209082" container="mkv" deepAnalysisVersion="4" requiredBandwidths="7663,6852,6270,5930,5812,5694,5320,5320" videoProfile="high">
<Stream id="10255" streamType="1" default="1" codec="h264" index="0" bitrate="4564" language="English" languageCode="eng" bitDepth="8" chromaLocation="topleft" chromaSubsampling="4:2:0" codedHeight="800" codedWidth="1920" colorPrimaries="bt709" colorRange="tv" colorSpace="bt709" colorTrc="bt709" frameRate="23.976" hasScalingMatrix="0" height="796" level="40" profile="high" refFrames="5" requiredBandwidths="7247,6436,5854,5514,5396,5277,4904,4904" scanType="progressive" width="1916" displayTitle="1080p (H.264)" extendedDisplayTitle="1080p (H.264)">
</Stream>
<Stream id="10256" streamType="2" selected="1" default="1" forced="1" codec="ac3" index="1" channels="2" bitrate="224" language="Deutsch" languageCode="ger" audioChannelLayout="stereo" requiredBandwidths="224,224,224,224,224,224,224,224" samplingRate="48000" displayTitle="Deutsch (AC3 Stereo)" extendedDisplayTitle="Deutsch (AC3 Stereo)">
</Stream>
<Stream id="10257" streamType="2" codec="ac3" index="2" channels="2" bitrate="192" language="English" languageCode="eng" audioChannelLayout="stereo" requiredBandwidths="192,192,192,192,192,192,192,192" samplingRate="48000" displayTitle="English (AC3 Stereo)" extendedDisplayTitle="English (AC3 Stereo)">
</Stream>
<Stream id="10258" streamType="3" default="1" forced="1" codec="srt" index="3" bitrate="0" language="Deutsch" languageCode="ger" requiredBandwidths="1,1,1,1,1,1,1,1" title="German forced" displayTitle="Deutsch Erzwungen (SRT)" extendedDisplayTitle="German forced (Deutsch SRT)">
</Stream>
</Part>
</Media>
<Media id="6321" duration="6144544" bitrate="4984" width="1916" height="796" aspectRatio="2.35" audioChannels="2" audioCodec="ac3" videoCodec="h264" videoResolution="1080" container="mp4" videoFrameRate="24p" optimizedForStreaming="1" proxyType="42" has64bitOffsets="0" target="pre_encode_8mbps_test" videoProfile="high" title="pre_encode_8mbps_test">
<Part accessible="1" exists="1" id="6321" key="/library/parts/6321/1615392194/file.mp4" duration="6144544" file="/media/Filme/Skyscraper1080/Plex Versions/pre_encode_8mbps_test 21/Skyscraper1080 (1900).mp4" size="3828050091" container="mp4" has64bitOffsets="0" optimizedForStreaming="1" videoProfile="high">
<Stream id="13461" streamType="1" default="1" codec="h264" index="0" bitrate="4562" language="English" languageCode="eng" bitDepth="8" chromaLocation="topleft" chromaSubsampling="4:2:0" codedHeight="800" codedWidth="1920" colorPrimaries="bt709" colorRange="tv" colorSpace="bt709" colorTrc="bt709" frameRate="23.976" hasScalingMatrix="0" height="796" level="40" profile="high" refFrames="5" streamIdentifier="1" width="1916" displayTitle="1080p (H.264)" extendedDisplayTitle="1080p (H.264)">
</Stream>
<Stream id="13462" streamType="2" selected="1" default="1" codec="ac3" index="1" channels="2" bitrate="224" language="Deutsch" languageCode="ger" audioChannelLayout="stereo" samplingRate="48000" streamIdentifier="2" displayTitle="Deutsch (AC3 Stereo)" extendedDisplayTitle="Deutsch (AC3 Stereo)">
</Stream>
<Stream id="13463" streamType="2" codec="ac3" index="2" channels="2" bitrate="192" language="English" languageCode="eng" audioChannelLayout="stereo" samplingRate="48000" streamIdentifier="3" displayTitle="English (AC3 Stereo)" extendedDisplayTitle="English (AC3 Stereo)">
</Stream>
<Stream id="13464" key="/library/streams/13464" streamType="3" forced="1" codec="srt" language="Deutsch" languageCode="ger" format="srt" displayTitle="Deutsch Erzwungen (SRT Extern)" extendedDisplayTitle="Deutsch Erzwungen (SRT Extern)">
</Stream>
</Part>

This is the XML :slight_smile:

I see. It appears the optimized version was indeed copied pointlessly.

Do you have a solution for this? or maybe a hint how i could realize a simple script with some functions? Never done this before.
If not, is it possible to add new files to an existing pre-encode-job or do i have to set up a new job every time my library expands? I could filter by bitrate and only encode if above a specific bitrate. It´s a shift-click, manual but if i want to check the metadata i could check this, too.

Thanks for your help anyway. I learned much about video-codecs the last days :smiley:

The existing optimization jobs get re-evaluated periodically, so that newly added items in your library get optimized automatically.

But as we already have seen it also does things like pointless encoding. So i don´t want to create a job spanning my whole library.
i mean i would select the files manually, according to the average bitrate, add a job for those and if i add a new file i can just add those files to an existing encoding-job. Tried it out but it allways creates new jobs.
I know, i know. This is just a little tweak i want to realize and not about essential functionality.
But you pulled one tooth after another and i don´t want to fall back to endless encode-jobs. After 1 year it will get pretty much confusing with all those encode-jobs.

A colleague just pointed out that optimized files are always using the mp4 container. That’s the reason for the above.

(Historically, mp4 was better accepted by devices than MKV)

Unfortunate, but thx for the Information.

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