This project has moved and is read-only. For the latest updates, please go here.

RTP H.264 frames into video file

Sep 15, 2014 at 2:06 PM
Edited Sep 15, 2014 at 2:08 PM

I am using Managed Media Aggregation in my C# App to stream a video in RTSP -

I have a RtspServer on my LAN that sends me RTP Frames encoded in H.264 (Payload Type 96).
I am looking for a way to save those frames/packets into a video file (could be any video file format that can Play H.264).

From what I understand, I don't have to decode it in order to save it to a file, just put it in a suitable container.

this is the method that is raised for each RTP frame that I recieve:
void Client_RtpFrameChanged(object sender, Media.Rtp.RtpFrame frame)
    // save to mp4 file
any ideas? been searching for a while..
Sep 16, 2014 at 9:39 AM
Edited Sep 16, 2014 at 9:40 AM
Unfortunately, I cannot help much here, as I am not a specialist in H264 or RTP.
Generally speaking, when you have pre-encoded video stream, all you need is to set properties of IAviVideoStream properly (namely, Codec, Width and Height), and pass the data of encoded frames to the Write method.

For H264, codec value may be 'H264'/'X264' or 'AVC1' (difference is described here )

Data in H264 are stored in network abstraction layer units (NALUs), which should be distributed into the frames for writing to IAviVideoStream (this link may help here)

When passed over RTP, H264 NALUs are distributed into RTP packets, according to this spec

Take a look at FFMPEG sources for the parsing code of RTP H264 streams
Nov 15, 2014 at 2:56 PM
Hello, I am the author of Managed Media Aggregation.

The latest release supports rfc6184 depacketization, check it out.

There is also a few examples in the Discussion area for my project which shows how to save to a .264 file as well as use cscodec to extract frames.