Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upcoming added features and changes to the code (an open discussion) #22

Open
michealespinola opened this issue May 3, 2022 · 6 comments
Assignees
Labels
discussion DSM7 Synology DSM 7 enhancement New feature or request

Comments

@michealespinola
Copy link
Owner

michealespinola commented May 3, 2022

My current priorities and open projects:

  1. Implement a codec downloader/updater. This will ensure maximum playback availability in the case of internet or plex.tv server unavailability. Codecs are otherwise downloaded on the fly as encountered/needed by the PMS, and this will allow the PMS to have higher availability during outages or intentional offline modes. This also addresses the rare need for deleting the codecs folder contents so that PMS can download newer versions when it has issues. Currently there are 284 codecs that will download for my Plex server
    STATUS: Partially completed as syno.plexcodecpreloader.sh. Hooks still need to be made into the update script so that this is automatically performed for each update to the PMS. Codec versioning matches PMS versioning, and they need to be updated together if they cannot be updated on-the-fly
  2. Implement PMS version rollback based on local archive
    STATUS: Work in progress
  3. Simplify internal code techniques and documentation
    STATUS: Always ongoing
  4. Create output and debug logs
    STATUS: Completed. .log and .debug files will automatically be created in the script directory

As always, I welcome any thoughts or ideas...

@michealespinola michealespinola added enhancement New feature or request DSM7 Synology DSM 7 discussion labels May 3, 2022
@michealespinola michealespinola self-assigned this May 3, 2022
@michealespinola michealespinola pinned this issue Dec 11, 2022
@jmighion
Copy link

Can you share any info on the codec downloader/updater? I see some folks have figured out the paths and setup here https://old.reddit.com/r/PleX/comments/u66k2p/can_i_download_codecs_and_subtitles_to_devices_in/ and am interested in helping add this functionality to this project.

@michealespinola
Copy link
Owner Author

michealespinola commented Sep 17, 2023

LOL, that's me! Yeah, I indeed have it all figured out. The version of the script I currently have (but have kinda put on the backburner) works automatically off of your current config (like my syno.plexupdate script). The one thing that it is lacking (that I keep putting off implementing) is passing it variables from the command line so it can be used without being in an online Synology NAS environment. You need to know the following in order to interrogate the Plex API for codecs:

  • Target kernel (uname --kernel-name)
  • Target architecture (uname --machine)
  • Plex Device ID ('.device-id' file)
  • Plex FFmpeg version ('Plex Transcoder' custom version of ffmpeg)

BUT, and this is a big butt, you have to request each codec individually, and you have to know what you are asking for. You cant just request "everything"... You have to request what is applicable to that version of FFmpeg - and to do that, you have to do a codec list dump from the version of FFmpeg that is running with that version of PMS, like:

[...]/PlexMediaServer/Plex Transcoder" -codecs

My script processes the outputted list along with the (4) system-specific system specs, crafts special URLs, and then calls the Plex API to see what is retrievable. Not everything is, but there is a lot. All you can do is essentially throw the entire list at the Plex API and see what it allows you to download.

You also can't go crazy with it or Plex will temp ban your IP (HTTP Error 429), but the script can process the entire list without an issue. If you run it too many times within 30 minutes though, you will get temporarily banned.

In its current version, it works fully automated on my online Synology NAS, but it would be a multi-step process to work offline. You would need to know very specific info about that offline PMS in order to download properly versioned codecs for it. You can't mismatch it. Some codecs overlap versions while others do not. If you have the wrong version codec, that media will not be playable.

So, this is why it's been on my backburner, because I haven't had a driving need to take it any further. I brought it up on Reddit a few times, but no one was interested, so I lost interest as well.

This is the report it currently makes:

All Codecs Downloaded

codec d e
aac X X
aac_latm X
aac_lc X
aasc X
ac3 X X
adpcm_4xm X
adpcm_adx X
adpcm_afc X
adpcm_aica X
adpcm_ct X
adpcm_dtk X
adpcm_ea X
adpcm_ea_maxis_xa X
adpcm_ea_r1 X
adpcm_ea_r2 X
adpcm_ea_r3 X
adpcm_ea_xas X
adpcm_g722 X
adpcm_g726 X
adpcm_g726le X
adpcm_ima_amv X
adpcm_ima_apc X
adpcm_ima_dat4 X
adpcm_ima_dk3 X
adpcm_ima_dk4 X
adpcm_ima_ea_eacs X
adpcm_ima_ea_sead X
adpcm_ima_iss X
adpcm_ima_oki X
adpcm_ima_qt X
adpcm_ima_rad X
adpcm_ima_smjpeg X
adpcm_ima_wav X
adpcm_ima_ws X
adpcm_ms X
adpcm_psx X
adpcm_sbpro_2 X
adpcm_sbpro_3 X
adpcm_sbpro_4 X
adpcm_swf X
adpcm_thp X
adpcm_thp_le X
adpcm_vima X
adpcm_xa X
adpcm_yamaha X
aic X
alias_pix X
amrnb X
amv X
anm X
ape X
asv1 X
asv2 X
atrac1 X
atrac3 X
atrac3p X
aura X
aura2 X
avrn X
avrp X
avs X
avui X
bethsoftvid X
bfi X
binkaudio_dct X
binkaudio_rdft X
bintext X
bmv_audio X
bmv_video X
brender_pix X
c93 X
cavs X
cdgraphics X
cdxl X
cfhd X
cinepak X
cljr X
cllc X
comfortnoise X
cook X
cpia X
cscd X
cyuv X
dca X
dds X
dfa X
dnxhd X
dpx X
dsd_lsbf X
dsd_lsbf_planar X
dsd_msbf X
dsd_msbf_planar X
dsicinaudio X
dsicinvideo X
dss_sp X
dvaudio X
dvvideo X
dxa X
dxtory X
dxv X
escape124 X
escape130 X
evrc X
exr X
fic X
flashsv X
flashsv2 X
flic X
flv X
fraps X
frwu X
g2m X
g723_1 X
g729 X
gsm X
gsm_ms X
h261 X
h263 X
h263i X
h263p X
h264 X
hap X
hevc X
hq_hqa X
hqx X
iac X
idcin X
idf X
iff_ilbm X
imc X
indeo2 X
indeo3 X
indeo4 X
indeo5 X
interplay_dpcm X
jpeg2000 X
jpegls X
jv X
kgv1 X
kmvc X
lagarith X
libx264 X
loco X
mace3 X
mace6 X
mdec X
metasound X
mimic X
mjpegb X
mmvideo X
motionpixels X
mp1 X
mp2 X
mp3 X
mp3adu X
mp3on4 X
mpeg1video X
mpeg2video X
mpeg4 X
msa1 X
msmpeg4v1 X
msmpeg4v2 X
msmpeg4v3 X
msrle X
mss1 X
mss2 X
msvideo1 X
mszh X
mts2 X
mvc1 X
mvc2 X
mxpeg X
nellymoser X
nuv X
paf_audio X
paf_video X
pam X
pbm X
pcm_bluray X
pcm_dvd X
pcx X
pgm X
pgmyuv X
pictor X
ppm X
prores X
ptx X
qcelp X
qdm2 X
qdraw X
qpeg X
qtrle X
r10k X
ra_144 X
ra_288 X
ralf X
rl2 X
roq X
roq_dpcm X
rpza X
rscc X
rv10 X
rv20 X
rv30 X
rv40 X
s302m X
sanm X
screenpresso X
sdx2_dpcm X
sgi X
sgirle X
shorten X
sipr X
smc X
smvjpeg X
snow X
sol_dpcm X
sonic X
sp5x X
subviewer1 X
sunrast X
svq1 X
svq3 X
tak X
targa X
targa_y216 X
tdsc X
theora X
tiertexseqvideo X
tiff X
tmv X
truemotion1 X
truemotion2 X
truemotion2rt X
truespeech X
tscc X
tscc2 X
tta X
twinvq X
txd X
ulti X
utvideo X
vb X
vble X
vc1 X
vc1image X
vcr1 X
vmdaudio X
vmdvideo X
vmnc X
vp3 X
vp5 X
vp6 X
vp6a X
vp6f X
vp7 X
vp8 X
vp9 X
wavpack X
webp X
wmalossless X
wmapro X
wmav1 X
wmav2 X
wmavoice X
wmv1 X
wmv2 X
wmv3 X
wmv3image X
wnv1 X
xan_dpcm X
xan_wc3 X
xan_wc4 X
xbin X
xbm X
xface X
xma1 X
xma2 X
xwd X
yop X
zerocodec X
zlib X
zmbv X

Total Codecs: 284 (281 decoders, 3 encoders)

@jmighion
Copy link

Any interest in sharing what you have?
Would it be too much to expect online by default since the updater seems to inherently require internet access? It seems like the capability to fully download everything in a one-shot scenario for offline use is secondary and could come in a later iteration.

For avoiding the rate limiting, I would not be surprised by some added waits and / or retry later, where the script checks to see what's currently downloaded and just pick back up on the next run. Not sure though if each codec that ffmpeg list has a corresponding one from PMS. Sounds like it could/should, but maybe they don't feel the need to host or provide all options. Does the temp ban impact logins from plex.tv as well? If so, then I could easily see making an exponential backoff to not temporarily block users entirely in case they change something on their end.

TBH, I haven't ran into a scenario where I need this and it doesn't seem like many other are either. I'm just interested in making this option work for the sake of having a "more complete" package, even if it's first solution is bounded by rate limiting and being an explicit opt in with all the appropriate warnings.

@michealespinola
Copy link
Owner Author

michealespinola commented Sep 18, 2023

Any interest in sharing what you have

If there is a genuine interest/need to move forward with this, I'm willing to. The use-case is very slim though, but if you can have the codecs preloaded, it makes any new codec-based media playback not have to delay/wait for the codec to download. The amount of time you potentially save is miniscule if even measurable when you are online. I like the idea of building out a complete toolset for Plex-related tasks/etc, This script needs command-line arguments to make it portable, and a written procedure for how to use it. The use procedure is likely to be convoluted and confusing to most people.

Are you proficient with bash?

avoiding the rate limiting

The rate limiting isn't really an issue based on "normal" use from my last rounds of testing. You'd have to run the script 3+ times consecutively (IIRC) to trigger it. I'd otherwise rather not needlessly introduce wasted time per query if its not necessary. Downloading all of the codecs one-at-a-time is already time consuming (takes 15 minutes in my testing ). If you hit the 429, you have to wait for a 30 minute cooldown. I hit the rate limit during my initial development phases, so I wrote in a detection that stops the download when encountered. It could expanded for its own wait/retry loop, but for now it quits with a messages to wait 30 minutes before trying again. I'm not sure if I ever determined what Plex's rate limit police is, But the rate limit reset took 30 minutes when I last tested it.

each codec that ffmpeg list has a corresponding one from PMS

There isn't. And I haven't been able to figure out a programmatic way to compare, so the script has to try everything that ffmpeg lists.

Does the temp ban impact logins from plex.tv as well

I don't know. I never saw any issues/errors on my PMS when testing the script, but my login is cached.

I haven't ran into a scenario where I need this and it doesn't seem like many other are either

The only real use I can see for the script is for those that need to preload all codecs so they can operate completely offline. I mean, its still not a bad thing to do in case of network outages either (I have encountered this on newish installs as well as can force the issue in testing by deleting the contents of the codecs folder). But the likelihood of not already having the common codecs used by the majority of the media in your library is pretty slim.

[ahhh, this has reminded me of what my ideas/concepts where when I last worked on this 🤔]

So, this has got me thinking back to where I really left off on this project. I was working on a backup/restore function, so that if you rolled-back to an older version of PMS it would roll-back your codec set as well. Like my other scripts, this is all written to Plex on Synology-centric (full automated w/no manual options), but it can certainly be used with other environments if command-line arguments are incorporated. That's where I really left off.

That was a lot of rambling. Is any of this something you are still interested in? 😅

@michealespinola
Copy link
Owner Author

I was a bit confused at the current 15 minute runtime. It used to be longer- closer to 30 minutes. It looks like the current codec set has dropped to 213 (210 decoders, 3 encoders).

@jmighion
Copy link

I agree the use case is very slim. I found the idea fun and you bring up a good point that the amount of time you potentially save is minuscule.

I am proficient in bash and am sort of still interested, I just don't think I'll have as much time as I hope and would probably need a few iterations with you to make the bash script work as you intend. I like the rollback idea and can see how this would help in that scenario.

The biggest reason for asking to see what you currently have is to help in small ways as I have time, you know, the open source way. I wouldn't be surprised if others could chip in as well. It doesn't look like you keep a dev branch up though, so not sure if you'd be open to sharing incomplete work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion DSM7 Synology DSM 7 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants