To configure your MFWriter object you should select RTSP streaming format and select required audio and video codecs. Result configuration looks like:
format='rtsp' protocol='rtsp://' video::codec='n264' audio::codec='aac'
Implementing RTSP streaming in the code
MPlatform
// Set up your source object, for example a device
// ...
// Start your source object
m_objMLive.ObjectStart(null);
// Initialize a new instance of MWriter object
m_objWriter = new MWriterClass();
// Set destination URL and capturing configuration
m_objWriter.WriterNameSet("rtsp://medialooks:medialooks@192.168.0.191:1935/live/MyLive",
" format='rtsp' protocol='rtsp://' video::codec='n264' audio::codec='aac' video::b='3M'");
// Start a streaming process
m_objWriter.ObjectStart(m_objMLive);
MFormats
MFWriterm_objMFWriter
= new MFWriter(); string myConfiguration = @" format='rtsp' protocol='rtsp://' video::codec='n264' audio::codec='aac' video::b='3M'");
string destinationURL ="rtsp://medialooks:medialooks@192.168.0.191:1935/live/MyLive"
;m_objWriter
.WriterSet(destinationURL, 1, myConfiguration);
and then you can use a m_objMFWriter object as a receiver to put frames to make RTSP streaming:
// a frame object MFFrame myFrame; // grab a frame ((IMFSource)myLiveSource).SourceFrameGet(-1, out myFrame, ""); // send to receiver ((IMFReceiver)m_objMFWriter).ReceiverFramePut(myFrame, -1, "");
Destination URL structure
The destination URL for RTSP streaming looks like this:
rtsp://[media server IP]:[port number]/[application name]/[stream_ID]
Where:
- media server IP - is the IP of your media server (if you use Wowza Media Server or Adobe Media Server it is the IP of the machine where the server is installed);
- port number - is the port number for streaming (by default it is "1935");
- application name - is the name of the server's application (for example, "live");
- stream ID - is the ID of your stream to the media server.
Implementing secure streaming
RTSP streaming in MFormats and MPlatform SDKs is FFmpeg-based so there are different approaches in streaming to a protected server (it depends on server configuration). So please try using one of the following approaches for target URL:
rtsp://[LOGIN]:[PASSWORD]@[media server IP]:[port number]/[application name]/[stream_ID]
or
rtsp://[media server IP]:[port number]/[application name] flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) live=true pubUser=[LOGIN] pubPasswd=[PASSWORD] playpath=[stream_ID]
or
rtsp://[media server IP]:[port number]/[application name]?username=password/[stream_ID]
Trying RTSP streaming with Writer Sample
1. Run the Writer sample, configure your source and select RTSP Streaming as encoding format:
2. Choose the video and audio codecs.
3. Paste the destination URL into the URL field and start streaming by clicking "Start Record" button.
Additional parameters
If you make a double click on the type "format" in Writer Sample you will see the list of the additional parameters for the RTSP streaming. When you change or select these parametres in form-they will automatically add to your encoding configuration. Also, you can add this parametre to the encoding configuration without calling this form.
Parameters for RTSP streaming
Parameter | Description |
---|---|
split_channels='0' |
Split audio channels to 1,2,4,6,8 channels. |
embed_cc='false' |
Enable embedding Closed Captions (ATSC) into the elementary video stream (only for MPEG-2, MPEG-4, H.264 video). |
rtpflags |
RTP muxer flags
|
rtsp_transport |
set RTSP transport protocol
|
min_port='5000' |
Set the minimum local UDP port. |
max_port='6500' | Set the maximum local UDP port. |
buffer_size = '-1' | Underlying protocol send/receive buffer size. |