// ---------------------------------------------------------------------------
-const LAST_MIGRATION_VERSION = 525
+const LAST_MIGRATION_VERSION = 530
// ---------------------------------------------------------------------------
'audio/x-ms-wma': '.wma',
'audio/wav': '.wav',
'audio/x-flac': '.flac',
- 'audio/flac': '.flac'
+ 'audio/flac': '.flac',
+ '‎audio/aac': '.aac',
+ 'audio/ac3': '.ac3'
},
EXT_MIMETYPE: null as { [ id: string ]: string }
},
VIDEO: {
- MIMETYPE_EXT: null as { [ id: string ]: string },
+ MIMETYPE_EXT: null as { [ id: string ]: string | string[] },
+ MIMETYPES_REGEX: null as string,
EXT_MIMETYPE: null as { [ id: string ]: string }
},
IMAGE: {
}
const LAZY_STATIC_PATHS = {
AVATARS: '/lazy-static/avatars/',
- PREVIEWS: '/static/previews/',
- VIDEO_CAPTIONS: '/static/video-captions/'
+ PREVIEWS: '/lazy-static/previews/',
+ VIDEO_CAPTIONS: '/lazy-static/video-captions/'
}
// Cache control
function buildVideoMimetypeExt () {
const data = {
+ // streamable formats that warrant cross-browser compatibility
'video/webm': '.webm',
- 'video/ogg': '.ogv',
+ // We'll add .ogg if additional extensions are enabled
+ // We could add .ogg here but since it could be an audio file,
+ // it would be confusing for users because PeerTube will refuse their file (based on the mimetype)
+ 'video/ogg': [ '.ogv' ],
'video/mp4': '.mp4'
}
if (CONFIG.TRANSCODING.ENABLED) {
if (CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS) {
+ data['video/ogg'].push('.ogg')
+
Object.assign(data, {
- 'video/quicktime': '.mov',
- 'video/x-msvideo': '.avi',
- 'video/x-flv': '.flv',
'video/x-matroska': '.mkv',
- 'video/avi': '.avi',
+
+ // Developed by Apple
+ 'video/quicktime': [ '.mov', '.qt', '.mqv' ], // often used as output format by editing software
'video/x-m4v': '.m4v',
+ 'video/m4v': '.m4v',
+
+ // Developed by the Adobe Flash Platform
+ 'video/x-flv': '.flv',
+ 'video/x-f4v': '.f4v', // replacement for flv
+
+ // Developed by Microsoft
+ 'video/x-ms-wmv': '.wmv',
+ 'video/x-msvideo': '.avi',
+ 'video/avi': '.avi',
+
+ // Developed by 3GPP
+ // common video formats for cell phones
+ 'video/3gpp': [ '.3gp', '.3gpp' ],
+ 'video/3gpp2': [ '.3g2', '.3gpp2' ],
+
+ // Developed by FFmpeg/Mplayer
+ 'application/x-nut': '.nut',
+
+ // The standard video format used by many Sony and Panasonic HD camcorders.
+ // It is also used for storing high definition video on Blu-ray discs.
+ 'video/mp2t': '.mts',
+ 'video/m2ts': '.m2ts',
+
+ // Old formats reliant on MPEG-1/MPEG-2
+ 'video/mpv': '.mpv',
+ 'video/mpeg2': '.m2v',
+ 'video/mpeg': [ '.m1v', '.mpg', '.mpe', '.mpeg', '.vob' ],
+ 'video/dvd': '.vob',
+
// Could be anything
'application/octet-stream': null,
- 'video/m4v': '.m4v'
+ 'application/mxf': '.mxf' // often used as exchange format by editing software
})
}
function updateWebserverConfig () {
MIMETYPES.VIDEO.MIMETYPE_EXT = buildVideoMimetypeExt()
- MIMETYPES.VIDEO.EXT_MIMETYPE = invert(MIMETYPES.VIDEO.MIMETYPE_EXT)
+ MIMETYPES.VIDEO.MIMETYPES_REGEX = buildMimetypesRegex(MIMETYPES.VIDEO.MIMETYPE_EXT)
+
ACTIVITY_PUB.URL_MIME_TYPES.VIDEO = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT)
- CONSTRAINTS_FIELDS.VIDEOS.EXTNAME = buildVideosExtname()
+ MIMETYPES.VIDEO.EXT_MIMETYPE = buildVideoExtMimetype(MIMETYPES.VIDEO.MIMETYPE_EXT)
+
+ CONSTRAINTS_FIELDS.VIDEOS.EXTNAME = Object.keys(MIMETYPES.VIDEO.EXT_MIMETYPE)
+}
+
+function buildVideoExtMimetype (obj: { [ id: string ]: string | string[] }) {
+ const result: { [id: string]: string } = {}
+
+ for (const mimetype of Object.keys(obj)) {
+ const value = obj[mimetype]
+ if (!value) continue
+
+ const extensions = Array.isArray(value) ? value : [ value ]
+
+ for (const extension of extensions) {
+ result[extension] = mimetype
+ }
+ }
+
+ return result
}
-function buildVideosExtname () {
- return Object.keys(MIMETYPES.VIDEO.EXT_MIMETYPE)
+function buildMimetypesRegex (obj: { [id: string]: string | string[] }) {
+ return Object.keys(obj)
+ .map(m => `(${m})`)
+ .join('|')
}
function loadLanguages () {
jsl: true, // Japanese sign language
sfs: true, // South African sign language
swl: true, // Swedish sign language
- rsl: true, // Russian sign language: true
+ rsl: true, // Russian sign language
+
+ kab: true, // Kabyle
epo: true, // Esperanto
tlh: true, // Klingon