Jellyfin Forum
Jellyfin Hardware Transcode Settings Apply - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions)
+--- Thread: Jellyfin Hardware Transcode Settings Apply (/t-jellyfin-hardware-transcode-settings-apply)



Jellyfin Hardware Transcode Settings Apply - Apollo0893 - 2024-12-03

I was wondering if anyone has any insight on this I am attempting to replicate the save button on the transcode settings screen.  The goal would be to be able to change the transcode method via a python or other console script that can be ran or run the equivalent *.js file on the back end in order to apply the changes without having to restart Jellyfin service.  When you hit the save button and confirm it will auto apply settings instantly without forcing a restart of the server application.  This is on the LinuxServer image running on Docker.


RE: Jellyfin Hardware Transcode Settings Apply - TheDreadPirate - 2024-12-03

Let's back up a bit. What is the goal of changing the transcode settings with a script? The transcodes settings are something you set one time, hopefully correctly, and probably never touch again.

How often are you changing settings and why?


RE: Jellyfin Hardware Transcode Settings Apply - Apollo0893 - 2024-12-03

Ideally they won't be changed much at all but I have am trying to set this up as failback so that I can change the setting if the transcode gets routed back to the local NAS due to some failure (Network or Hardware). Problem is the NAS uses VAAPI for hardware transcoding while my dedicated server has Nvidia capability and is quite a bit faster.


Edit : I have considered just doing a service/server restart after modifying the encoding.xml file with the correct profile but the inline apply would be seamless and not cause any interruption in playback (hopefully).


RE: Jellyfin Hardware Transcode Settings Apply - TheDreadPirate - 2024-12-03

Are you using rffmpeg or something? I don't see how else you would change the transcoding device on the fly.

Is Jellyfin running on the dedicated server with the Nvidia GPU? Or the NAS?


RE: Jellyfin Hardware Transcode Settings Apply - Apollo0893 - 2024-12-03

Correct this RFFMPEG on a remote host from the jellyfin server - everything is working transcode wise and I have it setup on a separate NAS share for transcoding off a solid state drive (shared paths) and Jellyfin is on the NAS (Intel - VAAPI).


RE: Jellyfin Hardware Transcode Settings Apply - TheDreadPirate - 2024-12-03

I believe this is the function called when you click save.

https://github.com/jellyfin/jellyfin-web/blob/master/src/components/playbackSettings/playbackSettings.js#L330

Line 351 is the initial entry point when you click save.

I'm not familiar enough with Jellyfin's code to assist beyond this.


RE: Jellyfin Hardware Transcode Settings Apply - Apollo0893 - 2024-12-03

thanks! For now I have it doing an update and restart if it's forced to switch back to local transcode (vaapi). I'll look a little further into the .js portion of running the script. I did try running it with nodejs from a console and although it ran it didn't appear to do anything.


RE: Jellyfin Hardware Transcode Settings Apply - qwerty12 - 2024-12-03

Python 3:

PHP Code:
import urllib.request
import json

URL 
f"http://127.0.0.1:8096/System/Configuration/encoding"
API_KEY "55869869e2cf4c3aafda6fbd551f88f1"

req urllib.request.Request(URLheaders={
    
"Accept""application/json",
    
"Authorization"f"MediaBrowser Token={API_KEY}",
})
with urllib.request.urlopen(reqtimeout=30) as response:
    
json_data json.load(response)

json_data["HardwareAccelerationType"] = "qsv"

req urllib.request.Request(URLheaders={
    
"Authorization"f"MediaBrowser Token={API_KEY}",
    
"Content-Type""application/json",
}, 
method="POST")
with urllib.request.urlopen(reqdata=json.dumps(json_data).encode(),timeout=30) as response:
    
pass 

Replace 127.0.0.1:8096 with your own Jellyfin host and port, and replace 55869869e2cf4c3aafda6fbd551f88f1 with your own Jellyfin API key (generate one from http://127.0.0.1:8096/web/index.html#/dashboard/keys).

This goes from whatever hardware acceleration method to QuickSync; to go from whatever to NVENC, change to json_data["HardwareAccelerationType"] = "nvenc"

I used my browser's developer tools to find the API endpoint. https://curlconverter.com is useful to churn the CURL command-lines your browser can generate into code for your favourite programming language.

You can access API docs from http://127.0.0.1:8096/api-docs/swagger/index.html
This is good information on the Authorization header in terms of Jellyfin: https://gist.github.com/nielsvanvelzen/ea047d9028f676185832e51ffaf12a6f
And https://jmshrv.com/posts/jellyfin-api/ makes for a good read too.

The Jellyfin project itself maintains SDKs for some languages if you prefer API wrappers: https://github.com/orgs/jellyfin/repositories?q=sdk+OR+apiclient
https://github.com/sj14/jellyfin-go is a nice option for Go.


RE: Jellyfin Hardware Transcode Settings Apply - Apollo0893 - 2024-12-04

Thanks! - That's perfect I might add this into a fork of RFFMPEG as I think it would be useful for anyone using it since often you don't have the transcode hardware. I think this could also be made to allow for various types of acceleration when utilizing multiple different remote hosts. I'll have to play around with it some though.