Home > Forum > Can I feed H.264 encoded frames one by one into the Player?

Can I feed H.264 encoded frames one by one into the Player?

Mar 11 (47 days ago)
Alvan Rahimli wrote
Hi. We are integrating a third party system which returns H.264 encoded frames one by one via TCP socket. I was wondering if it is possible to feed these frames into the Player of VisioForge SDK and render it on UI (Avalonia).

For the prototype, we made this using GStreamer pipeline that has "fdsrc fd=0" source, so it was reading stdin for frames. Can I achieve similar functionality using VisioForge SDK?

Thanks in advance
Reply
10 Answers
Mar 11 (47 days ago)
Roman Miniailov agent wrote
Hi

Yes, it's possible to use the Media Blocks SDK. You can use any GStreamer element using the CustomMediaBlock that will be the wrapper for the element.

(I'll close the second ticket)
Mar 12 (47 days ago)
Alvan Rahimli wrote
Hi Roman. Thank you for your answer. I have installed the sample project "VisioForge.MediaBlocks.Demos.CS Avalonia", and it works. But when I run the project, I get a lot of error logs to console like "Failed to load module: C:\Users\Alvan\Workspace\.Net-SDK-s-samples\Media Blocks SDK\Avalonia\Simple Player\SimplePlayerAvalonia.Desktop\bin\Debug\net7.0-windows7.0\x64\avcodec-59.dll". However, when I check that path, I can see the dll there. Can you please help me on this?

Also, when I call InitSDK() from our project, it throws the same exception telling it couldn't find libgstreamer-1.0.so. But this time it fails.

Thanks in advance.
Mar 12 (47 days ago)
Roman Miniailov agent wrote
Hi

Please check that the app started as x64.

"couldn't find libgstreamer-1.0.so" - you should have a Windows target like net7.0-windows in your csproj file.
Mar 12 (47 days ago)
Alvan Rahimli wrote
Thanks Roman. It is all slowly coming together! Just to make sure, I'll ask couple of final questions:
```
_videoRenderer = new VideoRendererBlock(_pipeline, videoView);
_framesSource = new StreamSourceBlock(new StreamSourceSettings(memStream));
_pipeline.ConnectLive(_framesSource.Output, _videoRenderer.Input);
```

Now, if I write these h264 encoded frames into `memStream`, should I see those being rendered on UI?
I am asking because earlier you suggested using CustomMediaBlock stuff, and I wonder if StreamSourceBlock is suitable for my scenario or not.
Mar 12 (47 days ago)
Roman Miniailov agent wrote
Hi

Probably it’s suitable but we need to add the H264Decoder block before the video renderer to decode frames.

I suggest you implementing the OnError event to see if something wrong.

Can we have a situation when the first frame is not a key frame and we need to skip it?
Mar 12 (47 days ago)
Alvan Rahimli wrote
No there won't be such case because I skip frames until I see a key frame (this happens before frame is fed to pipeline, so it is safe).

Thank you for OnError tip. I can see there is this error: "[MediaBlocksPipeline[]][Connect] Unable to connect pads. One of internal pads is null."

I can also see that `_framesSource.Output.b {MediaBlockPad}` is null. It is the same for _videoRenderer as well, but it's Input.b is null.
Mar 12 (47 days ago)
Alvan Rahimli wrote
Apparently I shouldn't have used ConnectLive. Removing it fixed last issue, but I still can't see any video.
Also, I switched to VirtualVideoSourceBlock() for testing purposes.

This time I am getting 3 errors:
- [MediaBlocksPipeline[]][Bus_StateChanged] State set to READY
- [MediaBlocksPipeline[]][Bus_StateChanged] State set to PAUSED
- [MediaBlocksPipeline[]][Bus_StateChanged] State set to PLAYING

... no render happening.
Mar 12 (46 days ago)
Alvan Rahimli wrote
I managed to solve these issues, but I keep getting this whenever I use StreamSourceBlock: System.Exception: Failed to load VisioForgeGstPlugins_x64.dll.

Where can I find this DLL?
Mar 12 (46 days ago)
Alvan Rahimli wrote
I managed to make it work. CustomSourceBlock with appsrc was the way to go.

Thanks.
Mar 13 (46 days ago)
Roman Miniailov agent wrote
OK, I'll close this ticket for now. We have a chat discussion already.