Wowza Community

Set Token security valid time per stream length

Hi, we have successfully implemented Token security in our HLS streams, works very good but we want to improve even more this.

We have a lot of types of videos from, little snippets up to 8 hour long conferences, we have with a very time to live token (24 hours), but we want that the token be generated by the length of the video dynamically, so a video snippet of 2 minutes can have a token that will live 2 minutes + an offset and the 8 hour long video a token of about 8 hours + an offset.

Is there a way that I can get the length of the video from the m3u8 or other means?

One trick: If you get the initial playlist.m3u8 and open it, it’ll point you to a chunklist.m3u8 - if you open that one with a text reader, you can take the sum of all the EXTINF values, that’ll give you the length of the VOD asset in seconds.

Another option is to implement an HttpProvider or an API outside Wowza that uses something like ffprobe to get the length.

Hi, for the vod assets, I generally use the ffmpeg ( ffprobe ) in my backend code.

ffprobe -v quiet -print_format json -show_format -show_streams video.mp4

this will give you the all video info with duration. you can also get only the duration itself with grep pipe

ffprobe -i video.mp4 -show_format | grep duration

Also there is lots of ffmpeg library for each backend such as php java and .net that use ffmpeg to get video details.