简体   繁体   中英

Decode H264 frames C#

I am using Managed Media Aggregation in C# - https://net7mma.codeplex.com/ .

I have a Rtsp Client that receives RTP Frames encoded in h264 (payload type 96). I want to be able to save the frames into a video file, and also be bale 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 raised for each RTP frame that I receive

void Client_RtpFrameChanged(object sender, Media.Rtp.RtpFrame frame)
{
    // Decode
}
  1. Can someone explain why its a problem to decode h264 frames one-by-one?
  2. Is there a open source/library/dll for this?

Thanks a lot!

There is an included class in the RtspServer project.

The class is RFC6184Media, it contains methods for packetization and depacketiation and handles all defined Nal Unit types.

After you call Depacketize there is a Buffer which contains the Raw Bit Stream Payload, you will have to add a start code consisting of 0x000001 and then the data contained in the raw bitstream.

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

After that you can feed the stream to a decoder for decoding and only then can the frames can be displayed; usually by conversion from Yuv to Rgb respective to the sub sampling used when encoding.

I can see about adding a small demo for a few static packets which corresponds to a frame and show how to achieve the desired result.

In the future if you make a discussion on the project page I will probably get to it much quicker.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM