-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.lua.example
98 lines (78 loc) · 3.49 KB
/
config.lua.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
config = {}
-- ########## CONFIG ##########
-- change according to your needs
-- `which ffmpeg`
config.ffmpeg = '/usr/local/bin/ffmpeg'
-- where to save original and transcoded files (trailing slash required)
config.mediaBaseFilepath = '/tmp/nginx/'
-- set to `true` to enable originals download from the upstream/CDN. See `getOriginalsUpstreamUrl` below
config.downloadOriginals = true
-- function to get a URL where originals are stored, when `downloadOriginals` set to true.
function config.getOriginalsUpstreamPath(prefix, postfix, filename)
-- return ngx.var.request_uri
return (prefix or '') .. (postfix or '') .. (filename or '')
end
-- character that is used to separate different flags in URL.
-- eg commas in `/w_1280,h_960,c_pad/`
config.flagsDelimiter = ','
-- character that is used to separate flag name from the value.
-- eg underscores in `/w_1280,h_960,c_pad/`
config.flagValueDelimiter = '_'
-- override URL flag names. Useful when you migrate from another transcoding solution and already have
-- some flags in use on the front end. Customize the left part of the table.
-- eg `['cropping'] = 'crop'` to use `cropping` instead of the default `c`
config.flagMap = {
['c'] = 'crop', -- crop / scale
['b'] = 'background',
['dpr'] = 'dpr', -- DPR, https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
-- ['f'] = 'format',
['h'] = 'height',
['w'] = 'width',
['x'] = 'x',
['y'] = 'y',
}
-- override URL flag values. Useful when you migrate from another transcoding solution and already have
-- some flag values in use on the front end. Customize the left part of the table
-- eg `['padded'] = 'pad'` to use `padded` instead of the default `pad`
-- Also, all flag values not present in this table will be considered (and cast to) a number
config.flagValueMap = {
['pad'] = 'padding',
['lpad'] = 'limited_padding',
['fill'] = 'fill',
['blurred'] = 'blur',
}
-- log transcoding process. Useful when doing initial setup or debugging issues
config.logEnabled = false
config.logLevel = ngx.ERR
-- config.logLevel = ngx.INFO
-- config.logLevel = ngx.DEBUG
-- log `ffmpeg` output.
-- If enabled, will log ffmpeg transcoding process output to error log (because that's where ffmpeg outputs to)
config.logFfmpegOutput = false
-- where to redirect ffmpeg output to (if `logFfmpegOutput = false`)
config.ffmpegDevNull = '2> /dev/null' -- nix
-- config.ffmpegDevNull = '2>NUL' -- win
-- whether to prepend transcoding command with `time` utility to log time spent in ffmpeg
config.logTime = false
-- top limit for output video height (default 4k UHD)
config.maxHeight = 2160
-- top limit for output video width (default 4k UHD)
config.maxWidth = 3840
-- customize this function to preprocess flags or their values
-- return values should contain values that are present in `config.flagMap` and `config.flagValueMap`
function config.flagPreprocessHook(flag, value)
-- do some processing
-- strip sub parameters `c_pad:pink` -> `c_pad`
-- value = value:gsub('([^:]+):?.*', '%1')
return flag, value
end
-- serve original file when transcode failed.
config.serveOriginalOnTranscodeFailure = true
-- least required size (in bytes) for the transcoded file to not be considered broken and deleted (default is 1KB)
config.minimumTranscodedFileSize = 1024
-- encoding preset to use https://trac.ffmpeg.org/wiki/Encode/H.264
config.ffmpegPreset = ''
-- config.ffmpegPreset = 'ultrafast'
-- config.ffmpegPreset = 'superfast'
-- config.ffmpegPreset = 'veryfast'
return config