Start adding file playback queue support
This commit is contained in:
parent
30d4e65061
commit
f2769e5062
|
@ -310,7 +310,7 @@ PlaylistModule.prototype.handleQueue = function (user, data) {
|
|||
}
|
||||
|
||||
/* Specifying a custom title is currently only allowed for custom media */
|
||||
if (typeof data.title !== "string" || data.type !== "cu") {
|
||||
if (typeof data.title !== "string" || (data.type !== "cu" && data.type !== "fi")) {
|
||||
data.title = false;
|
||||
}
|
||||
|
||||
|
@ -860,6 +860,14 @@ PlaylistModule.prototype._addItem = function (media, data, user, cb) {
|
|||
});
|
||||
}
|
||||
|
||||
/* Warn about high bitrate for raw files */
|
||||
if (media.type === "fi" && media.meta.bitrate > 1000) {
|
||||
user.socket.emit("queueWarn", {
|
||||
msg: "This video has a bitrate over 1000kbps. Clients with slow " +
|
||||
"connections may experience lots of buffering."
|
||||
});
|
||||
}
|
||||
|
||||
var item = new PlaylistItem(media, {
|
||||
uid: self._nextuid++,
|
||||
temp: data.temp,
|
||||
|
|
|
@ -104,7 +104,10 @@ var defaults = {
|
|||
"max-items": 4000,
|
||||
"update-interval": 5
|
||||
},
|
||||
"channel-blacklist": []
|
||||
"channel-blacklist": [],
|
||||
ffmpeg: {
|
||||
enabled: false
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
58
lib/ffmpeg.js
Normal file
58
lib/ffmpeg.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
var Logger = require("./logger");
|
||||
var Config = require("./config");
|
||||
var Metadata;
|
||||
var enabled = false;
|
||||
|
||||
function init() {
|
||||
if (Config.get("ffmpeg.enabled")) {
|
||||
try {
|
||||
Metadata = require("fluent-ffmpeg").Metadata;
|
||||
Logger.syslog.log("Enabling raw file support with fluent-ffmpeg");
|
||||
enabled = true;
|
||||
} catch (e) {
|
||||
Logger.errlog.log("Failed to load fluent-ffmpeg. Did you remember to " +
|
||||
"execute `npm install fluent-ffmpeg` ?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var acceptedCodecs = {
|
||||
"mov/h264": true,
|
||||
"matroska/vp8": true
|
||||
};
|
||||
|
||||
exports.query = function (filename, cb) {
|
||||
if (!Metadata) {
|
||||
init();
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
return cb("Raw file playback is not enabled on this server");
|
||||
}
|
||||
|
||||
new Metadata(filename, function (meta, err) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
var video = meta.video;
|
||||
if (!video) {
|
||||
return cb("File has no video stream");
|
||||
}
|
||||
|
||||
var codec = video.container + "/" + video.codec;
|
||||
|
||||
if (!(codec in acceptedCodecs)) {
|
||||
return cb("Unsupported codec " + codec);
|
||||
}
|
||||
|
||||
var data = {
|
||||
title: meta.title || "Raw Video",
|
||||
duration: meta.durationsec,
|
||||
bitrate: video.bitrate,
|
||||
codec: codec
|
||||
};
|
||||
|
||||
cb(null, data);
|
||||
});
|
||||
};
|
|
@ -8,7 +8,6 @@ The above copyright notice and this permission notice shall be included in all c
|
|||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var http = require("http");
|
||||
var https = require("https");
|
||||
var domain = require("domain");
|
||||
|
@ -17,6 +16,7 @@ var Media = require("./media");
|
|||
var CustomEmbedFilter = require("./customembed").filter;
|
||||
var Server = require("./server");
|
||||
var Config = require("./config");
|
||||
var ffmpeg = require("./ffmpeg");
|
||||
|
||||
var urlRetrieve = function (transport, options, callback) {
|
||||
// Catch any errors that crop up along the way of the request
|
||||
|
@ -766,6 +766,21 @@ var Getters = {
|
|||
callback(res, null);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/* ffmpeg for raw files */
|
||||
fi: function (id, cb) {
|
||||
ffmpeg.query(id, function (err, data) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
var m = new Media(id, data.title, data.duration, "fi", {
|
||||
bitrate: data.bitrate,
|
||||
codec: data.codec
|
||||
});
|
||||
cb(null, m);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -31,7 +31,9 @@ Media.prototype = {
|
|||
object: this.meta.object,
|
||||
params: this.meta.params,
|
||||
direct: this.meta.direct,
|
||||
restricted: this.meta.restricted
|
||||
restricted: this.meta.restricted,
|
||||
codec: this.meta.codec,
|
||||
bitrate: this.meta.bitrate
|
||||
}
|
||||
};
|
||||
},
|
||||
|
|
|
@ -845,6 +845,14 @@ Callbacks = {
|
|||
$("#ytapiplayer_wrapper").remove();
|
||||
}
|
||||
|
||||
if (data.type === "fi") {
|
||||
if (USEROPTS.no_h264 && data.meta.codec !== "matroska/vp8") {
|
||||
data.forceFlash = true;
|
||||
}
|
||||
|
||||
data.url = data.id;
|
||||
}
|
||||
|
||||
/*
|
||||
VIMEO SIMULATOR 2014
|
||||
|
||||
|
|
Loading…
Reference in a new issue