Showing posts from November, 2010


RTMPDUMP is a good tools to dump rtmp stream into a file and analyze the rtmp protocol.
Below are some commands
rtmpdump.exe -r "rtmp://host:port/app/path/file.mp4" -o "output.mp4" -z
Variables app -> your rtmp application name path -> your rtmp path in the application to the file (optional) file.mp4 -> your VOD file name output.mp4 -> your output file name to local disk
Commands -z -> debug print mode -r -> rtmp url -o -> output file
rtmpdump.exe -r "rtmp://host:port/app/path" -v -y "" -o "output.mp4" -z
Variables app -> your rtmp application name path -> your rtmp path in the application to the file (optional) -> your live stream path output.mp4 -> your output file name to local disk
Commands -z -> debug print mode -r -> rtmp url -o -> output file -v -> live stream (denoting this will provide play time to a negative value) -y -> the play path for your stream
If you run rtmpdump at…

RTMP Part 10 - Handshake

In the RTMP specification provided by Adobe, it did not mention the importance of handshake.
Also, the RTMP specification 1.0 that is widely available online is "outdated". The reason it is "outdated" because this specification defined the handshake only for flv streaming. If you use this handshake for connecting H.264 stream, it will never work. Below are from RTMP specification 1.0 handshake

In the RTMP 1.0 specification, 5th to 8th bytes are zero bytes in the first client and server message. That in turn saying that it only support flv stream. The client will not play the H.264 stream even if you have sent correct onMetaData and configuration information. So, if you are working on a flash media server for serving H.264 stream, you should take note of this handshake.
Client versions equal to or greater than Flash 9,0,124,0 require a nonzero value as the fifth byte of the handshake request. Furthermore, Flash seems have changed the handshake again.
I will …


In general, RTMP server accept 2 types of URL connection.
1. Flash player
Open source player such as flowplayer and JW Player use this format
I am referring to flowplayer in this example, but in general, they have the equivalent variables.

Most server requires you to define at least an application name.
For URL, they commonly support format tag flv, m4v, mp4. So, for flv, it will be

In Wowza VOD example, the RTMP setting for flowplayer will be

2. Single RTMP URL
There are application that requires only single RTMP URL. For example, VLC and rmptdump.exe
The single RTMP URL is

For using rtmpdump to connect to Wowza VOD, the RTMP URL is

Please note that most single RTMP URL treat and information after application instance as path to the file. For example

These 2 URL is the same. They are referring that sample.mp4 is at the path folder1/folder2/ of the vod/app1.

MP4 File Format Part 2

ISO IEC 14496-12 defined the base media file format for MPEG file structure.
ISO IEC 14496-15 Information technology — Coding of audio-visual objects — Part 15: Advanced Video Coding (AVC) file format extends part 12 to provide specific atom/box type for AVC (H.264)
Mdat Atom
As mdat is about frame, I have to mention about AVC sample structure

ISO 14496-15 define AVC sample structure as externally framed sample and have a frame length supplied by external framing. Thus, AVC access unit means a set of NAL units where each NAL has
a usually 4 bytes fields to denote the frame sizefollowed by a NAL unit
With that in mind, the screenshot shows a the red box denote the frame size (4 bytes). The blue box is the start of the frame, in this case, it is H.264 Non-IDR frame. See 5.2.3 of that document.
AVC Decoder Configuration Record
H.264 require decoder configuration data to initialize the decoder prior to any decoding process. Thus, MP4 file must have this record in the Movie Box.
These decoder confi…

MP4 File Format Part 1

This is a MP4 file format notes that reference from ISO IEC 14496-12 2005 edition about Information technology — Coding of audio-visual objects — Part 12: ISO base media file format
This is not designed for details explanation of each atom. For detail information, please read the ISO IEC 14496-12 document.
General Format

In general, MP4 file format has the following structure
ftyp File type box that denote the mp4 media type mdat Media data box which contains the actual AV frames.Within a mdat, there are chunks and samples moov Movie box which is the container for all metadataEach moov has have a mvhd (Movie header box)It can contains N trak box. Each trak box contains media specific meta data information Usually, it will have 2 tracks (video and audio)More importantly, it contains sample information such as stsd, stts, stsz stsc, stco, etc...
Mdat Atom
MPEG4 sample

H.264 sample

Mdat is the media data atom which contain video and audio frames. As you can see from the screenshot, it is separated in…