Opened 19 months ago

Closed 8 days ago

Last modified 8 days ago

#7654 closed defect (fixed)

hevc_amf does not honor -level option

Reported by: Tupsi Owned by:
Priority: minor Component: avcodec
Version: git-master Keywords: amf
Cc: cornofear@yahoo.ca, cus Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

% ffmpeg -i input.mkv -c:v hevc_amf -quality quality -level 50 -c:s copy -c:a copy output.mkv

ffmpeg version N-92917-gb9523f2fd3 Copyright (c) 2000-2019 the 
FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181201
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt

the resulting .mkv still has

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L6.2@Main
Codec ID                                 : V_MPEGH/ISO/HEVC

show with ffprobe. 6.2 seems to be the auto level which currently is the highest. I tried all sorts of integer but it always ends in the same.

ffmpeg -h encoder=hevc_amf shows the following about level

  -level             <int>        E..V..... Set the encoding level (default auto) (from 0 to 186) (default auto)
     auto                         E..V.....
     1.0                          E..V.....
     2.0                          E..V.....
     2.1                          E..V.....
     3.0                          E..V.....
     3.1                          E..V.....
     4.0                          E..V.....
     4.1                          E..V.....
     5.0                          E..V.....
     5.1                          E..V.....
     5.2                          E..V.....
     6.0                          E..V.....
     6.1                          E..V.....
     6.2                          E..V.....

so I even tried numbers like 50 in the hopes it means "5.1", as I do not understand how the 14 current options listed above are represented by integer number between 0 und 186 (which says so in the help). I tried both left the labels 5.0, 5.1, 4.0, even 1.0 as well as differnt integer numbers in between 0 and 186. Everything ends in Main@L6.2

Attachments (1)

err.txt (1.1 MB) - added by Tupsi 18 months ago.

Download all attachments as: .zip

Change History (19)

comment:1 Changed 19 months ago by Tupsi

I manged to catch a glimpse of the error with -loglevel trace (I hope, no clue about C sorry)

[AVFilterGraph @ 000001561e8dcb80] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[hevc_amf @ 000001561e500380] AMFDeviceDX11Impl: 2019-01-04 18:59:02.231     1E58 [AMFDeviceDX11Impl]   Debug: InitDX11() created HW DX11.1 device
[hevc_amf @ 000001561e500380] AMFDeviceDX11Impl: 2019-01-04 18:59:03.117     1E58 [AMFDeviceDX11Impl]   Debug: InitDX11() created HW DX11 device
[hevc_amf @ 000001561e500380] AMF initialisation succeeded via D3D11.
[hevc_amf @ 000001561e500380] EncoderUVEHEVCImpl: 2019-01-04 18:59:03.133     1E58 [EncoderUVEHEVCImpl]    Info: SetProperty HevcUsage:0
[hevc_amf @ 000001561e500380] EncoderUVEHEVCImpl: 2019-01-04 18:59:03.133     1E58 [EncoderUVEHEVCImpl]    Info: SetProperty HevcFrameSize:1916,1076
[hevc_amf @ 000001561e500380] EncoderUVEHEVCImpl: 2019-01-04 18:59:03.134     1E58 [EncoderUVEHEVCImpl]    Info: SetProperty HevcFrameRate:24000,1001
[hevc_amf @ 000001561e500380] EncoderUVEHEVCImpl: 2019-01-04 18:59:03.134     1E58 [EncoderUVEHEVCImpl]    Info: SetProperty HevcProfile:1
[hevc_amf @ 000001561e500380] EncoderUVEHEVCImpl: 2019-01-04 18:59:03.134     1E58 [EncoderUVEHEVCImpl]    Info: SetProperty HevcTier:1
[hevc_amf @ 000001561e500380] EncoderUVEHEVCImpl: 2019-01-04 18:59:03.134     1E58 [EncoderUVEHEVCImpl]    Info: SetProperty HevcProfileLevel:-99
[hevc_amf @ 000001561e500380] PropertyStorageExImpl: 2019-01-04 18:59:03.135     1E58 [PropertyStorageExImpl]   Error: c:\constructicon\builds\gfx\six\18.50\drivers\amf\stable\public/common/PropertyStorageExImpl.h(286):AMF_ERROR 4 : AMF_INVALID_ARG: Property=HevcProfileLevel
[hevc_amf @ 000001561e500380] EncoderUVEHEVCImpl: 2019-01-04 18:59:03.135     1E58 [EncoderUVEHEVCImpl] Warning: SetProperty HevcProfileLevel failed in AMFPropertyStorageExImpl with return code:0x4, and will not set driver either, but return ok for now!
[hevc_amf @ 000001561e500380] EncoderUVEHEVCImpl: 2019-01-04 18:59:03.135     1E58 [EncoderUVEHEVCImpl]    Info: SetProperty HevcQualityPreset:0

you see there, that the encoder wants the profile_level set to -99 (while I tried 5.0 and then 186). Whatever you enter after -level gives you -99 here and the error afterwards.

From what it looks like, my current driver does not support the profile_level option any more?

hope that helps in the bug hunting.

comment:2 Changed 19 months ago by Tupsi

  • Component changed from ffmpeg to avcodec

comment:3 Changed 19 months ago by cehoyos

  • Keywords amf added; hevc_amf level removed
  • Priority changed from normal to minor

Please provide your (simplified) command line together with the complete, uncut console output to make this a valid ticket.

Changed 18 months ago by Tupsi

comment:4 Changed 18 months ago by Tupsi

added debug log as attachment.

simplified commandline is:

ffmpeg.exe -i .\input.mkv -c:v hevc_amf -level:v 5.0 output.mkv

comment:5 follow-up: Changed 9 months ago by lolmaster5000

  • Keywords hevc_amf added
  • Priority changed from minor to normal

I have the same issue, developers should have a look at the following example:
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/public/samples/CPPSamples/common/EncoderParamsHEVC.cpp

The integer values for the levels are

AMF_LEVEL_1 = 30,
AMF_LEVEL_2 = 60,
AMF_LEVEL_2_1 = 63,
AMF_LEVEL_3 = 90,
AMF_LEVEL_3_1 = 93,
AMF_LEVEL_4 = 120,
AMF_LEVEL_4_1 = 123,
AMF_LEVEL_5 = 150,
AMF_LEVEL_5_1 = 153,
AMF_LEVEL_5_2 = 156,
AMF_LEVEL_6 = 180,
AMF_LEVEL_6_1 = 183,
AMF_LEVEL_6_2 = 186

Furthermore the encoded file is badly seekable and the following parameter is needed as well:
-gops_per_idr 1
This should be standard.

comment:6 Changed 9 months ago by cehoyos

  • Keywords hevc_amf removed
  • Priority changed from normal to minor

comment:7 Changed 8 months ago by Adrianwo

  • Priority changed from minor to critical

The problem is still unresolved, so I changed priority to critical for better response. Similar problem appears in hevc_nvenc encoder - there are fixed level 5.1: https://www.voukoder.org/forum/thread/407-profile-level-option-not-work-on-amf-hevc/?postID=2549#post2549

comment:8 Changed 8 months ago by cehoyos

  • Priority changed from critical to minor

comment:9 in reply to: ↑ 5 Changed 7 months ago by Tupsi

Replying to lolmaster5000:

I have the same issue, developers should have a look at the following example:
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/public/samples/CPPSamples/common/EncoderParamsHEVC.cpp

The integer values for the levels are

AMF_LEVEL_1 = 30,
AMF_LEVEL_2 = 60,
AMF_LEVEL_2_1 = 63,
AMF_LEVEL_3 = 90,
AMF_LEVEL_3_1 = 93,
AMF_LEVEL_4 = 120,
AMF_LEVEL_4_1 = 123,
AMF_LEVEL_5 = 150,
AMF_LEVEL_5_1 = 153,
AMF_LEVEL_5_2 = 156,
AMF_LEVEL_6 = 180,
AMF_LEVEL_6_1 = 183,
AMF_LEVEL_6_2 = 186

Furthermore the encoded file is badly seekable and the following parameter is needed as well:
-gops_per_idr 1
This should be standard.

I noticed that the ffmpeg file reports the correct level:int numbers at least, but it seems the whole -level:v is completly ignored if you try to use it and so always 6.2 is used (as I doubt somehow the default "auto" is actually working), because I just tried to encode an ancient dvd at its still sitting at 6.2.

With your gops_per_idr note I totally agree. The file is not usuable with the default, which is 60.

comment:10 Changed 6 months ago by Adrianwo

  • Priority changed from minor to important

Still nothing changed.

I checked, and AMF HEVC encoder in HandBrake? works much better and all options are being passed. So here we have an unrelated library from that in FFmpeg. The problem, of course, is in FFmpeg itself.

Last edited 6 months ago by Adrianwo (previous) (diff)

comment:11 Changed 6 months ago by cehoyos

  • Priority changed from important to minor

comment:12 Changed 7 weeks ago by cornofear

  • Cc cornofear@yahoo.ca added

comment:13 follow-up: Changed 11 days ago by cus

  • Cc cus added
  • Resolution set to invalid
  • Status changed from new to closed

The command line is wrong.

-level 5.0 should be used, not -level 50.

Closing as invalid.

comment:14 Changed 10 days ago by cornofear

  • Resolution invalid deleted
  • Status changed from closed to reopened

ffmpeg -h encoder=hevc_amf

-level <int> E..V...... Set the encoding level (default auto) (from 0 to 186) (default auto)

"from 0 to 186"
this needs to be fixed

comment:15 Changed 10 days ago by cus

0 to 186 is the numeric representation of the named constants "5.0" and similar. What we might do is not write the minimum and maximum integer value of the numeric representation because it seems to be misleading. Is this what you prefer?

comment:16 Changed 10 days ago by cornofear

In the original ticket Tupsi said:

'so I even tried numbers like 50 in the hopes it means "5.1", as I do not understand how the 14 current options listed above are represented by integer number between 0 und 186 (which says so in the help). I tried both left the labels 5.0, 5.1, 4.0, even 1.0 as well as differnt integer numbers in between 0 and 186.'

To avoid this problem, I'd suggest changing the help text to list the constants 'auto, 1.0, 2.0 etc,'

Even better would be to use the following code by AMD to parse this value: https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/public/samples/CPPSamples/common/EncoderParamsHEVC.cpp

comment:17 in reply to: ↑ 13 Changed 8 days ago by Tupsi

  • Resolution set to fixed
  • Status changed from reopened to closed

Replying to cus:

The command line is wrong.

-level 5.0 should be used, not -level 50.

Closing as invalid.

You did not take the time to read my whole ticket, because then you would have seen, that I also tried 5.0 and not only the 50 mentioned in the commandline example.

Doesnt matter, as I just downloaded a half current version from zeranoe (git from 20200628) and can clarify, that it is indead NOW working as intended, meaning, if you you use -level 5.1 you get Main@L5.1 and not the highest possible as it was before.

So whoever changed that to the better, THANK YOU for understanding the ticket and fixing it :-)

@cornofear
I just even tried -level 156 which according to the help should get me Main@L5.2 and it did! So both options work now, entering the human version as well as the machine version.

So I would suggest to close the ticket.

comment:18 Changed 8 days ago by cus

Ok, makes sense now. This was the fix then: c96837043e2e0a6449e0e6eb3d4119a834f9a0da

Note: See TracTickets for help on using tickets.