H264-Encoder | Implementation of a subset of CBP of h.264 encoder | Machine Learning library
kandi X-RAY | H264-Encoder Summary
kandi X-RAY | H264-Encoder Summary
Implementation of a subset of CBP of h.264 encoder
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of H264-Encoder
H264-Encoder Key Features
H264-Encoder Examples and Code Snippets
Community Discussions
Trending Discussions on H264-Encoder
QUESTION
Using the Android Camera Video recorder I made a video:
It seems like seqParamSetLength always is 15 and picParamSetLength is always 4.
Is this somehow defined in Codec (MediaCodec)?
...ANSWER
Answered 2021-Mar-15 at 00:30It seems like seqParamSetLength always is 15 and picParamSetLength is always 4.
This is not true. The size of the SPS/PPS are different depending on the encoder and settings used. Since android typically uses hardware encoders, You will get different sizes on different devices.
QUESTION
Background: I'm encoding NV12 buffers into h264 video stream wrapped in MPEG4 container using SinkWriter. Everything works fine but one problem though, as the SinkWriter abstracts the low-level encoder configurations I'm unable to control the properties like GOP size, B-picture count, CODECAPI_AVEncCommonRateControlMode, etc.
The problem is due to the fact that the SinkWriter instantiates the encoder transform only after the SetInputMediaType call, and we will be able to get the CodecAPI instance only after that point. So, we have no way to control the encoder and configure necessary props before all this happens, it also never honours further changes to the encoder through CodecAPI instance.
Experiments: I tried the PropertyStore(MF_SINK_WRITER_ENCODER_CONFIG) approach but nothing seemed to be changing (It could be a platform/encoder specific behaviour), I could also see a lot of people complaining about unpredictable behaviours with these APIs. Then, I came across this MSDN thread (Almost 7 years old post) in which the user described how he dealt with this problem by locally registering a custom class factory on Windows7 machine.
Problem: Having the MSDN thread as a reference, I tried implementing IClassFactory and registering it through MFTRegisterLocal but the CreateInstance function is never getting called for me (Windows 10 machine). I'm only getting the QueryInterface method called for IID_IClassFactory and IID_IMFAttributes interfaces instead. And, the SinkWriter seems to be proceeding with fetching the MFT on its own.
I understand I might be doing something wrong, and I'm not an expert in COM. Is there any other way I could achieve this?
Custom class factory implementation:
...ANSWER
Answered 2020-Jan-06 at 14:28You are walking on thin ice here because what you are trying to do is not supposed to work. You do (or at least can) register a local transform but API would typically prefer other existing MFTs to your one because they are of higher internal merit (and with hardware assistance support), so you are not expected to override existing behavior.
Your real options are:
- to use
MF_SINK_WRITER_ENCODER_CONFIG
attribute to pass encoder specific configuration - register class factory with COM rather than with MF for existing CLSID of encoder so that COM instantiation of MFT went your way; you would have to figure out details about COM to implement this and I would, in general, not recommend to interfere with standard behavior of COM registration/instantiation without good reason
- run encoding MFT (or its equivalent - you don't have to use MFT exactly in this case) separately, outside of Sink Writer API, and feed Sink Writer with already compressed data
QUESTION
I'm capturing the desktop using DesktopDuplication API and converting the samples from RGBA to NV12 in GPU and feeding the same to MediaFoundation hardware H264 MFT. This works fine with Nvidia graphics, and also with software encoders but fails when only intel graphics hardware MFT is available. The code works fine on the same intel graphics machine if I fallback to Software MFT. I also have ensured that the encoding is actually done in hardware on Nvidia graphics machines.
On Intel graphics, MFT returns MEError ("Unspecified error"), which happens just only after the first sample is fed, and subsequent calls to ProcessInput (when event generator triggers METransformNeedInput) returns "The callee is currently not accepting further input". It's rare that MFT consumes a few more samples before returning these errors. This behavior is confusing, I'm feeding a sample only when the event generator triggers METransformNeedInput asynchronously through IMFAsyncCallback, and also checking properly whether METransformHaveOutput is triggered as soon as a sample is fed. This really baffles me when the same asynchronous logic works fine with Nvidia hardware MFT & Microsoft software encoders.
There is also a similar unresolved question in the intel forum itself. My code is similar to the one mentioned in the intel thread, except for the fact that I'm also setting d3d device manager to the encoder like below.
And, there are three other stack overflow threads reporting a similar issue with no solution given (MFTransform encoder->ProcessInput returns E_FAIL & How to create IMFSample from D11 texture for Intel MFT encoder & Asynchronous MFT is not sending MFTransformHaveOutput Event(Intel Hardware MJPEG Decoder MFT)). I have tried every possible option with no improvement on this.
Color converter code is taken from intel media sdk samples. I have also uploaded my complete code here.
Method to set d3d manager:
...ANSWER
Answered 2019-Nov-13 at 21:50I looked at your code.
According to your post, i suspect an Intel video processor problem.
My OS is Win7, so i decide to test the video processor behaviour with a D3D9Device on my Nvidia card, and then on an Intel HD Graphics 4000.
I suppose the video processor capabilities will behave the same way for a D3D9Device as for a D3D11Device. Of course it will be necessary to check.
So i made this program to check : https://github.com/mofo7777/DirectXVideoScreen (see D3D9VideoProcessor sub-project)
It seems you do not check sufficient things about the video processor capabilities.
With IDXVAHD_Device::GetVideoProcessorDeviceCaps, here is what i check :
DXVAHD_VPDEVCAPS.MaxInputStreams > 0
DXVAHD_VPDEVCAPS.VideoProcessorCount > 0
DXVAHD_VPDEVCAPS.OutputFormatCount > 0
DXVAHD_VPDEVCAPS.InputFormatCount > 0
DXVAHD_VPDEVCAPS.InputPool == D3DPOOL_DEFAULT
I also check input and output format supported with IDXVAHD_Device::GetVideoProcessorOutputFormats and IDXVAHD_Device::GetVideoProcessorInputFormats.
This is where i found a difference between Nvidia GPU and Intel GPU.
NVIDIA : 4 output format
- D3DFMT_A8R8G8B8
- D3DFMT_X8R8G8B8
- D3DFMT_YUY2
- D3DFMT_NV12
INTEL : 3 output format
- D3DFMT_A8R8G8B8
- D3DFMT_X8R8G8B8
- D3DFMT_YUY2
On Intel HD Graphics 4000, there is no support for the NV12 output format.
Also for the program to work correctly, i need to setup stream state before using VideoProcessBltHD :
- DXVAHD_STREAM_STATE_D3DFORMAT
- DXVAHD_STREAM_STATE_FRAME_FORMAT
- DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE
- DXVAHD_STREAM_STATE_SOURCE_RECT
- DXVAHD_STREAM_STATE_DESTINATION_RECT
For D3D11 :
ID3D11VideoProcessorEnumerator::GetVideoProcessorCaps == IDXVAHD_Device::GetVideoProcessorDeviceCaps
(D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT_OUTPUT) ID3D11VideoProcessorEnumerator::CheckVideoProcessorFormat == IDXVAHD_Device::GetVideoProcessorOutputFormats
(D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT_INPUT) ID3D11VideoProcessorEnumerator::CheckVideoProcessorFormat == IDXVAHD_Device::GetVideoProcessorInputFormats
ID3D11VideoContext::(...) == IDXVAHD_VideoProcessor::SetVideoProcessStreamState
Could you first verify the video processor capabilities of your GPU. Do you see same difference as i see ?
This is the first thing we need to know, and it seems your program does not check this, from what i've seen on your github project.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install H264-Encoder
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page