Jump to content

Tonemapping Filter Pull Request


gallileo

Recommended Posts

gallileo

Hi there,

 

I have played around a bit with HDR tonemapping filters for ffmpeg.

 

I was wondering if you would accept a PR that adds a tonemapping filter to the MediaEncoding part of Emby? (As an alpha option of course)

 

Or would you accept a PR / help with creating one, that allows plugins to change the ffmpeg parameters / add filters?

 

Kind regards,

 

Leo

Link to comment
Share on other sites

gallileo

Well as far as I can see, the part that generates the command line options for ffmpeg seems to be opensource here: https://github.com/MediaBrowser/Emby.Common/blob/master/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs?

 

I would like to add something like this as a filter (see the tonemap_opencl part):

 

ffmpeg -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device \opencl=ocl@va -hwaccel vaapi -hwaccel_device va -hwaccel_output_format \vaapi -i INPUT -filter_hw_device ocl -filter_complex \'[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1]; \[x1]hwmap=derive_device=vaapi:reverse=1' -c:v hevc_vaapi -profile 2 OUTPUT
This was taken from here: https://gist.github.com/Brainiarc7/4f831867f8e55d35cbcb527e15f9f116

 

From my testing this allows a hardware transcode at almost 2x speeds for full 4K blurays. And I am currently looking into speeding this up even more.

 

Ideally, (depends on how the options are integrated) one could even specify a different tonemapping filter (e.g. replace linear with hable, clip, etc.).

 

For the plugins, ideally, one could either override IMediaEncoding or EncodingHelper. This way, a plugin can specify custom parameters for ffmpeg, but this would probably need some more revamping.

Link to comment
Share on other sites

gallileo

@ I haven‘t yet looked at this in depth. I would imagine that we could use opencl anyways (just on the cpu), but I don‘t know.

 

@@Luke I would have an option to enable it. Then I would check that, as well as the color info from the media info that is already scanned into Emby (i.e. does it say bt2020).

Link to comment
Share on other sites

gallileo

@@Luke Depends. When using hardware transcoding, there does not seem to be any performance impact, since the limit is hardware transcoding itself.

 

However, I haven‘t tried a lot with hardware transcoding on different gpus or a cpu. I suspect it would not impact it that much though.

 

If software decoding is used, I have no idea. If the tonemapping is done without opencl, I only get around 3-4 fps. However, even with software decoding, the opencl filter should be usable. But I do not know whether the software or opencl filter will be limiting there.

Edited by gallileo
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...