Open pszemus opened 4 years ago
The idea that I have in mind right now:
/manifest.mpd
http://adserver/dynamic.json
for ads for that userdynamic.json
and generates manifest.mpd
/media/ad1.mp4/fragment-1-v1-x3.m4s
http://mp4storage/ad1.mp4
for /media/ad1.mp4/fragment-1-v1-x3.m4s
In order it to work:
/
and /media
) have to have access to the same mp4 filesmanifest.mpd
returned by location /
(mapped mode) has to have:
media
and initialization
paths prefixed with /media/$mp4filename
That way the dynamic.json
is requested just once, I could cache all the chunks, and they are immutable regardless of their corresponding mp4 file's position in dynamic.json
.
What do you think about that? Chunk numbering and paths could be done in lua module if nginx-vod-module does not have necessary configuration options.
The module outputs continuous timestamps, even in multi-period DASH, so the segments will not be same if they are part of different MPDs. Sounds to me that it may be easiest to have the module perform the segmentation of the media files, and perform the manifest manipulation elsewhere (maybe in some high level language like node.js)
I prepared a proof-of-concept and it works in Google Shaka Player and MPEG-DASH reference player.
I'm downloading a multi-period manifest from:
location / {
vod dash;
vod_mode mapped;
# location of JSON
vod_upstream_location /playlist;
# location of source video files
vod_remote_upstream_location /media-origin;
# TODO:
# - @media and @initialization attributes should be prefixed with /media/$mp4filename/
# - @startNumber attribute should be set to 1
vod_base_url "";
}
<Period>
's @startNumber
to 1 and set base URL for @initialization
and @media
attributes to /media/<put mp4 file name here>
/media/
:
location /media/ {
vod dash;
vod_mode remote;
vod_upstream_location /media-origin;
vod_base_url ""; # relative segment URLs
rewrite ^/media(.*)$ $1 break;
}
As I said before, this stream can be played in Google Shaka Player and MPEG-DASH reference player.
Regarding timestamps: In my proof-of-concept, manifests are served via /
location (mapped mode) whereas all segments are served via /media/
location (remote mode). I checked segment's sidx/earliest_presentation_time
, moof/mfhd/sequence number
and moof/traf/tfdt/base media decode time
and they are starting from 0 in segment No.1 and they are increasing correctly in latter segments. With segment numbering starting from 1 for every <Period>
it is OK to do so, because timestamps also would start from 0 for every <Period>
.
To sum up, in order to accomplish dynamic JSON and static segments, nginx-vod-module should have:
<Period>
:
@startnumber
to 1 moof/mfhd/sequence number
should start from 1vod_base_url
with mp4 file name so that initialization and media URL be different for every <Period>
, eg:
media="/media/rek-g2.mp4/fragment-$Number$-$RepresentationID$.m4s"
initialization="/media/rek-g2.mp4/init-$RepresentationID$.mp4"
Hi I want to concatenate multiple mp4 files in one MPEG-DASH stream.
/dynamic.json/manifest.mpd
nginx will issue a subrequest tohttp://adserver/dynamic.json
that returns different response for different users?