Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am using RTSPClientExample to record H264 videos from stream its working fine for HikVision camera but not in flir camera. When i record stream from flir camera i only see blank screen #110

Closed
praveenbinomial opened this issue Feb 26, 2024 · 2 comments

Comments

@praveenbinomial
Copy link

I am using RTSP Client to record H264 videos from stream its working fine for HikVision camera but not in flir camera. When i record stream from flir camera i only see blank screen

@praveenbinomial praveenbinomial changed the title I am using RTSP Client to record H264 videos from stream its working fine for HikVision camera but not in flir camera. When i record stream from flir camera i only see blank screen I am using RTSPClientExample to record H264 videos from stream its working fine for HikVision camera but not in flir camera. When i record stream from flir camera i only see blank screen Feb 26, 2024
@Revan1985
Copy link

Revan1985 commented Feb 26, 2024

Check if the h264 nals contains the intial 0x00 0x00 0x00 0x01 header.
I have found a similar problem for some cameras at works, and resolved checking for it and add when needed...
or you could try to debug the h264 and check if there are any errors in the parsing for the flir camera streaming...
This is the only thing I can think about, I don't know this kind of cameras, sorry

This is the code I use for this purpose

`bool frame_i = nal_units.Any(n => ((n.Span[0] >> 0) & 0x1F) == 5);

if (frame_i)
{
if (!ArrayUtils.StartsWith(_sps, 0, 4, [0x00, 0x00, 0x00, 0x01])) { bufferMemoryStream.Write([0x00, 0x00, 0x00, 0x01], 0, 4); }
bufferMemoryStream.Write(_sps, 0, _sps.Length);
if (!ArrayUtils.StartsWith(_pps, 0, 4, [0x00, 0x00, 0x00, 0x01])) { bufferMemoryStream.Write([0x00, 0x00, 0x00, 0x01], 0, 4); }
bufferMemoryStream.Write(_pps, 0, _pps.Length);
}`

You need to do the same later for the nal units when saving the frame info.

bufferMemoryStream is a MemoryStream that holds the required informations.
Remember, if you receive an I frame, you must save also the sps and pps information (as in code), not all the software can render h264 right if this info is missing.

@praveenbinomial
Copy link
Author

Thank you for reaching out, this is very helpful,
I have done lot of changes on my project and after that
foreach (byte[] nal_unit in nal_units)
{
if (nal_unit.Length>2)
{
fs_v.Write(new byte[] { 0x00, 0x00, 0x00, 0x01 }, 0, 4); // Write Start Code
fs_v.Write(nal_unit, 0, nal_unit.Length); // Write NAL
}

}
this is working for me.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants