kaltura / nginx-vod-module

NGINX-based MP4 Repackager
GNU Affero General Public License v3.0
2k stars 439 forks source link

Using variables in vod_hls_segment_file_name_prefix and vod_dash_fragment_file_name_prefix #1539

Open nonth opened 2 months ago

nonth commented 2 months ago

Is it possible to use variables, such as $vod_clip_id in the vod_hls_segment_file_name_prefix and vod_dash_fragment_file_name_prefix directives.

Our use case is as follows:

  1. A video player requests a video from a URL formatted as {vod_set_id}/master.m3u8 or {vod_set_id}/manifest.mpd
  2. The nginx-vod-module then queries our API to retrieve a mapping response based on the vod_set_id
  3. The API returns a mapping response containing the vod_set_id along with sequences where each sequence has its own vod_sequence_id and corresponding video/audio MP4 file.
  4. The nginx-vod-module uses the response from the API to create the m3u8/mpd file and returns it to the video player.
  5. In our backend, users can change the video or audio MP4 file, which updates the vod_sequence_id in the API response.

We have deployed the nginx-vod-module behind a CDN, which caches the TS/M4S segments. When the scenario described above occurs, we would like to update the segments by altering the segment names using a variable, such as vod_sequence_id

erankor commented 2 months ago

This is not supported. The common solution to the caching issue you described is to change the path of the URL instead. For example, you can use a URL like - http://domain/video/{id}/version/{ver}/master.m3u8. If you change the version, the manifest and all segments get a new URL, and bypass the CDN cache.

nonth commented 2 months ago

Hi @erankor

Thanks for your answer. Unfortunately, the user can’t change the URL of the master playlist (m3u8/mpd) since it’s already being used on their website/app. Is there any way to change the URLs for the sub-playlists (m3u8) or the segment files (TS/M4S) instead?

Thanks again for your help!

erankor commented 1 month ago

You can solve it with HTTP redirection - have the master URL used by the website/app redirect to the nginx-vod-module master URL (cached on the CDN). Then, when you want to publish a new version, you just change the redirection to point a new URL, that has a new version, and therefore bypasses the CDN cache.