[PATCH] Use specification-compliant FLV header

Maxim Dounin mdounin at mdounin.ru
Fri Nov 18 02:04:13 UTC 2011


Hello!

On Thu, Nov 17, 2011 at 09:56:09PM +0100, Piotr Sikora wrote:

> Hey,
> according to the Flash Video (FLV) specification [1] E.2 & E.3, [2],
> the correct format of the FLV header and the beginning of the stream is:
> 
>    FLV\x01(\x01|\x04|\x05)\x00\x00\x00\x09\x00\x00\x00\x00
> 
> with 5th byte denoting presence of video (\x01), audio (\x04)
> or both (\x05).
> 
> However, nginx is currently using:
> 
>    FLV\x01\x01\x00\x00\x00\x09\x00\x00\x00\x09
> 
> and while denoting presence of only video tags (\x01) isn't strictly
> incorrect, denoting presence of both audio and video (\x05) would match
> "real world" usage much closer.
> 
> The real problem is \x00\x00\x00\x09 in the beginning of the stream
> (denoting size of the previous tag), which is plainly wrong, because
> according to the specification it should be always \x00\x00\x00\x00.
> 
> I'm aware of the fact that virtually all other pseudo-streaming modules
> are using the same incorrect header, but that doesn't mean that nginx
> must use it as well. Attached patch fixes this.
> 
> [1] http://www.adobe.com/devnet/f4v.html
> [2] http://osflash.org/flv#flv_format
> 
> Best regards,
> Piotr Sikora < piotr.sikora at frickle.com >
> 

> --- src/http/modules/ngx_http_flv_module.c.orig	Thu Nov 17 17:53:11 2011
> +++ src/http/modules/ngx_http_flv_module.c	Thu Nov 17 17:53:29 2011
> @@ -23,7 +23,7 @@
>  };
>  
>  
> -static u_char  ngx_flv_header[] = "FLV\x1\x1\0\0\0\x9\0\0\0\x9";
> +static u_char  ngx_flv_header[] = "FLV\x1\x5\0\0\0\x9\0\0\0\0";
>  
>  
>  static ngx_http_module_t  ngx_http_flv_module_ctx = {

The patch looks perfectly correct for me from specification point of 
view, thanks.

What about real world interoperability?  I.e. is it possible 
it will break something?  Was it tested to work properly with 
flv players?

(It looks like youtube uses this header, so I suppose it's safe.  
But I would like to see some testing results.)

Maxim Dounin



More information about the nginx-devel mailing list