GPUOpen-LibrariesAndSDKs / AMF

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

SimpleEncoder output question #490

Open daneden21 opened 1 month ago

daneden21 commented 1 month ago

Hi Guys,

I try to encode a stream of a screen capture to AV1 using AMF. I used the SimpleEncoder example to implement AMF in my application. The output file has no content and doesnt look like a video file but it has a valid size.

After not getting further within my app I tried SimpleEncoder as a stand alone and it generates an "output.h264" that I cant open in any media player.

I also tried TranscodeHW.exe and this works fine. The output files are all OK and useable independent of the used codec. All of them work.

Now here is the part that I dont understand: When I use the "output.h264" from the SimpleEncoder as input for the TranscodeHW.exe it generates a wonderful working video file. So what am I missing here?

Does the encoder output file need some post processing to work?

I would be thankful for every advice.

MikhailAMD commented 1 month ago

SimpleEncoder sample is minimalistic and only shows how to use AMF encoder. The produced output file is elementary stream for any codec. It consists only of encoded data. Some applications can parse and read such files, like FFmpeg, many regular apps and players don't. TranscodeHW in addition to encoding also "mux" the file, meaning wraps the encoded data into file container format like MKV or MP4. It also transcodes and muxes audio into the file. These files are playable by all apps. The TranscodeHW sample uses FFmpeg library to do muxing and audio processing.

daneden21 commented 1 month ago

Thank you very much for your quick answer. This is very helpful for me as an absolute beginner in video encoding. I have seen the muxing description in the AMF_Video_Encode_API dokumentation and I thought this is only necessary when you want to add an audio stream to the final video.

I have another final question regarding native DX12 support. Before I tried AMF I tried to use the native dx12 ID3D12VideoDevice interface. I can create the device but when I use ID3D12VideoDevice::CheckFeatureSupport to check for encoder support it gives an error. I searched the internet if AMD supports this but couldnt find anything only AMF informations. So is native dx12 de-/encoding supported by AMD?

Btw I use an APU with 780M graphics, so RDNA3.

Thank you and have a nice weekend.

MikhailAMD commented 1 month ago

D3D12 native encoding and decoding are supported but you need to check the driver version.

daneden21 commented 1 month ago

Hi,

I just wanted to let you know that I got it working in my app and the performance is great. Actually not much code is necesssary to mux the encoder output into a ffmpeg container. If I can do it everybody can, so AMF is really easy to work with.

During coding I found one thing that make me wonder a bit. When I compare the AMF_VIDEO_ENCODER_AV1_USAGE_ENUM to AMF_VIDEO_ENCODER_HEVC_USAGE_ENUM and AMF_VIDEO_ENCODER_USAGE_ENUM the order of the elements is changed in one position. 0:Transcoding, 1: Ultra_low_latency, 2: Low_latency, 3: Webcam, 4: HQ, 5: LL HQ for h264 and h265. For av1 Nr.1&2 are exchanged, is this a typo or should it be like this?

Kind regards

MikhailAMD commented 1 month ago

This is not a typo. You should treat parameters for every codec as completely independent from another codec. There was no intention to match enum values between codecs. Great to hear that your app is up and running. When/if you make it a product or public, you may send us a link for tracking purposes.