Skip to main content
Inspiring
October 25, 2011
Question

Change relative URL of segments for HLS-VOD

  • October 25, 2011
  • 1 reply
  • 6439 views

Simple Version:

Can I change the URL of the TS segments delivered by the hlshttp_module in any way, or is it always relative to the requested m3u8 URL?

Long Version:

To try and protect my content from being accessed by third parties I want to use mod-auth-token, with a client inserted token in the request for the variant m3u8, and a server generated token in the HLS m3u8.

My clients generate a token using a shared secret, and request the variant m3u8 from:

https://myserver/hls-manifest/<clienttoken>/<hextime>/path/to/folder/manifest.m3u8

This page is served dynamically (using php), and does not really have anything to do with FMS even though it is running in the same Apache instance. The m3u8 is generated with server tokens in the m3u8 URLs somethign like this:

#EXTM3U

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=10240000,CODECS="mp4a.40.2, avc1.42001f"

https://myserver/hls-vod/dc226454b9e39b9ffc44f9496505c70e/4ea6963f/path/to/folder/filename_1024k.mp4.m3u8

I have installed mod-auth-token, and configured it on a LocationMatch for "^/hld-vod/(.*)\.m3u8$". Everything up to this works perfectly, and I can request both m3u8 playlists successfully. The problem is that the content of the m3u8 (the ts fragment URLs) are relative to the URL of the m3u8.

#EXTM3U

#EXT-X-MEDIA-SEQUENCE:0

#EXT-X-ALLOW-CACHE:NO

#EXT-X-VERSION:2

#EXT-X-KEY:METHOD=AES-128,URI="https://myserver/hls-key/vodkey.bin",IV=0X560417e9155f2f2cb1fb9410397db72e

#EXT-X-TARGETDURATION:10

#EXTINF:10,

filename_1024k.mp4Frag1Num0.ts

The player is attempting to request files from:

https://myserver/hls-vod/dc226454b9e39b9ffc44f9496505c70e/4ea6963f/path/to/folder/filename_1024k.mp4Frag1Num0.ts

I want this to look more like this:

https://myserver/hls-vod/path/to/folder/filename_1024k.mp4Frag1Num0.ts

or even this:

http://mycacheserver/hls-vod/path/to/folder/filename_1024k.mp4Frag1Num0.ts

So the m3u8 needs to look more like this:

#EXT-X-TARGETDURATION:10

#EXTINF:10,

http://mycacheserver/hls-vod/path/to/folder/filename_1024k.mp4Frag1Num0.ts

I can think of lost of placeswhere this would have  useful applications. There does not appear to be anything in the Developer documents which would help here. Does anybody have a suggestion for something I can try?

This topic has been closed for replies.

1 reply

Adobe Employee
November 1, 2011

Hi Michael,

Thanks for using FMS 4.5 and its new features.

However, there is no way to not to put relative urls for the ts files. However, you might like to do either Apache's "URL rewriting rules" or redirection . For rewriting rules, you might check http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Though, you may suffer in caching benefits. Here, if the id that you have inserted is on per client basis, you may not get the caching benefits on the caching server as it will always caching on basis of

https://myserver/hls-vod/dc226454b9e39b9ffc44f9496505c70e/4ea6963f/pat h/to/folder/filename_1024k.mp4Frag1Num0.ts

while, if you use client side redirect something like

redirect 301 url1 url2

it may help. You might consider other similar solutions for example, client redirect on proxy servers etc.. just be ware of caching in your case (if applicable)

Inspiring
November 9, 2011

Hi Nitin,

Thanks for the response. I considered a RewriteRule, but this would break all caching as you suggest and my Apache ervers would have to process all of the segment requests anyway.

I have implemented a solution using mod_substitute, which gives the functionality I was looking for. Any line which does not start with # is prepended with a path dependant on the file name.

Adobe Employee
November 9, 2011

Its good that you were able to solve the issue.

And thanks for sharing the info. I will definetly check out mod_subsitute.