[FFmpeg-devel] [PATCH/RFC] Detecting EOF in RTMP

Martin Storsjö martin
Fri Dec 11 12:16:48 CET 2009

On Thu, 10 Dec 2009, Kostya wrote:

> On Thu, Dec 10, 2009 at 12:12:50PM -0500, compn wrote:
> > On Thu, 10 Dec 2009 17:23:03 +0200, Kostya wrote:
> > >On Thu, Dec 10, 2009 at 04:37:59PM +0200, Martin Storsj? wrote:
> > >> 
> > >> When the live broadcast ends, the current rtmp protocol handler doesn't 
> > >> detect this as an eof, and thus sits and waits for more data on the 
> > >> connection.
> > >
> > >Looks like Wowza does not follow RTMP standards :(.

What would be the proper standard way of indicating that the stream has 
reached the end, by the way? I tried all the streams on the RTMP 
MultimediaWiki page (most of them were dead, but a few of them worked), 
and found a few different cases:

- Some streams end without sending a single hint that there won't be any 
more data (e.g. 

- Some streams send a NetStream.Play.Stop event, followed by a server 
error (e.g., 
rtmp://fl9.maelstrom.jet-stream.nl:80/vod/vdoxadmin/jeroen/bunny.mp3 sends 
this immediately, to indicate that the file isn't found at all)

- Some streams send an NetStream.Play.UnpublishNotify event, followed by a 
server error ("Failed to play foobar; stream not found."), when the stream 
ends. This occurred with the "live" example in Wowza.

- Some streams send an NetStream.Play.Stop event, not followed by any 
server error. This occurred when serving a static file through Wowza.

In my patch from yesterday, I reacted to the 
NetStream.Publish.UnpublishNotify event, but when testing things today, I 
only receive NetStream.Play.UnpublishNotify events instead. Either the 
former was a mistake in documenting my findings yesterday, or some servers 
can return either one. I only kept the Play.UnpublishNotify version for 

Adding the STREAM_STOPPED behaviour as in my patch makes some of these eof 
error messages be lost, since the Stop/Unpublish status codes preceding 
the error messages terminate reading from the stream at that time.

> > is it possible to detect wowza server and then use non-standard exit
> > procedure?
> Yes, it sends notification with full server name and version. 

I guess that would be an option, but I'm not sure if this is a general 
wowza-specific behaviour.

Attached is an updated patch.

Kostya, do you want me to add wowza detection and enable this only in that 
particular case?

// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-rtmp-eof.patch
Type: text/x-diff
Size: 1978 bytes
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091211/0c92eaf9/attachment.patch>

More information about the ffmpeg-devel mailing list