jellyfin / jellyfin-androidtv

Android TV Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.44k stars 414 forks source link

[Exoplayer] Real-time conversion of Dolby Vision Profile 7 to 8.1 #2807

Open Moxh3 opened 1 year ago

Moxh3 commented 1 year ago

Describe the feature you'd like

Most Android TV players do not support Dolby Vision Profile 7 (which is typically used on 4K UHD discs). However, a lot of them do support Profile 8.1.

It would be great for the client (or server) to use libdovi (https://github.com/quietvoid/dovi_tool/) to covert Profile 7 to 8.1 in real-time.

VampiricAlien commented 1 year ago

AI Bot said: Dolby Vision Profile 7 to 8.1 conversion is not a feature that is natively supported by the ExoPlayer library. Therefore, we will need to implement this functionality ourselves. To do this, we will need to use the Dolby Vision Metadata Parser library, which is a Java library that can be used to parse Dolby Vision metadata from video streams. We will also need to use the ExoPlayer library to play the video stream. Here is some sample code that demonstrates how to use these libraries to convert Dolby Vision Profile 7 to 8.1:

// Create a new instance of the Dolby Vision Metadata Parser
DolbyVisionMetadataParser dolbyVisionMetadataParser = new DolbyVisionMetadataParser();

// Parse the Dolby Vision metadata from the video stream
DolbyVisionMetadata dolbyVisionMetadata = dolbyVisionMetadataParser.parse(metadataBuffer);

// Check if the Dolby Vision profile is 7
if (dolbyVisionMetadata.getProfile() == DolbyVisionProfile.DV_PROFILE_7) {
    // Convert the Dolby Vision profile to 8.1
    dolbyVisionMetadata.setProfile(DolbyVisionProfile.DV_PROFILE_8_1);
}

// Create a new instance of the ExoPlayer
SimpleExoPlayer exoPlayer = new SimpleExoPlayer.Builder(context).build();

// Create a new instance of the MediaSource
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
        .createMediaSource(mediaItem);

// Set the Dolby Vision metadata on the MediaSource
mediaSource = new DolbyVisionMediaSource(mediaSource, dolbyVisionMetadata);

// Prepare the ExoPlayer with the MediaSource
exoPlayer.setMediaSource(mediaSource);
exoPlayer.prepare();

In this code, we first create a new instance of the Dolby Vision Metadata Parser and use it to parse the Dolby Vision metadata from the video stream. We then check if the Dolby Vision profile is 7 and, if it is, we convert it to 8.1. Next, we create a new instance of the ExoPlayer and a new instance of the MediaSource using the ProgressiveMediaSource.Factory. We then set the Dolby Vision metadata on the MediaSource using the DolbyVisionMediaSource class. Finally, we prepare the ExoPlayer with the MediaSource and start playing the video stream.


Given that the code base is moving away from java and this isn't supported in exoplayer, it may take sometime for this to happen, that's if there is demand for this (that's just my thoughts)

nielsvanvelzen commented 1 year ago

This so called "Dolby Vision Metadata Parser library" doesn't even exist. Don't trust ChatGPT answers without verifying everything it says.

rbjtech-github commented 1 year ago

I have used dovi_tool a lot and I'm not even sure this is technically possible in real-time ? The tool and all tools based on it are very sequential in their processing of the file... ?

Moxh3 commented 1 year ago

There are Kodi builds that use libdovi (the library) for real-time conversion. So yes, technically feasible. Dovi_tool uses libdovi.

https://aur.archlinux.org/packages/libdovi

rbjtech-github commented 1 year ago

There are Kodi builds that use libdovi (the library) for real-time conversion. So yes, technically feasible. Dovi_tool uses libdovi.

ok - I didn't know that - thanks for the info.