jellyfin / jellyfin-kodi

Jellyfin Plugin for Kodi
https://jellyfin.org
GNU General Public License v3.0
815 stars 109 forks source link

Force transcoding any Format like h265 4k to h264 1080p #793

Open lunainvictum opened 3 years ago

lunainvictum commented 3 years ago

Hi Guys,

im really Sorry if im here wrong.

Im using the latest stable Version of Jellyfin Server and Jellyfin for Kodi.

Im using Hardware Transcoding too with a 1070ti i had lying around.

Everything works so far.

But i have only one Problem: I have some 4k Videos (vp9 for example) they work on Kodi on a rpi4 and some not (with the trick or workaround to reduce the bitrate to 10mps to force transcoding to 1080p).

But this isnt a proper solution. Because some Videos transcode to 10mbs, but the resolution didnt go down to 1080p. They stay at 4k (https://www.youtube.com/watch?v=mkggXE5e2yk for example i downloaded).

On a PC or Android or iOS device this isnt a problem, because there i have the option to force to transcode to 480p, 720p, 1080p or what ever.

In the logs there is no error. Everything works too. The Problem is on the Kodi/rpi4 side because the software im using (libreelec) cant playback 4k at the moment.

But i didnt need 4k on the rpi4 devices anyway.

So im asking, is there anyway a hidden option or so there i can force to transcode to 1080p on jellyfin?

Thanks.

Sry for my bad English. Im a old nativ german guy wich didnt learn english in the school :-)

ebb-earl-co commented 3 years ago

@lunainvictum at least from my reading and perusing the Jellyfin subreddit, I don't think that this is an option right now. The logic for transcoding is that the server tries the following:

  1. Direct play
  2. If that's not possible, change the container (e.g. mkv -> mp4) but leave the video and audio (and subtitle, possibly) alone
  3. If that's not sufficient, transcode the audio but leave the video alone
  4. If that's not sufficient, transcode audio and video

However, you say that there are no errors in the logs and everything works so... what is the issue here?

lunainvictum commented 3 years ago

Sry, but this didnt make sense. Because with every Client, Browser, iOS, Android and other except the Kodi one, have the feature to "force" transcoding.

For example in Android, you can choose resolution and mbps from 360p to 4k from 1mbps to 120mbps.

And i like to have the same on Kodi.

The issue is, that the rpi4 is simply to slow (or libreelec cant it) to play 4k Material, its stutters heavy. So i wanted to do the same like in any other client for jellyfin, to select 1080p for example.

i searched already the whole internet because of that. And a lot of guys suggest to reduce the bitrate in jellyfin for kodi self to so low, untils jellyfin sends a 1080p material. That works, for 80% of Videos. The other 20% stays at 4k, until i go further down like 5mbs.

But that isnt a proper solution.

ebb-earl-co commented 3 years ago

Ah, I see what you're saying: to force the selected quality definitely is a feature on clients. Sorry for that confusion.

I don't know of a way to get that other 20% to transcode 4K -> 1080p, unfortunately. On the other hand, there might be a way to get Kodi to use the Raspberry Pi's hardware encoding (can decode the H.265 codec at up to 4K, 60 frames per second as well as the H.264 codec at 1080p, 60 frames per second) to render without stuttering.

The issue is, that the rpi4 is simply to slow (or libreelec cant it) to play 4k Material, its stutters heavy.

The change notes for version 19 specify that the RPi4 can do hardware decoding for the codecs that I mentioned above which leads me to believe that Libreelec can play 4k media without a sweat, as long as it is encoded as H.265.

lunainvictum commented 3 years ago

Ah, I see what you're saying: to force the selected quality definitely is a feature on clients. Sorry for that confusion.

I don't know of a way to get that other 20% to transcode 4K -> 1080p, unfortunately. On the other hand, there might be a way to get Kodi to use the Raspberry Pi's hardware encoding (can decode the H.265 codec at up to 4K, 60 frames per second as well as the H.264 codec at 1080p, 60 frames per second) to render without stuttering.

The issue is, that the rpi4 is simply to slow (or libreelec cant it) to play 4k Material, its stutters heavy.

The change notes for version 19 specify that the RPi4 can do hardware decoding for the codecs that I mentioned above which leads me to believe that Libreelec can play 4k media without a sweat, as long as it is encoded as H.265.

Ok... But the new libreelec with new kodi wouldnt be released until it is stable and everything is working. that is possible next year because of the stupid driver support of the chips on the raspberry pi 4. i didnt understand anyway why the company wich builds the raspberry pi4 choose hardware/chips, where no driver exist for. community is already since release 2 years ago waiting for proper working driver...

I didnt know where i can make suggestion here on github for jellyfin, but for me it would be the easiest solution if in the admin panel under the option for transcoding, would exist three options:

1: Transcode everytime? yes/no 2: Wich resolution wanted? 360p/480p/720p/1080p/2160p 3: Transcode to wich codec? h264/h265

I could implement this with php. But i dont know the code of jellyfin and would take me months to study.

Because i already found out, that the jellyfin server simply builds his commandline for ffmpeg with variables (wich hardware encoder, what video, what to transcode exactly).

It would be a huge improvment for the user who didnt have a 4k display in possesion, but have 4k material.

Plz jellyfin gods, make this wish true! :-)

lunainvictum commented 3 years ago

here is a example:

https://pastebin.com/raw/5BbSz3iF

Why the Hell is jellyfin transcoding to h264 instead to h265? I have sound without stutters, but no video.

ebb-earl-co commented 3 years ago

I hear what you're saying, @lunainvictum. What I've seen others do is to transcode the 4K content to 1080p and then just have both files stored in different libraries. You'd then need to direct the client to the right library that has either the 4K version of 1080p version of the file.

In response to your pastebin, I see that it is transcoding using h264_nvenc which means that you have an NVIDIA graphics card that you are using. If it's older than a GTX 950, then the card doesn't support hevc_nvenc meaning that h264_nvenc would be the only option and you would not be able to decode the VP9 and encode with hevc_nvenc. In any case, looking at this line here gives us a clue:

Output #0, hls, to '/var/lib/jellyfin/transcodes/ccd0a0131cafd915477c81417ab3069e.m3u8':

The Jellyfin server is using HLS (the hls near the beginning of the line) to stream the video, and according to the specification, HLS sends H.264-encoded video so that is why Jellyfin is automatically converting to H.264 in this situation.

lunainvictum commented 3 years ago

Yeah, and it should transcode to h265.

Im using a Nvidia 1070ti as gpu. this gpu can transcode any format (execpt av1) to h265 without problem.

ebb-earl-co commented 3 years ago

@lunainvictum I'm sorry that I cannot be of more assistance; from what I know, if you are streaming your content and it's not direct play, then as far as I know, Jellyfin will convert it to H.264 in order to transport it to your client via HLS. You will have to get someone more knowledgeable to assist you :disappointed:

lunainvictum commented 3 years ago

no problem. HLS didnt play a role. Because i tried already with and without hls. and many other options and combinations.

The only "solution" until now, is simply to set the bitrate in the kodi addon below or equal 10mbps. And if sometimes a video occurs that is still 4k, to reduce the bitrate even lower as 10mbps only for that video.

Hooloovoo commented 3 years ago

I also have a raspberry pi 4 acting as front-end to a backend that is good at hardware transcoding.

While the Raspberry Pi 4 can decode 1080p h.264 and 4k h.265 in hardware, it is not capable of playing 4k VP9 (and presumably other formats) in real time.

One of the things I love about Jellyfin is that I can throw all my media at it and not worry about codec support. I would therefore also like to manually set what the client can cope with Direct Playing (by both codec and resolution) and have Jellyfin transcode anything else.

From my testing, the Raspberry Pi 4 can cope with up to 1080p in vp9 even without hardware acceleration.

bzzbrr commented 2 years ago

The only "solution" until now, is simply to set the bitrate in the kodi addon below or equal 10mbps. And if sometimes a video occurs that is still 4k, to reduce the bitrate even lower as 10mbps only for that video.

In the Jellyfin for Kodi addon there is an option to force transcode VP9 (add-on settings->playback). It won't change the resolution, but an rpi4 should be able to play 4k h264. @Hooloovoo as well, if you're using or willing to use kodi.

Hooloovoo commented 2 years ago

In the Jellyfin for Kodi addon there is an option to force transcode VP9 (add-on settings->playback). It won't change the resolution, but an rpi4 should be able to play 4k h264. @Hooloovoo as well, if you're using or willing to use kodi.

Thanks for the response, @bzzbrr. I actually gave up fighting the RPi in the end and just bought a Roku Streaming Stick+. It was a great decision for my limited front-end use case -- half the price, no more fighting Widevine issues and all the rest to play the streaming services and the Roku Jellyfin app works better than I could get Jellyfin working on the RPi. (Obviously Roku is not open source, though.)

abc123me commented 1 year ago

I would like to post here to hopefully bump the issue, I have some older devices which I need to be able to watch Jellyfin on, unfortunately they cannot handle a 1080P HEVC, VP9, or AV1 stream. However they can handle a 1080p H264 stream fine, I've noticed some video files get transcoded due to incompatible subtitles however I am hoping there would be a way I can force all files viewed by the user to only play in H264 format. I am a luddite and will not even consider upgrading my Thinkpad T430 so that is not an option. I am running the TrueNAS Application form of Jellyfin (docker) on a Dell PE R720XD with infinite bandwidth and compute so neither of those are of any concern to me. I also am a decent programmer so if anyone has any pointers that could help me implement the feature myself that would be great!

jellyfin-bot commented 9 months ago

This issue has gone 120 days without an update and will be closed within 21 days if there is no new activity. To prevent this issue from being closed, please confirm the issue has not already been fixed by providing updated examples or logs.

If you have any questions you can use one of several ways to contact us.