Streaming flv video to JW FLV media player 4.0

Igor Sysoev is at rambler-co.ru
Fri Jul 4 15:50:09 MSD 2008


On Fri, Jul 04, 2008 at 01:30:57PM +0200, Thomas wrote:

> Why is my rewrite rule not working as expected? My video still doesn't
> want to scrub correctly.
> 
> Using the following config:
> ---
>   location ~ ^/videos/[\w|-]+\.flv.* {
>     rewrite ^/(videos)/([\w|-]+\.flv\?start=\d+).* /$1/$2 break;
>     root          /public;
>     flv;
>   }
> ---
> 
> Using my regexp tool, I get the following:
> 
> Request:
> /videos/video.flv?start=3850792&width=280&client=FLASH%20MAC%209,0,124,0&version=4.0%20$Rev:%2030%20$
> 
> Gets rewritten as:
> /videos/video.flv?start=3850792
> 
> Am I not understanding how Nginx rewrite and location work?

rewrite does work not with a query string.

Try the attached patch: it allows several values in query string.


-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/http/modules/ngx_http_flv_module.c
===================================================================
--- src/http/modules/ngx_http_flv_module.c	(revision 1405)
+++ src/http/modules/ngx_http_flv_module.c	(working copy)
@@ -60,7 +60,7 @@
 static ngx_int_t
 ngx_http_flv_handler(ngx_http_request_t *r)
 {
-    u_char                    *p, *last;
+    u_char                    *p, *n, *last;
     off_t                      start, len;
     size_t                     root;
     ngx_int_t                  rc;
@@ -169,8 +169,14 @@
         if (p) {
             p += 6;
 
-            start = ngx_atoof(p, r->args.len - (p - r->args.data));
+            for (n = p; n < r->args.data + r->args.len; n++) {
+                if (*n == '&') {
+                    break;
+                }
+            }
 
+            start = ngx_atoof(p, n - p);
+
             if (start == NGX_ERROR || start >= len) {
                 start = 0;
             }


More information about the nginx mailing list