Building a pipeline to show H265 encoded stream

Hi. I have a third party application that pushes H265 encoded stream’s frames one by one, and I need to create a pipeline that can handle this stream.

I am using C# bindings, with VisioForge library. But my question is not directly related to that particular library. I want to learn building that pipeline generally, then it can easily be adapted to VisioForge (it is kind of a wrapper for gstreamer c# bindings)

Here is the code I use to build the pipeline now:

As source, I am using AppSrc and I push frames using need-data delegate. I have the pipeline working for H264 encoded stream, but now having trouble making H265 part:

_appSrc = new CustomMediaBlock(new CustomMediaBlockSettings("appsrc"));
if (_streamInfo!.VideoCodec is VideoCodecType.H264) // works nicely
{
    _h264Parser = new H264ParseBlock();
    _pipeline.Connect(_appSrc.Output, _h264Parser.Input);
    
    _h264Decoder = new H264DecoderBlock(new OpenH264DecoderSettings());
    _pipeline.Connect(_h264Parser.Output, _h264Decoder.Input);
    
    _videoConverter = new VideoConverterBlock();
    _pipeline.Connect(_h264Decoder.Output, _videoConverter.Input);
    
    _grabber = new VideoSampleGrabberBlock(addNullRenderer: true);
    _pipeline.Connect(_videoConverter.Output, _grabber.Input);
}
else if (_streamInfo.VideoCodec is VideoCodecType.HEVC)
{
    _h265Parser = new H265ParseBlock();
    _pipeline.Connect(_appSrc.Output, _h265Parser.Input);
    _h265DecoderBin = new DecodeBinBlock(false, false, false);
    // _h265Decoder = new D3D11H265DecoderBlock();
    _pipeline.Connect(_h265Parser.Output, _h265DecoderBin.Input);
    _videoConverter = new VideoConverterBlock();
    _pipeline.Connect(_h265DecoderBin.Output, _videoConverter.Input);
    
    _grabber = new VideoSampleGrabberBlock(addNullRenderer: true);
    _pipeline.Connect(_videoConverter.Output, _grabber.Input);
}

Any help or comment is much appreciated,
thanks in advance!

Is there not a H265DecoderBlock similar to the H264DecoderBlock?

decodebin usually comes with additional problems such as sometimes pads / dynamic linking - does VisioForge abstract/handle that for you?

No, there isn’t such wrapper, but I will now ask the author of that lib. how does overall pipeline look? For example, H264 branch is working even without videoconverter.

I fixed made it work!

I don’t know why I wasn’t using custom media media block with nvh265dec. Thanks for forwarding me to the correct place.

In the meantime, can you please comment on the efficiency part of the pipeline? do you see any performance killer parts or something?

1 Like

Update: instead of DecodeBinBlock, I used new CustomMediaBlock(new CustomMediaBlockSettings("nvh265dec")); which fixed it.