VideoHelp Forum
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 31
Thread
  1. Which is the max compression settings for hevc_nvenc lossless (NVIDIA H.265 HEVC LOSSLESS)? Can anubody write ffmpeg comand for that?
    Quote Quote  
  2. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Lossless compression is the opposite of "max. compression"; efficient compression is achieved by allowing a certain degree of loss.

    The compression ratio of lossless algorithms can't be tuned for a great range of speed vs. efficiency; if there are at all any options to change the behaviour, variation in results will be small.

    Depending on the video material (complexity and similarity), lossless compression ratios may typically be between 2:1 and 5:1 in relation to uncompressed YUV; lossy HEVC compression can achieve about 1000:1.
    Last edited by LigH.de; 16th Jan 2018 at 02:30.
    Quote Quote  
  3. Enabling SAP can emprove lossless compression. Do you know ffmpeg command for that?
    Quote Quote  
  4. Originally Posted by qo4on View Post
    Enabling SAP can emprove lossless compression. Do you know ffmpeg command for that?
    Did you read the paper? Are you sure that NVidia implemented this? Are you sure that libx265 (ffmpeg use libx265 fot h.265 encode) implemented this?
    Quote Quote  
  5. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    This paper proposed an improved SAP (Sample-based Angular Prediction) algorithm based on adaptive directional prediction (ADSAP).
    It describes a theory how encoding could be improved. Whether this has been implemented in practice yet, is unknown, though...
    Quote Quote  
  6. May be you are right. But I still can't find any information about using nvenc hevc through ffmpeg. Can you suggest anything to read about that?
    Last edited by qo4on; 16th Jan 2018 at 14:46.
    Quote Quote  
  7. Originally Posted by qo4on View Post
    May be you are right. But I still can't find any information about using nvenc hevc through ffmpeg. Can you suggest anything to read about that?
    The best information (the latest & usually most accurate) is from ffmpeg itself.
    Open a command prompt and enter the following command:
    Code:
    ffmpeg -h encoder=hevc_nvenc
    (protip: you can copy this text and paste it to the command window)

    To save the information to a file (which is what I prefer), enter this command instead:
    Code:
    ffmpeg -h encoder=hevc_nvenc >ffmpeg-help-hevc_nvenc.txt
    EDIT if Windows says it can't find ffmpeg, you need to navigate to the directory where ffmpeg.exe was installed.

    Here is the result. The way I read this, the only option for lossless NVENC that makes any difference is choosing between -preset lossless and -preset losslesshp.
    Code:
    Encoder hevc_nvenc [NVIDIA NVENC hevc encoder]:
        General capabilities: delay 
        Threading capabilities: none
        Supported pixel formats: yuv420p nv12 p010le yuv444p yuv444p16le bgr0 rgb0
    hevc_nvenc AVOptions:
      -preset            <int>        E..V.... Set the encoding preset (from 0 to 11) (default medium)
         default                      E..V.... 
         slow                         E..V.... hq 2 passes
         medium                       E..V.... hq 1 pass
         fast                         E..V.... hp 1 pass
         hp                           E..V.... 
         hq                           E..V.... 
         bd                           E..V.... 
         ll                           E..V.... low latency
         llhq                         E..V.... low latency hq
         llhp                         E..V.... low latency hp
         lossless                     E..V.... lossless
         losslesshp                   E..V.... lossless hp
      -profile           <int>        E..V.... Set the encoding profile (from 0 to 4) (default main)
         main                         E..V.... 
         main10                       E..V.... 
         rext                         E..V.... 
      -level             <int>        E..V.... Set the encoding level restriction (from 0 to 186) (default auto)
         auto                         E..V.... 
         1                            E..V.... 
         1.0                          E..V.... 
         2                            E..V.... 
         2.0                          E..V.... 
         2.1                          E..V.... 
         3                            E..V.... 
         3.0                          E..V.... 
         3.1                          E..V.... 
         4                            E..V.... 
         4.0                          E..V.... 
         4.1                          E..V.... 
         5                            E..V.... 
         5.0                          E..V.... 
         5.1                          E..V.... 
         5.2                          E..V.... 
         6                            E..V.... 
         6.0                          E..V.... 
         6.1                          E..V.... 
         6.2                          E..V.... 
      -tier              <int>        E..V.... Set the encoding tier (from 0 to 1) (default main)
         main                         E..V.... 
         high                         E..V.... 
      -rc                <int>        E..V.... Override the preset rate-control (from -1 to INT_MAX) (default -1)
         constqp                      E..V.... Constant QP mode
         vbr                          E..V.... Variable bitrate mode
         cbr                          E..V.... Constant bitrate mode
         vbr_minqp                    E..V.... Variable bitrate mode with MinQP
         ll_2pass_quality              E..V.... Multi-pass optimized for image quality (only for low-latency presets)
         ll_2pass_size                E..V.... Multi-pass optimized for constant frame size (only for low-latency presets)
         vbr_2pass                    E..V.... Multi-pass variable bitrate mode
      -rc-lookahead      <int>        E..V.... Number of frames to look ahead for rate-control (from -1 to INT_MAX) (default -1)
      -surfaces          <int>        E..V.... Number of concurrent surfaces (from 0 to INT_MAX) (default 32)
      -cbr               <boolean>    E..V.... Use cbr encoding mode (default false)
      -2pass             <boolean>    E..V.... Use 2pass encoding mode (default auto)
      -gpu               <int>        E..V.... Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on. (from -2 to INT_MAX) (default any)
         any                          E..V.... Pick the first device available
         list                         E..V.... List the available devices
      -delay             <int>        E..V.... Delay frame output by the given amount of frames (from 0 to INT_MAX) (default INT_MAX)
      -no-scenecut       <boolean>    E..V.... When lookahead is enabled, set this to 1 to disable adaptive I-frame insertion at scene cuts (default false)
      -forced-idr        <boolean>    E..V.... If forcing keyframes, force them as IDR frames. (default auto)
      -spatial_aq        <boolean>    E..V.... set to 1 to enable Spatial AQ (default false)
      -temporal_aq       <boolean>    E..V.... set to 1 to enable Temporal AQ (default false)
      -zerolatency       <boolean>    E..V.... Set 1 to indicate zero latency operation (no reordering delay) (default false)
      -nonref_p          <boolean>    E..V.... Set this to 1 to enable automatic insertion of non-reference P-frames (default false)
      -strict_gop        <boolean>    E..V.... Set 1 to minimize GOP-to-GOP rate fluctuations (default false)
      -aq-strength       <int>        E..V.... When Spatial AQ is enabled, this field is used to specify AQ strength. AQ strength scale is from 1 (low) - 15 (aggressive) (from 1 to 15) (default 8)
      -cq                <int>        E..V.... Set target quality level (0 to 51, 0 means automatic) for constant quality mode in VBR rate control (from 0 to 51) (default 0)
    Last edited by raffriff42; 16th Jan 2018 at 23:57.
    Quote Quote  
  8. Thank you! But I've already read this list. It doesn't answer to a lot of questions: what is the difference between lossless and lossleshp, which other options I can use with lossless, how to setup rec709 full and limited range?
    Quote Quote  
  9. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Originally Posted by qo4on View Post
    what is the difference between lossless and lossleshp,
    According to a thread in the phoronix forum (especially post 30), "hp" means "high performance", which must mean that speed is preferred over quality, so it's probably using only simple prediction algorithms.

    Originally Posted by qo4on View Post
    which other options I can use with lossless,
    Rather looking from the opposite angle: If it is supposed to limit the quantization or elements only used in lossy compression (DCT/IT, CU/CTU, partitions), then it will probably not affect lossless compression. But going into details would require some insight in HEVC as a whole.

    Wikipedia about Nvidia NVEnc mentions a "HP444" profile, means, there are specifications about complexity limits to ensure fast decoding on supporting hardware.

    Originally Posted by qo4on View Post
    how to setup rec709 full and limited range?
    If a technique is valid for several encoders, it is often exposed as general ffmpeg option instead of encoder-specific parameters. Check the ffmpeg "full help" too.
    Quote Quote  
  10. Originally Posted by LigH.de View Post
    If a technique is valid for several encoders, it is often exposed as general ffmpeg option instead of encoder-specific parameters. Check the ffmpeg "full help" too.
    I've found colorspace settings for libx264 -x264opts. But it doesn't work for nvenc hevc.
    Quote Quote  
  11. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Generic ffmpeg options valid for more or less all encoders:

    Code:
    AVCodecContext AVOptions:
    ...
      -color_primaries   <int>        ED.V.... color primaries (from 1 to INT_MAX) (default unknown)
         bt709                        ED.V.... BT.709
         unknown                      ED.V.... Unspecified
         bt470m                       ED.V.... BT.470 M
         bt470bg                      ED.V.... BT.470 BG
         smpte170m                    ED.V.... SMPTE 170 M
         smpte240m                    ED.V.... SMPTE 240 M
         film                         ED.V.... Film
         bt2020                       ED.V.... BT.2020
         smpte428                     ED.V.... SMPTE 428-1
         smpte428_1                   ED.V.... SMPTE 428-1
         smpte431                     ED.V.... SMPTE 431-2
         smpte432                     ED.V.... SMPTE 422-1
         jedec-p22                    ED.V.... JEDEC P22
         unspecified                  ED.V.... Unspecified
      -color_trc         <int>        ED.V.... color transfer characteristics (from 1 to INT_MAX) (default unknown)
         bt709                        ED.V.... BT.709
         unknown                      ED.V.... Unspecified
         gamma22                      ED.V.... BT.470 M
         gamma28                      ED.V.... BT.470 BG
         smpte170m                    ED.V.... SMPTE 170 M
         smpte240m                    ED.V.... SMPTE 240 M
         linear                       ED.V.... Linear
         log100                       ED.V.... Log
         log316                       ED.V.... Log square root
         iec61966-2-4                 ED.V.... IEC 61966-2-4
         bt1361e                      ED.V.... BT.1361
         iec61966-2-1                 ED.V.... IEC 61966-2-1
         bt2020-10                    ED.V.... BT.2020 - 10 bit
         bt2020-12                    ED.V.... BT.2020 - 12 bit
         smpte2084                    ED.V.... SMPTE 2084
         smpte428                     ED.V.... SMPTE 428-1
         arib-std-b67                 ED.V.... ARIB STD-B67
         unspecified                  ED.V.... Unspecified
         log                          ED.V.... Log
         log_sqrt                     ED.V.... Log square root
         iec61966_2_4                 ED.V.... IEC 61966-2-4
         bt1361                       ED.V.... BT.1361
         iec61966_2_1                 ED.V.... IEC 61966-2-1
         bt2020_10bit                 ED.V.... BT.2020 - 10 bit
         bt2020_12bit                 ED.V.... BT.2020 - 12 bit
         smpte428_1                   ED.V.... SMPTE 428-1
      -colorspace        <int>        ED.V.... color space (from 0 to INT_MAX) (default unknown)
         rgb                          ED.V.... RGB
         bt709                        ED.V.... BT.709
         unknown                      ED.V.... Unspecified
         fcc                          ED.V.... FCC
         bt470bg                      ED.V.... BT.470 BG
         smpte170m                    ED.V.... SMPTE 170 M
         smpte240m                    ED.V.... SMPTE 240 M
         ycgco                        ED.V.... YCGCO
         bt2020nc                     ED.V.... BT.2020 NCL
         bt2020c                      ED.V.... BT.2020 CL
         smpte2085                    ED.V.... SMPTE 2085
         unspecified                  ED.V.... Unspecified
         ycocg                        ED.V.... YCGCO
         bt2020_ncl                   ED.V.... BT.2020 NCL
         bt2020_cl                    ED.V.... BT.2020 CL
      -color_range       <int>        ED.V.... color range (from 0 to INT_MAX) (default unknown)
         unknown                      ED.V.... Unspecified
         tv                           ED.V.... MPEG (219*2^(n-8))
         pc                           ED.V.... JPEG (2^n-1)
         unspecified                  ED.V.... Unspecified
         mpeg                         ED.V.... MPEG (219*2^(n-8))
         jpeg                         ED.V.... JPEG (2^n-1)
    But whether the flags are correctly included in either the encoded video bitstream or (if applicable) in the container, is a whole different topic. If an encoder does not care about colorimetry and does not write matching flags, results may look surprising. Here I have no practical experience, though. Another user may know more than me.
    Quote Quote  
  12. Originally Posted by qo4on View Post
    Which is the max compression settings for hevc_nvenc lossless (NVIDIA H.265 HEVC LOSSLESS)? Can anubody write ffmpeg comand for that?
    If only someone, somewhere, had done an NVENC Lossless test, using ffmpeg, and posted the results:

    https://forum.videohelp.com/threads/382367-X265-Lossless-not-really-lossless-and-I-can-prove-it
    Quote Quote  
  13. Thank you.
    But I still can't get a real lossless. I took an 8-bit clip 4:2:0 mp4, encoded it to h.265:
    ffmpeg -vsync 0 -r 60 -c:v h264_cuvid -i "in.mp4" -c:v hevc_nvenc -preset lossless "out.mp4"
    In PP I see the same colors, but there is an outline at the bright colored edges in layer difference mode. Any idea why does this happen?
    Image
    [Attachment 44433 - Click to enlarge]
    Last edited by qo4on; 18th Jan 2018 at 12:38.
    Quote Quote  
  14. Nobody knows why it is not lossless?
    Quote Quote  
  15. Member Bernix's Avatar
    Join Date
    Apr 2016
    Location
    Europe
    Search Comp PM
    It seems to me similar to some subsampling conversion difference. Don't know why, but when tested 4:4:4 and 4:2:2 or 4:2:0 I get similar difference. So probably some internal conversion, probably made by colorspace conversion. Problem can be also software playback settings you are using. But most probably your source is BT601 and Hevc is most probably BT709

    Edit: Can you post text form of mediainfo for both files?

    Bernix
    Last edited by Bernix; 20th Jan 2018 at 06:33. Reason: Edit
    Quote Quote  
  16. It's a premiere decoding bug. It doesn't support lossless hevc profile decoding. It's lossless in other programs/decoders

    But AVC lossless is decoding correctly in newer PP versions
    Quote Quote  
  17. Originally Posted by poisondeathray View Post
    It's a premiere decoding bug.
    It looks like you're right. In which program i will see 0 difference at hevc lossless sources?
    Quote Quote  
  18. Member Bernix's Avatar
    Join Date
    Apr 2016
    Location
    Europe
    Search Comp PM
    Hi,
    I believe you can use for this Avisynth (probably possible to feed it with this codecs), but don't want script from me, probably some will post it, but not 100% sure about avisynth and Hevc.

    Bernix
    Quote Quote  
  19. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    The usual AviSynth based converters (e.g. MeGUI, StaxRip, ...) will help you creating a script using FFMS2 or L-SMASH Works as source plugins; their current libavcodec implementation should be able to read lossless HEVC.
    Quote Quote  
  20. Do you know is this command 100% guarantee that files are completely lossless? ffmpeg -i -i -lavfi "ssim;[0:v][1:v]psnr" -f null –
    If it returns "1" and "inf".
    Quote Quote  
  21. Originally Posted by qo4on View Post
    Do you know is this command 100% guarantee that files are completely lossless? ffmpeg -i -i -lavfi "ssim;[0:v][1:v]psnr" -f null –
    If it returns "1" and "inf".
    Yes , but only for that sample test .

    But this is not definitive proof that something else is lossless with the same workflow without additional testing . For example, what if the workflow (not necessarily the encoder) clipped "superbright" data? But your test source didn't include that data to test in the first place.
    Quote Quote  
  22. I also found out that all tested lossless files were strongly different by compression. The same clip was encoded to various lossless formats:

    libx264 - 150 KB (very good, but encoding was 100 times longer than nvenc)
    libx265 - 757 KB
    nvenc_h264 - 2 472 KB
    nvenc_hevc lossless - 634 KB
    nvenc_hevc lossless_hp - 634 KB

    Is there anything I can tweak to improve compression in nvenc lossless?
    Quote Quote  
  23. Member Bernix's Avatar
    Join Date
    Apr 2016
    Location
    Europe
    Search Comp PM
    Seems to me be weird lossless 265 is bigger, probably something is wrong, or it is not already tuned (doubt). libx265 is also bigger than any NVENC Hevc lossless, something must be wrong definitely.

    Bernix
    Quote Quote  
  24. You can tweak the settings for libx265 and libx264 to make it more compressed /less compressed, or encode faster/slower (--preset ultrafast will still be slower than NVEnc), or decode faster/slower by using the presets and/or adjusting GOP length . Often the issue is decoding speed, if it's meant to be used in an editor (--tune fastdecode --keyint 1). Very sluggish for usage, almost unusable it "feels" so slow. Often you want I-frame or at least short GOPs and faster decoding (so it's faster to edit on the timeline) . Or if it's meant for storage , then you can tweak it for higher compression

    For NVEnc, not sure I haven't used it much for lossless but you might be able to influence the compression slightly by adjusting GOP length . In NVEncC, there is a --preset quality mode separate from the --lossless switch , but I haven't tested it. It's slightly different than ffmpeg NVEnc
    Quote Quote  
  25. Originally Posted by qo4on View Post
    I also found out that all tested lossless files were strongly different by compression. The same clip was encoded to various lossless formats:

    libx264 - 150 KB (very good, but encoding was 100 times longer than nvenc)
    libx265 - 757 KB
    nvenc_h264 - 2 472 KB
    nvenc_hevc lossless - 634 KB
    nvenc_hevc lossless_hp - 634 KB

    Is there anything I can tweak to improve compression in nvenc lossless?

    You should also test longer duration input files. A large part of these codecs compression ability (especially over traditional I-frame lossless codecs) is based on temporal compression. That is not tested here much based on those filesizes . For example if your max GOP length was say 60 , you would not see any effect of increasing the value if your test video was already shorter than 60 frames. I don't know what the defaults are for NVEnc HEVC, but in ffmpeg -g is the switch for max GOP length
    Quote Quote  
  26. Member Bernix's Avatar
    Join Date
    Apr 2016
    Location
    Europe
    Search Comp PM
    O.k. so x265 is less effective in lossless, why then they do not use x264 for lossless when it is faster and more effective?

    Bernix
    Quote Quote  
  27. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    A ratio 1:5 for lossless x264 vs. x265 is rather confusing than impressive. This may be a failure as well as heavily depending on the material, yet. Until confirmed by someone else with the same original material or a completely different one.
    Quote Quote  
  28. Member Bernix's Avatar
    Join Date
    Apr 2016
    Location
    Europe
    Search Comp PM
    I found on internet This:

    Image
    [Attachment 44480 - Click to enlarge]


    It seems to me done properly, but I can only guess. Check speed and size... In this case (lossless) encoding, x265 can benefit from x264 codec as special case
    I know it is hardly possible.

    Bernix
    Last edited by Bernix; 23rd Jan 2018 at 13:26. Reason: picture instead of text
    Quote Quote  
  29. Some quick tests for x264/x264/ff nvenc h264

    1920x1080 4:2:0 2582frames , outdoor scene, low motion, several crossfades, high quality src

    default settings for lossless
    x264 2.06GB
    x265 2.11GB
    ffmpeg nvenc h264 2.62GB

    x264 lossless doesn't use b-frames, but x265 does. NVEnc hevc doesn't use b-frames at all for lossy or lossless mode, but I can't test it here on this GPU
    Quote Quote  
  30. Member Bernix's Avatar
    Join Date
    Apr 2016
    Location
    Europe
    Search Comp PM
    Hi poisondeathray,
    time is also very important, and I belive x264 was 5 times faster. Just guess.

    Edit: so conclusion?
    a) using b-frames in lossless mode is bad idea (b-frames are smallest) but it doesn't results in smallest filesize. And time is several times longer then x264 lossless (same output results pixel by pixel)
    b) using b-frames are worth of bigger filesize and slower speed (for some to me unknown reason)

    I know x265 is more aggressive during encoding, so probably harder to achieve lossless, probably using only P-frames will not help (for almost sure)
    So not use x265 don't know how other codecs of h265 format, probably all h265 codecs for lossless compression.

    But on I-frames only lossless compression x265 must win in smallest file from them all. And lossless I-frames only is also best for editing.

    Correct me if I'm wrong. I will correct this post with pleasure.

    Bernix
    Last edited by Bernix; 24th Jan 2018 at 03:48. Reason: Edit
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!