Load SDP file and encode stream to MP4

Topics: Question
Jan 15, 2016 at 9:36 PM
Does your library support taking an SDP file and encoding the stream within the session to an MP4 container using H.264?

I see there are projects setup for each but don't see any examples or documentation that would describe the process of setting this up. Is it supported?
Jan 19, 2016 at 3:36 PM
I'm currently trying to connect an RTP client but will not connect given the SDP.

var client = Media.Rtp.RtpClient.FromSessionDescription(SessionDescription);
client.Activate();

The session description is created from this:

v=0
o=- 1 1 IN IP4 192.168.5.102
s=stream-high
i=H264 session-high
u=http://192.168.5.102
c=IN IP4 239.1.5.63/64/1
t=0 0
m=video 5006/1 RTP/AVP 102
i=Video stream
c=IN IP4 239.1.5.63/64/1
a=fmtp:102 width=1920;height=1080;depth=0;framerate=0;fieldrate=0;
a=framerate:0
a=rtpmap:102 H264/90000


VLC can load this SDP and playback the stream but with your library, I can't get past simply connecting. Received frame events don't fire because no connection is actually established. Any ideas?

Cheers.
Coordinator
Jan 20, 2016 at 2:28 PM
Yes, it should be supported and I am sorry you are having difficulties.

I happen to be very busy this week so far, hopefully tonight or possibly tomorrow or at the latest early next week I will be able to give this issue more attention.

From first glance it seems you are using a multicast address, did you properly configure the socket before creating the RtpClient?

Right now multicast isn't directly supported but can easily be configured, you just need to create the socket and pass it to the InitializeMethod of the TransportContext you are using or do some work to the socket which was created for you to properly join the Multicast group.

Let me know if that makes sense and keep an eye our for another response soon.

Thanks for your interest in the library.
Marked as answer by juliusfriedman on 1/20/2016 at 6:29 AM
Jan 20, 2016 at 8:53 PM
Edited Jan 20, 2016 at 9:14 PM
I just got multicast working, reading your response tells me I must of did it correctly!

I then register to the RTP received event and then I process the packet through the TestRFC6184VideoFrame routine replacing the test data with actual RTP data being received. At the end of the routine it is creating Test.h264, so now I'm needing to decode this info and then encode, and then mux it to an MP4 file... any more information you can provide on that is greatly appreciated!

Library looks great so far, especially for a managed solution that does not require DirectShow or MediaFoundation components.

Cheers.
Coordinator
Jan 21, 2016 at 4:56 PM
Thanks for the kind words!

You can proably just use FFMPEG or another tool to combine the various h.264 files into a MP4 or other container.

The process to do it all in managed code isn't that hard and data doesn't need to be decoded and re-encoded just to store in a MP4, it just needs to be wrapped per say.

I hope to have more utilities to do this automatically for a developer but I just haven't had the time right now, I also haven't had any real offers for help contributing to the project only requests for support but I am confident that if I got a little help this library would definitely be able to do a lot more that it currently can for instance RTSP to DASH or RTSP to RTMP.

There is also some minor work which needs to be done to support archving and playback of archived data, once that work is done it would be trivial to point FFMPEG to the archive URL and transcode the resulting output over RTSP to any codec or container their FFMPEG instance can support.

Let me know if you have anymore questions or if you can contribute anything!

Reguards!
Marked as answer by juliusfriedman on 1/21/2016 at 8:57 AM
Jan 21, 2016 at 7:13 PM
Edited Jan 21, 2016 at 7:13 PM
I wish I can contribute more. I'm definitely thinking about it now :)

Currently I'm creating separate h.264 files, is it best practice to simply append the next frame to the end of the previous h.264 file?

I've done a lot with directshow specifically, I've used mainconcept, intel, and various other filters... in c#... as well as libraries such as Streamcoders. Always wanted a pure managed solution without the means of hooking into this or that. I'll try to peek through most of the solution on the weekend, see what I can contribute.

Cheers.
Coordinator
Jan 21, 2016 at 7:46 PM
Most of the time yes, however there are some cases where re-ordering may have to be done on the underlying NAL units but that is only for certain profiles. I would need to see a copy of the session description to completely answer that question but I would also say that if the decoder your using is good enough it shouldn't really matter.

Thanks again for your interest and hopefully you can contribute!
Marked as answer by juliusfriedman on 1/21/2016 at 11:46 AM
Jan 21, 2016 at 8:27 PM
SDP

v=0
o=- 1 1 IN IP4 192.168.5.102
s=stream-high
i=H264 session-high
u=http://192.168.5.102
c=IN IP4 239.1.5.63/64/1
t=0 0
m=video 5006/1 RTP/AVP 102
i=Video stream
c=IN IP4 239.1.5.63/64/1
a=fmtp:102 width=1920;height=1080;depth=0;framerate=0;fieldrate=0;
a=framerate:0
a=rtpmap:102 H264/90000
Jan 21, 2016 at 9:07 PM
Did a quick append, and -vcodec copy and got 9 seconds worth of video. Sweet!
Coordinator
Jan 21, 2016 at 9:23 PM
It looks like basic H264 with in band PPS and SPS so you should be fine.

Glad to hear your having success!
Marked as answer by juliusfriedman on 1/21/2016 at 1:23 PM