GPUOpen-LibrariesAndSDKs / AMF

The Advanced Media Framework (AMF) SDK provides developers with optimal access to AMD devices for multimedia processing
Other
596 stars 149 forks source link

[Question]: What are the proper FFMPEG syntax usages with AMD AMF drivers on Ubuntu Linux? #332

Open rajhlinux opened 2 years ago

rajhlinux commented 2 years ago

Hello, I built FFMPEG with AMD AMF enabled.

Now I have never executed FFMPEG commands over Ubuntu terminal.

I did some googling and couldn't find any proper guide on how to make FFMPEG to do some video encoding or converting using the AMD AMF hardware acceleration. I only found guides for VAAPI but not for AMD AMF.

What are some of the FFMPEG basic syntax usage for AMD AMF hardware acceleration?

Thanks.

rhutsAMD commented 2 years ago

One of the basic ways to use the AMF encoder with FFmpeg is to specify in the command line arguments to use the h264_amf or hevc_amf encoder in the codec option of the video stream.

ffmpeg -y -i input_file.mp4 -codec:v h264_amf output_file.mp4

To view all FFmpeg codec specific options you can run ffmpeg -h full.

Documentation for general FFmpeg options can be found here: https://ffmpeg.org/ffmpeg-all.html Additionally, there is a program called Axiom which is an FFmpeg interface and lets you generate command line options from a graphical UI. However, this program runs on Windows.

rajhlinux commented 2 years ago

Thanks for your reply.

I get this error:

$ ffmpeg -y -i video_sample.mp4 -codec:v h264_amf output_file.mp4

ffmpeg version N-107316-gf9dd8fcf9b Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --bindir=/home/user/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libaom --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-shared --disable-static --enable-amf --enable-nonfree
  libavutil      57. 27.100 / 57. 27.100
  libavcodec     59. 36.100 / 59. 36.100
  libavformat    59. 26.100 / 59. 26.100
  libavdevice    59.  6.100 / 59.  6.100
  libavfilter     8. 41.100 /  8. 41.100
  libswscale      6.  6.100 /  6.  6.100
  libswresample   4.  6.100 /  4.  6.100
  libpostproc    56.  5.100 / 56.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video_sample.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.76.100
  Duration: 00:00:40.87, start: 0.000000, bitrate: 9392 kb/s
  Stream #0:0[0x1](und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p(pc, gbr/bt709/iec61966-2-1), 1920x1080 [SAR 1:1 DAR 16:9], 9391 kb/s, 30.02 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (h264_amf))
Press [q] to stop, [?] for help
Segmentation fault (core dumped)

I ran this code on Ubuntu 22.04

Here is the error log file when using the "-report" option on ffmpeg:

ffmpeg started on 2022-07-06 at 17:20:47
Report written to "ffmpeg-20220706-172047.log"
Log level: 48
Command line:
ffmpeg -y -report -i video_sample.mp4 -codec:v h264_amf output_file.mp4
ffmpeg version N-107316-gf9dd8fcf9b Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --bindir=/home/user/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libaom --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-shared --disable-static --enable-amf --enable-nonfree
  libavutil      57. 27.100 / 57. 27.100
  libavcodec     59. 36.100 / 59. 36.100
  libavformat    59. 26.100 / 59. 26.100
  libavdevice    59.  6.100 / 59.  6.100
  libavfilter     8. 41.100 /  8. 41.100
  libswscale      6.  6.100 /  6.  6.100
  libswresample   4.  6.100 /  4.  6.100
  libpostproc    56.  5.100 / 56.  5.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-i' ... matched as input url with argument 'video_sample.mp4'.
Reading option '-codec:v' ... matched as option 'codec' (codec name) with argument 'h264_amf'.
Reading option 'output_file.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url video_sample.mp4.
Successfully parsed a group of options.
Opening an input file: video_sample.mp4.
[NULL @ 0x55e18a9ac080] Opening 'video_sample.mp4' for reading
[file @ 0x55e18a9ac840] Setting default whitelist 'file,crypto,data'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e18a9ac080] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e18a9ac080] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e18a9ac080] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e18a9ac080] Processing st: 0, edit list 0 - media time: 0, duration: 627717
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e18a9ac080] Before avformat_find_stream_info() pos: 47981586 bytes read:39161 seeks:1 nb_streams:1
[mpeg4 @ 0x55e18a9ad540] Format yuv420p chosen by get_format().
[mpeg4 @ 0x55e18a9ad540] Format yuv420p chosen by get_format().
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e18a9ac080] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e18a9ac080] After avformat_find_stream_info() pos: 79712 bytes read:118829 seeks:2 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video_sample.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.76.100
  Duration: 00:00:40.87, start: 0.000000, bitrate: 9392 kb/s
  Stream #0:0[0x1](und), 1, 1/15360: Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p(pc, gbr/bt709/iec61966-2-1), 1920x1080 [SAR 1:1 DAR 16:9], 9391 kb/s, 30.02 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Successfully opened the file.
Parsing a group of options: output url output_file.mp4.
Applying option codec:v (codec name) with argument h264_amf.
Successfully parsed a group of options.
Opening an output file: output_file.mp4.
[file @ 0x55e18a9c23c0] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
detected 8 logical cores
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (h264_amf))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mpeg4 @ 0x55e18a9c2ac0] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[graph 0 input from stream 0:0 @ 0x55e18c0731c0] Setting 'video_size' to value '1920x1080'
[graph 0 input from stream 0:0 @ 0x55e18c0731c0] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x55e18c0731c0] Setting 'time_base' to value '1/15360'
[graph 0 input from stream 0:0 @ 0x55e18c0731c0] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 0x55e18c0731c0] Setting 'frame_rate' to value '30/1'
[graph 0 input from stream 0:0 @ 0x55e18c0731c0] w:1920 h:1080 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:1/1
[format @ 0x55e18c13ad00] Setting 'pix_fmts' to value 'nv12|yuv420p'
[AVFilterGraph @ 0x55e18bd9e940] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[h264_amf @ 0x55e18a9c0a40] AMF initialisation succeeded via Vulkan.
[h264_amf @ 0x55e18a9c0a40] EncodeQueueVulkan: 0122-06-06 17:20:47 9FA22EC0 [EncodeQueueVulkan]    Info: EncodeQueueServiceVulkanImpl::Initialize() new encode queue extension is not supported
[h264_amf @ 0x55e18a9c0a40] EncodeQueueService: 0122-06-06 17:20:47 9FA22EC0 [EncodeQueueService] Warning: Failed to create encode queue serivce.
[h264_amf @ 0x55e18a9c0a40] AMFEncoderCoreBaseImpl: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderCoreBaseImpl] Warning: Failed to initialize EncodeQueueFactory.
[h264_amf @ 0x55e18a9c0a40] AMFEncoderCoreBaseImpl: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderCoreBaseImpl] Warning: Failed to create encode queue serivce.
[h264_amf @ 0x55e18a9c0a40] AMFEncoderCoreH264: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderCoreH264] Warning: Encode Core dll not found, fall back to UVE path
[h264_amf @ 0x55e18a9c0a40] AMFEncoderCoreH264: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderCoreH264] Warning: CreateServices failed.
[h264_amf @ 0x55e18a9c0a40] AMFEncoderCoreH264: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderCoreH264]    Info: *****Fallback to UVE path!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderCoreH264: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderCoreH264]   Debug: AMFEncoderCoreH264Impl::Terminate()
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]   Error: ../../../../../runtime/src/components/EncoderVulkan/EncoderVulkanH264Impl.cpp(453):InitializeCap() res: AMD Decode extension is not loaded
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param ConstraintSetFlags changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param EnableVBAQ changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param EncoderMaxInstances changed to 1!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param EncoderOutputCallback changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param ExtraData changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param FrameSize changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param InstanceID changed to -1!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param IntraRefreshMode changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param MaxDecFrameBuffering changed to -1!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param MaxMBPerSec changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param MaxNumRefFrames changed to 4!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param MaxOfLTRFrames changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param MultiInstanceMode changed to 0!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty CABACEnable:0
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param Profile changed to 77!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param ProfileLevel changed to 42!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param QualityPreset changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param QueryTimeout changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param RateControlPreanalysisEnable changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param ScanType changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param UniqueInstance changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(0): UpdateConfig:Init Param WaitForTask changed to 0!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty Usage:0
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param ConstraintSetFlags changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param EnableVBAQ changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param EncoderMaxInstances changed to 1!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param EncoderOutputCallback changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param ExtraData changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param FrameSize changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param InstanceID changed to -1!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param IntraRefreshMode changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param MaxDecFrameBuffering changed to -1!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param MaxMBPerSec changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param MaxNumRefFrames changed to 4!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param MaxOfLTRFrames changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param MultiInstanceMode changed to 0!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty CABACEnable:0
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param Profile changed to 77!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param ProfileLevel changed to 42!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param QualityPreset changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param QueryTimeout changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param RateControlPreanalysisEnable changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param ScanType changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param UniqueInstance changed to 0!
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param WaitForTask changed to 0!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty FrameSize:1920,1080
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan] Warning: SetProperty FrameSize failed in AMFPropertyStorageExImpl with return code:0x5, and will not set driver either, but return ok for now!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty FrameRate:30,1
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty Profile:77
[h264_amf @ 0x55e18a9c0a40] PropertyStorageExImpl: 0122-06-06 17:20:47 9FA22EC0 [PropertyStorageExImpl]   Error: ../../../../../public/common/PropertyStorageExImpl.h(277):AMF_ERROR 4 : AMF_INVALID_ARG: Property=Profile
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan] Warning: SetProperty Profile failed in AMFPropertyStorageExImpl with return code:0x4, and will not set driver either, but return ok for now!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty AspectRatio:1,1
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty FullRangeColor:true
[h264_amf @ 0x55e18a9e0d40] Rate control turned to CBR
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty RateControlPreanalysisEnable:0
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty QualityPreset:1
[h264_amf @ 0x55e18a9c0a40] EncoderVulkanH264PropertySet: 0122-06-06 17:20:47 9FA22EC0 [EncoderVulkanH264PropertySet]   Debug: EncoderVulkanH264PropertySet(-1): UpdateConfig:Init Param QualityPreset changed to 1!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty RateControlMethod:1
[h264_amf @ 0x55e18a9c0a40] PropertyStorageExImpl: 0122-06-06 17:20:47 9FA22EC0 [PropertyStorageExImpl]   Error: ../../../../../public/common/PropertyStorageExImpl.h(277):AMF_ERROR 4 : AMF_INVALID_ARG: Property=RateControlMethod
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan] Warning: SetProperty RateControlMethod failed in AMFPropertyStorageExImpl with return code:0x4, and will not set driver either, but return ok for now!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty MaxAUSize:0
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty TargetBitrate:2000000
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan] Warning: SetProperty TargetBitrate failed in AMFPropertyStorageExImpl with return code:0x5, and will not set driver either, but return ok for now!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]    Info: SetProperty PeakBitrate:2000000
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan] Warning: SetProperty PeakBitrate failed in AMFPropertyStorageExImpl with return code:0x5, and will not set driver either, but return ok for now!
[h264_amf @ 0x55e18a9c0a40] AMFEncoderVulkan: 0122-06-06 17:20:47 9FA22EC0 [AMFEncoderVulkan]   Debug: AMFEncoderVulkanH264Impl::_Init(YUV420P, 1920, 1080)

Thanks.

rajhlinux commented 2 years ago

Alright I seem to have fixed the issue for H.264 encoding, seems to work properly.

What I did is that I did a fresh reinstall of Ubuntu 22.04 and installed the amd amf drivers using this command:

sudo amdgpu-install --usecase=workstation,amf -y --accept-eula --opencl=rocr,legacy --vulkan=pro

However ffmpeg encodes extremely slow, I see that ffmpeg is encoding with "speed=1.31x", same to that as software encoding using CPU... so I do not see any benefits on using GPU acceleration. Maybe I need to set some parameters?

And when using hevc_amf, I get the following error:

[hevc_amf @ 0x557ddae36d40] CreateComponent(AMFVideoEncoderHW_HEVC) failed with error 11
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

Thanks.

MikhailAMD commented 2 years ago

What is your GPU? On Linux AMF supports HEVC for RX5xxx and RX6xxx only. From performance perspective, you are probably bound be SW decoder or SW processing before encoder. Please note, that all HW encoders mostly work on NV12. try to add "-pix_fmt nv12".

rajhlinux commented 2 years ago

AMD Radeon WX 2100

Thanks for hints.