Decoding H264 frames c #

I am using managed media aggregation in C # - https://net7mma.codeplex.com/ .

I have an Rtsp client that receives h264 encoded RTP frames (payload type 96). I want to save the frames to a video file and also be kip to tell when the video starts / ends.

I did some reading and I read that its a problem to decode h264 frames one by one .. didn't really understand why.

Here is the method that is generated for every RTP frame I receive

void Client_RtpFrameChanged(object sender, Media.Rtp.RtpFrame frame)
{
    // Decode
}

      

  • Can anyone explain why its a problem to decode h264 frames one by one?
  • Is there an open source / library / dll for this?

Thank you so much!

+3


source to share


1 answer


The RtspServer project has an included class.

The class is RFC6184Media, it contains batching and unpacking methods and handles all specific types of Nal units.

After the call to Depacketize, there is a buffer that contains the Raw Bit Stream payload, you will need to add the initial code consisting of 0x000001 and then the data contained in the original bitstream.

There are several examples in the discussion area for the project.



After that, you can feed the stream to the decoder for decoding, and only then can the frames be displayed; usually by converting from Yuv to Rgb corresponding to the sub-sampling used in encoding.

I can see how to add a small demo for a few static packages that match a frame and show how to achieve the desired result.

In the future, if you do a discussion on the project page, I will probably get to it much faster.

0


source







All Articles