Welcome! Log In Create A New Profile

Advanced

String replace in .m3u8 file

Posted by rfocus_streamer 
String replace in .m3u8 file
May 15, 2015 11:37AM
Hello, how to replace some string from proxy_pass but from remote file ?!

proxy_pass http://domen.com/test/playlist.m3u8;
sub_filter 'EXTM3U' 'newstring';
sub_filter_once off;
subs_filter 'EXTM3U' 'newstring' i;

I can replace string if is not .m3u8 but if is on .m3u8 then I have a problem

Thanks
Re: String replace in .m3u8 file
May 15, 2015 12:33PM
Can you be a bit more clearer in what you want to happen (or not to happen) ?

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: String replace in .m3u8 file
May 15, 2015 01:25PM
Thanks for your answer, I use proxy_pass to hide real url for m3u8 file from onother server, proxy working but I need to change string in that file.

For example if I open on browser url http://127.0.0.1:8080/test I get over proxy_pass

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1000000
chunklist_w000000_x1000000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2500000
chunklist_w000000_x2500000.m3u8

So I need to change for example "#EXTM3U" to be :

newstring
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1000000
chunklist_w000000_x1000000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2500000
chunklist_w000000_x2500000.m3u8

I hope now is clear !
Re: String replace in .m3u8 file
May 15, 2015 02:28PM
Ok, but you said;
"I can replace string if is not .m3u8 but if is on .m3u8 then I have a problem"

Can you explain what the problem is?
To me this seems to be working.

If you do a curl -h "http://domen.com/test/playlist.m3u8"
and you want to hide playlist.m3u8, you replace playlist.m3u8 with playlist.xxxx

Maybe this http://serverfault.com/questions/489672/nginx-url-rewrite-with-string-substitution
or this http://wiki.nginx.org/NginxHttpRewriteModule

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: String replace in .m3u8 file
May 15, 2015 05:20PM
No the problem is if I use for example :

proxy_pass http://domen.com/test/someurl
sub_filter 'EXTM3U' 'newstring';
sub_filter_once off;
subs_filter 'EXTM3U' 'newstring' i;

replace is working, but if is m3u8 file from remote host then not working !

So I need to modifi that maybe is download file then to serve to browser !
Re: String replace in .m3u8 file
May 16, 2015 03:17AM
Maybe use another location block to loop-back where you can change the name (or request something else) and stream via this extra block.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: String replace in .m3u8 file
May 17, 2015 06:20AM
I trying also that but not working !

Any onother example ?
Re: String replace in .m3u8 file
May 17, 2015 07:57AM
I resolve problem with lua code :

location /hls01{
more_set_headers 'Content-Type: text/plain';
proxy_pass http://domen.com/test/playlist.m3u8;
}

location /newhls01{
default_type 'text/plain';

content_by_lua '
local res = ngx.location.capture("/hls01")
if res.status == 200 then
izmena = ngx.re.gsub(res.body, "EXTM3U", "newstring")
ngx.print(izmena)
end';
}

Thanks for your help
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 132
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready