Medialooks Knowledge Base Support Center

Contact Us

RTMP streaming

Real Time Messaging Protocol (RTMP) is used for high-speed transmission of audio, video, and data between a player and a server. You can make RTMP streaming to media servers with an MFWriter or an MWriter object.

Usually, a media server is used for RTMP streaming. So, MFormats's encoder will stream to the media server, and the media server will deliver the stream to end users.

Some of the media servers used for RTMP streaming are:

Some media servers, including Wowza and Adobe, support FLV H.263 video. But the more common encoding format is H.264.

To configure your MFWriter object you should select RTMP streaming format and select required audio and video codecs. Result configuration looks like:

 format='flv' protocol='rtmp://' video::codec='n264' audio::codec='libmp3lame' audio::ar='44100'

If your target server is external one (YouTube, Akamai etc) you should add video::g='60' to your configuration to make streaming stable.

Implementing RTMP streaming in the code

Here's an example on how to configure RTMP streaming:

MFormats SDK:

MFWriter myWriter = new MFWriter();
string myConfiguration = @" format='flv' protocol='rtmp://' video::codec='n264' audio::codec='libmp3lame' audio::ar='44100'";
string destinationURL = @"rtmp://";
myWriter.WriterSet(destinationURL, 1, myConfiguration);

and then you can use myWriter object as a receiver to put frames to make RTMP streaming:

// a frame object
MFFrame myFrame;
// grab a frame
((IMFSource)myLiveSource).SourceFrameGet(-1, out myFrame, "");
// send to receiver
((IMFReceiver)myWriter).ReceiverFramePut(myFrame, -1, "");

MPlatform SDK

// Set up your source object, for example a device
// ...
// Start your source object
// Initialize a new instance of MWriter object
myWriter = new MWriterClass();
// Set destination URL and capturing configuration
myWriter.WriterNameSet(myTargetURL, @"format='flv' protocol='rtmp://' merge_tracks='true' video::codec='n264' audio::codec='libmp3lame' audio::ar='44100'");
// Start a streaming process

Destination URL structure

The destination URL for RTMP streaming looks like this:

rtmp://[media server IP]:[port number]/[application name]/[stream_ID]


If you use external media servers (such as YouTube), all these parameters will be provided to you upon setting your channel upon the server's side.

Implementing secure streaming

RTMP 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:

rtmp://[LOGIN]:[PASSWORD]@[media server IP]:[port number]/[application name]/[stream_ID]


rtmp://[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]


rtmp://[media server IP]:[port number]/[application name]?username=password/[stream_ID]

Trying RTMP streaming with Writer Sample

1. Run the Writer sample, configure your source and select RTMP 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.