Jellyfin Forum
Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Off Topic (https://forum.jellyfin.org/f-off-topic)
+--- Forum: General Discussion (https://forum.jellyfin.org/f-general-discussion)
+--- Thread: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) (/t-encoding-discussion-megathread-ffmpeg-handbrake-av1-etc)

Pages: 1 2 3 4 5 6 7 8 9 10 11


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - bitmap - 2023-10-31

You got it, specify the device since ffmpeg can't infer that anymore. By default I think it'll use the first card in line, which is your iGPU. If you don't have multiple drivers installed, you shouldn't need all of what's in there, but being specific never hurts.


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - bitmap - 2023-11-01

Okay, so I figured out there's a QSV tonemapping filter, which is used by Jellyfin as well. Use the first line of the code below to get the full output of the vpp_qsv filter, which includes quite a few other filter options. I have not tested to see if VPP tonemapping is more accurate, has costs to brightness or quality, etc... I do now know that the filter you're using above simply CLIPS the out-of-range colors, which is not the best application of tonemapping. You might want to consider hable or reinhard -- you can see here (https://ayosec.github.io/ffmpeg-filters-docs/6.0/Filters/Video/tonemap.html) brief information about the options for non-QSV tonemapping. You could also look at the defaults in Jellyfin to get an idea of what to use if you don't want to use the QSV version -- disable HWA and take a look at the recommended defaults for tonemapping.

There's also an OpenCL and straight VAAPI tonemapping option, so either of those might work for you as well. The QSV option is extremely simple...I think.

Code:
bitmap@server:testing$ ffmpeg -h filter=vpp_qsv
Filter vpp_qsv
  Quick Sync Video "VPP"
    Inputs:
       #0: default (video)
    Outputs:
       #0: default (video)
vpp_qsv AVOptions:
   procamp           <int>        ..FV....... Enable ProcAmp (from 0 to 1) (default 0)
   brightness        <float>      ..FV....... ProcAmp brightness (from -100 to 100) (default 0)
   w                 <string>     ..FV....... Output video width(0=input video width, -1=keep input video aspect) (default "cw")                                                                                                                            
   h                 <string>     ..FV....... Output video height(0=input video height, -1=keep input video aspect) (default "w*ch/cw")                                                                                                                      
   format            <string>     ..FV....... Output pixel format (default "same")                                                                                                                                                                                                                                                                        
   scale_mode        <int>        ..FV....... scaling & format conversion mode (mode compute(3), vd(4) and ve(5) are only available on some platforms) (from 0 to 5) (default auto)                                                                          
     auto            0            ..FV....... auto mode                                                                                                                                                                                                      
     low_power       1            ..FV....... low power mode                                                                                                                                                                                                
     hq              2            ..FV....... high quality mode                                                                                                                                                                                              
     compute         3            ..FV....... compute                                                                                                                                                                                                        
     vd              4            ..FV....... vd                                                                                                                                                                                                            
     ve              5            ..FV....... ve                                                                                                                                                                                                                                                                                                                                                                  
   out_range         <int>        ..FV....... Output color range (from 0 to 2) (default 0)                                                                                                                                                                  
     full            2            ..FV....... Full range                                                                                                                                                                                                    
     limited         1            ..FV....... Limited range
     jpeg            2            ..FV....... Full range
     mpeg            1            ..FV....... Limited range
     tv              1            ..FV....... Limited range
     pc              2            ..FV....... Full range
   out_color_matrix  <string>     ..FV....... Output color matrix coefficient set
   out_color_primaries <string>     ..FV....... Output color primaries
   out_color_transfer <string>     ..FV....... Output color transfer characteristics
   tonemap           <int>        ..FV....... Perform tonemapping (0=disable tonemapping, 1=perform tonemapping if the input has HDR metadata) (from 0 to 1) (default 0)

I left in the options that you might want to use like ProcAmp if you want to enhance the brightness (can also change saturation, hue), w/h in case you want to scale, format and scale_mode for additional flexibility, out_range in case you want to set this explicitly (should be Limited in nearly all cases), and out_color_X options so you can set these according to your tonemapping.


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - TheDreadPirate - 2023-11-01

I did notice some minor to moderate artifacting that I didn't notice initially.  Mostly in darker and brighter parts of a scene.  I'm wondering if this is related to using the clip option.  I wish I had some shorter content to test on.  I'll have to find some free HDR clips and experiment.

Edit: I found the tonemapping logic for Jellyfin.

https://github.com/jellyfin/jellyfin-ffmpeg/blob/627f1c8c3edae2d33cfc83df382afe832d7b22a1/libavfilter/vf_tonemap_opencl.c


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - bitmap - 2023-11-01

For a shorter clip, use time bound options for your current media. You can just encode a snippet with the seek option.


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - Deleted User - 2023-11-01

(2023-11-01, 04:04 PM)bitmap Wrote: For a shorter clip, use time bound options for your current media. You can just encode a snippet with the seek option.

yes, precisely what i do for tests

5 minute sample, starting at 5 minutes -ss 00:05:00 -t 00:05:00

you may also find something further in the video with higher motion rate which will affect an encode
- but know that -ss will in fact scan the frames up to that point to start time so too far into the video will take almost as long as a full encode anyway


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - TheDreadPirate - 2023-11-01

*groan* Not sure why I didn't think of that. I use -ss and -to when I am splitting episodes when they come off the disc as 1 file.


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - Deleted User - 2023-11-01

(2023-11-01, 04:31 PM)TheDreadPirate Wrote: *groan*  Not sure why I didn't think of that.  I use -ss and -to when I am splitting episodes when they come off the disc as 1 file.

usually happens when you stare at something too long, just need a 3rd party to refocus the issue at hand 👍


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - TheDreadPirate - 2023-11-12

I figured out some quirks with QSV with Arc. When you are using any video filters, you are required to specify a deinterlace parameter. Even if it is disabled (deinterlace=0).

Code:
-vf vpp_qsv=deinterlace=0:cw=1920:cx=0:w=1920:h=1080

I figured out the syntax for cropping, but how it works is different so still testing that.

I am super annoyed that I couldn't simply change "hevc_qsv" to "av1_qsv".

My backlog can be serviced with what I have now. But going to have to figure out tone mapping AGAIN. I think my scaling parameters will work as is, based on the documentation I read.


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - TheDreadPirate - 2023-11-12

@bitmap How does HDR and 10 bit color work with AV1?  I can't find documentation about AV1 profiles, like main vs main10 in HEVC.  One of my HDR10 test encodes appears to have automatically used 10 bit color without my having to specify that during the encode.  Does AV1 automatically do that?

   


RE: Encoding Discussion Megathread (ffmpeg, Handbrake, AV1, etc...) - bitmap - 2023-11-13

Depends on the encoder. If we're talking av1_qsv, I've found that currently only 8->8 and 10->10 works properly. Everything else gives me an error. So that's dependent upon source and is automatic. By default, if you're doing a one-for-encode without mapping anything, any necessary metadata should come over with the encode automatically and the doesn't appear to be a flag like with SVT-AV1.

So in my experience, it's almost automatic. When mapping streams, you need to ensure that you map the metadata correctly in most cases, which I'm still struggling with a bit. I haven't had a single AV1 encode with HDR fail, though without the metadata I have had encodes fail to play properly.

On profiles/levels: they don't work the same as HEVC. Profile should be main for nearly everything, as I think the next up is professional? Run ffmpeg -h encoder=av1_qsv for more details about what options are available. Note that a lot of things are broken at the moment.