Skip to content

Commit a53ce02

Browse files
committed
add playlist support
initial commit
1 parent 8f0822f commit a53ce02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+8860
-3970
lines changed

README.md

+203-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55

66
* On-the-fly repackaging of MP4 files to DASH, HDS, HLS, MSS
77

8-
* Adaptive bitrate support
9-
108
* Working modes:
119
1. Local - serve locally accessible files (local disk/NFS mounted)
1210
2. Remote - serve files accessible via HTTP using range requests
1311
3. Mapped - perform an HTTP request to map the input URI to a locally accessible file
1412

13+
* Adaptive bitrate support
14+
15+
* Playlist support (playing several different media files one after the other) - mapped mode only
16+
1517
* Fallback support for file not found in local/mapped modes (useful in multi-datacenter environments)
1618

1719
* Video codecs: H264, H265 (DASH/HLS)
@@ -93,7 +95,7 @@ baseurl = http://installrepo.kaltura.org/releases/latest/RPMS/$basearch/
9395
#### Debian/Ubuntu deb package
9496
```
9597
# wget -O - http://installrepo.kaltura.org/repo/apt/debian/kaltura-deb.gpg.key|apt-key add -
96-
# echo "deb http://installrepo.kaltura.org/repo/apt/debian jupiter main" > /etc/apt/sources.list.d/kaltura.list
98+
# echo "deb [arch=amd64] http://installrepo.kaltura.org/repo/apt/debian kajam main" > /etc/apt/sources.list.d/kaltura.list
9799
# apt-get update
98100
# apt-get install kaltura-nginx
99101
```
@@ -162,6 +164,204 @@ Where:
162164
The default is to include the first audio and first video tracks of each file.
163165
The tracks selected on the file name are AND-ed with the tracks selected with the /tracks/ path parameter.
164166

167+
### Mapping response format
168+
169+
When configured to run in mapped mode, nginx-vod-module issues an HTTP request to a configured upstream server
170+
in order to receive the layout of media streams it should generate.
171+
The response has to be in JSON format, this section contains are a few simple examples followed by a reference
172+
of the supported objects and fields.
173+
174+
But first, a couple of definitions:
175+
1. `Source Clip` - a set of audio and/or video frames (tracks) extracted from a single media file
176+
2. `Filter` - a manipulation that can be applied on audio/video frames. The following filters are supported:
177+
* rate (speed) change - applies to both audio and video
178+
* audio volume change
179+
* mix - can be used to merge several audio tracks together, or to merge the audio of source A with the video of source B
180+
2. `Clip` - the result of applying zero or more filters on a set of source clips
181+
3. `Sequence` - a set of clips that should be played one after the other.
182+
4. `Set` - several sequences that play together as an adaptive set, each sequence must have the same number of clips.
183+
184+
#### Simple mapping
185+
186+
The JSON below maps the request URI to a single MP4 file:
187+
```
188+
{
189+
"sequences" : [
190+
{
191+
"clips": [
192+
{
193+
"type": "source",
194+
"path": "/path/to/video.mp4"
195+
}
196+
]
197+
}
198+
]
199+
}
200+
```
201+
202+
When using multi URLs, this is the only allowed JSON pattern. In other words, it is not
203+
possible to combine more complex JSONs using multi URL.
204+
205+
#### Adaptive set
206+
207+
As an alternative to using multi URL, an adaptive set can be defined via JSON:
208+
```
209+
{
210+
"sequences" : [
211+
{
212+
"clips": [
213+
{
214+
"type": "source",
215+
"path": "/path/to/bitrate1.mp4"
216+
}
217+
]
218+
},
219+
{
220+
"clips": [
221+
{
222+
"type": "source",
223+
"path": "/path/to/bitrate2.mp4"
224+
}
225+
]
226+
}
227+
]
228+
}
229+
```
230+
231+
#### Playlist
232+
233+
The JSON below will play 35 seconds of video1 followed by 22 seconds of video2:
234+
```
235+
{
236+
"durations" : [ 35000, 22000 ],
237+
"sequences" : [
238+
{
239+
"clips": [
240+
{
241+
"type": "source",
242+
"path": "/path/to/video1.mp4"
243+
},
244+
{
245+
"type": "source",
246+
"path": "/path/to/video2.mp4"
247+
}
248+
]
249+
}
250+
]
251+
}
252+
```
253+
254+
#### Filters
255+
256+
The JSON below takes video1, plays it at x1.5 and mixes the audio of the result with the audio of video2,
257+
after reducing it to 50% volume:
258+
```
259+
{
260+
"sequences" : [
261+
{
262+
"clips": [
263+
{
264+
"type": "mixFilter",
265+
"sources": [
266+
{
267+
"type": "rateFilter",
268+
"rate": 1.5,
269+
"source": {
270+
"type": "source",
271+
"path": "/path/to/video1.mp4"
272+
}
273+
},
274+
{
275+
"type": "gainFilter",
276+
"gain": 0.5,
277+
"source": {
278+
"type": "source",
279+
"path": "/path/to/video2.mp4",
280+
"tracks": "a1"
281+
}
282+
}
283+
]
284+
}
285+
]
286+
}
287+
]
288+
}
289+
```
290+
291+
### Mapping reference
292+
293+
#### Set (top level object in the mapping JSON)
294+
295+
Mandatory fields:
296+
* `sequences` - array of Sequence objects.
297+
The mapping has to contain at least one sequence and up to 32 sequences.
298+
299+
Optional fields:
300+
* `durations` - an array of integers representing clip durations in milliseconds.
301+
This field is mandatory if the mapping contains more than a single clip per sequence.
302+
If specified, this array must contain at least one element and up to 128 elements.
303+
* `discontinuity` - boolean, indicates whether the different clips in each sequence have
304+
different media parameters. This field has different manifestations according to the
305+
delivery protocol - a value of true will generate `#EXT-X-DISCONTINUITY` in HLS,
306+
and a multi period MPD in DASH. The default value is true, set to false only if the media
307+
files were transcoded with exactly the same parameters (in AVC for example,
308+
the clips should have exactly the same SPS/PPS).
309+
* `consistentSequenceMediaInfo` - boolean, currently affects only DASH. When set to true (default)
310+
the MPD will report the same media parameters in each period element. Setting to false
311+
can have severe performance implications for long sequences (nginx-vod-module has
312+
to read the media info of all clips included in the mapping in order to generate the MPD)
313+
314+
#### Sequence
315+
316+
Mandatory fields:
317+
* `clips` - array of Clip objects (mandatory). The number of elements must match the number
318+
the durations array specified on the set. If the durations array is not specified,
319+
the clips array must contain a single element.
320+
321+
#### Clip (abstract)
322+
323+
Mandatory fields:
324+
* `type` - a string that defines the type of the clip. Allowed values are:
325+
* source
326+
* rateFilter
327+
* mixFilter
328+
* gainFilter
329+
330+
#### Source clip
331+
332+
Mandatory fields:
333+
* `type` - a string with the value `source`
334+
* `path` - a string containing the path of the MP4 file
335+
336+
Optional fields:
337+
* `tracks` - a string that specifies the tracks that should be used, the default is "v1-a1",
338+
which means the first video track and the first audio track
339+
* `clipFrom` - an integer that specifies an offset in milliseconds, from the beginning of the
340+
media file, from which to start loading frames
341+
342+
#### Rate filter clip
343+
344+
Mandatory fields:
345+
* `type` - a string with the value `rateFilter`
346+
* `rate` - a float that specified the acceleration factor, e.g. a value of 2 means double speed.
347+
Allowed values are in the range 0.5 - 2 with up to two decimal points
348+
* `source` - a clip object on which to perform the rate filtering
349+
350+
#### Gain filter clip
351+
352+
Mandatory fields:
353+
* `type` - a string with the value `gainFilter`
354+
* `gain` - a float that specified the amplification factor, e.g. a value of 2 means twice as loud.
355+
The gain must be positive with up to two decimal points
356+
* `source` - a clip object on which to perform the gain filtering
357+
358+
#### Mix filter clip
359+
360+
Mandatory fields:
361+
* `type` - a string with the value `mixFilter`
362+
* `sources` - an array of Clip objects to mix. This array must contain at least one clip and
363+
up to 32 clips.
364+
165365
### DRM
166366

167367
Nginx-vod-module has the ability to perform on-the-fly encryption for MPEG DASH (CENC) and MSS Play Ready.

config

+17-6
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,18 @@ NGX_ADDON_DEPS="$NGX_ADDON_DEPS \
8181
$ngx_addon_dir/ngx_http_vod_utils.h \
8282
$ngx_addon_dir/ngx_perf_counters.h \
8383
$ngx_addon_dir/ngx_perf_counters_x.h \
84-
$ngx_addon_dir/ngx_simple_json_parser.h \
85-
$ngx_addon_dir/vod/audio_filter.h \
8684
$ngx_addon_dir/vod/avc_defs.h \
8785
$ngx_addon_dir/vod/bit_read_stream.h \
8886
$ngx_addon_dir/vod/codec_config.h \
8987
$ngx_addon_dir/vod/common.h \
9088
$ngx_addon_dir/vod/dash/dash_packager.h \
9189
$ngx_addon_dir/vod/dash/edash_packager.h \
9290
$ngx_addon_dir/vod/dynamic_buffer.h \
93-
$ngx_addon_dir/vod/full_frame_processor.h \
91+
$ngx_addon_dir/vod/filters/audio_filter.h \
92+
$ngx_addon_dir/vod/filters/filter.h \
93+
$ngx_addon_dir/vod/filters/gain_filter.h \
94+
$ngx_addon_dir/vod/filters/mix_filter.h \
95+
$ngx_addon_dir/vod/filters/rate_filter.h \
9496
$ngx_addon_dir/vod/hds/hds_amf0_encoder.h \
9597
$ngx_addon_dir/vod/hds/hds_amf0_fields_x.h \
9698
$ngx_addon_dir/vod/hds/hds_fragment.h \
@@ -108,7 +110,10 @@ NGX_ADDON_DEPS="$NGX_ADDON_DEPS \
108110
$ngx_addon_dir/vod/hls/mpegts_encoder_filter.h \
109111
$ngx_addon_dir/vod/hls/sample_aes_aac_filter.h \
110112
$ngx_addon_dir/vod/hls/sample_aes_avc_filter.h \
113+
$ngx_addon_dir/vod/json_parser.h \
111114
$ngx_addon_dir/vod/list_entry.h \
115+
$ngx_addon_dir/vod/media_set.h \
116+
$ngx_addon_dir/vod/media_set_parser.h \
112117
$ngx_addon_dir/vod/mp4/mp4_builder.h \
113118
$ngx_addon_dir/vod/mp4/mp4_clipper.h \
114119
$ngx_addon_dir/vod/mp4/mp4_defs.h \
@@ -117,6 +122,7 @@ NGX_ADDON_DEPS="$NGX_ADDON_DEPS \
117122
$ngx_addon_dir/vod/mp4/mp4_parser_base.h \
118123
$ngx_addon_dir/vod/mss/mss_packager.h \
119124
$ngx_addon_dir/vod/mss/mss_playready.h \
125+
$ngx_addon_dir/vod/parse_utils.h \
120126
$ngx_addon_dir/vod/read_cache.h \
121127
$ngx_addon_dir/vod/read_stream.h \
122128
$ngx_addon_dir/vod/segmenter.h \
@@ -141,14 +147,16 @@ NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
141147
$ngx_addon_dir/ngx_http_vod_udrm.c \
142148
$ngx_addon_dir/ngx_http_vod_utils.c \
143149
$ngx_addon_dir/ngx_perf_counters.c \
144-
$ngx_addon_dir/ngx_simple_json_parser.c \
145-
$ngx_addon_dir/vod/audio_filter.c \
146150
$ngx_addon_dir/vod/codec_config.c \
147151
$ngx_addon_dir/vod/common.c \
148152
$ngx_addon_dir/vod/dash/dash_packager.c \
149153
$ngx_addon_dir/vod/dash/edash_packager.c \
150154
$ngx_addon_dir/vod/dynamic_buffer.c \
151-
$ngx_addon_dir/vod/full_frame_processor.c \
155+
$ngx_addon_dir/vod/filters/audio_filter.c \
156+
$ngx_addon_dir/vod/filters/filter.c \
157+
$ngx_addon_dir/vod/filters/gain_filter.c \
158+
$ngx_addon_dir/vod/filters/mix_filter.c \
159+
$ngx_addon_dir/vod/filters/rate_filter.c \
152160
$ngx_addon_dir/vod/hds/hds_amf0_encoder.c \
153161
$ngx_addon_dir/vod/hds/hds_fragment.c \
154162
$ngx_addon_dir/vod/hds/hds_manifest.c \
@@ -162,13 +170,16 @@ NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
162170
$ngx_addon_dir/vod/hls/mpegts_encoder_filter.c \
163171
$ngx_addon_dir/vod/hls/sample_aes_aac_filter.c \
164172
$ngx_addon_dir/vod/hls/sample_aes_avc_filter.c \
173+
$ngx_addon_dir/vod/json_parser.c \
174+
$ngx_addon_dir/vod/media_set_parser.c \
165175
$ngx_addon_dir/vod/mp4/mp4_builder.c \
166176
$ngx_addon_dir/vod/mp4/mp4_clipper.c \
167177
$ngx_addon_dir/vod/mp4/mp4_encrypt.c \
168178
$ngx_addon_dir/vod/mp4/mp4_parser.c \
169179
$ngx_addon_dir/vod/mp4/mp4_parser_base.c \
170180
$ngx_addon_dir/vod/mss/mss_packager.c \
171181
$ngx_addon_dir/vod/mss/mss_playready.c \
182+
$ngx_addon_dir/vod/parse_utils.c \
172183
$ngx_addon_dir/vod/read_cache.c \
173184
$ngx_addon_dir/vod/segmenter.c \
174185
$ngx_addon_dir/vod/write_buffer.c \

ngx_child_http_request.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ ngx_merge_upstream_conf(
10821082
}
10831083

10841084
hash.max_size = 512;
1085-
hash.bucket_size = 64;
1085+
hash.bucket_size = ngx_align(64, ngx_cacheline_size);
10861086
hash.name = "child_request_headers_hash";
10871087

10881088
if (ngx_http_upstream_hide_headers_hash(cf, conf_upstream,

0 commit comments

Comments
 (0)