diff --git a/lib/channel/playlist.js b/lib/channel/playlist.js index 71a72cdc..0646620d 100644 --- a/lib/channel/playlist.js +++ b/lib/channel/playlist.js @@ -885,7 +885,8 @@ PlaylistModule.prototype._addItem = function (media, data, user, cb) { } /* Warn about possibly unsupported formats */ - if (media.type === "fi" && media.meta.codec !== "mov/h264" && + if (media.type === "fi" && media.meta.codec.indexOf("/") !== -1 && + media.meta.codec !== "mov/h264" && media.meta.codec !== "flv/h264") { user.socket.emit("queueWarn", { msg: "The codec " + media.meta.codec + " is not supported " + diff --git a/lib/ffmpeg.js b/lib/ffmpeg.js index 4ebb9adc..9b5fb395 100644 --- a/lib/ffmpeg.js +++ b/lib/ffmpeg.js @@ -9,7 +9,7 @@ function init() { Metadata = require("fluent-ffmpeg").Metadata; Logger.syslog.log("Enabling raw file support with fluent-ffmpeg"); enabled = true; - } catch (e) { + } catch (e) { Logger.errlog.log("Failed to load fluent-ffmpeg. Did you remember to " + "execute `npm install fluent-ffmpeg` ?"); } @@ -24,6 +24,11 @@ var acceptedCodecs = { "ogg/theora": true, }; +var acceptedAudioCodecs = { + "mp3": true, + "vorbis": true +}; + exports.query = function (filename, cb) { if (!Metadata) { init(); @@ -38,24 +43,50 @@ exports.query = function (filename, cb) { return cb(err); } - var video = meta.video; - if (!video) { - return cb("File has no video stream"); + if (isVideo(meta)) { + var video = meta.video; + var codec = video.container + "/" + video.codec; + + if (!(codec in acceptedCodecs)) { + return cb("Unsupported video codec " + codec); + } + + var data = { + title: meta.title || "Raw Video", + duration: meta.durationsec, + bitrate: video.bitrate, + codec: codec + }; + + cb(null, data); + } else if (isAudio(meta)) { + var audio = meta.audio; + var codec = audio.codec; + + if (!(codec in acceptedAudioCodecs)) { + return cb("Unsupported audio codec " + codec); + } + + var data = { + title: meta.title || "Raw Audio", + duration: meta.durationsec, + bitrate: audio.bitrate, + codec: codec + }; + + cb(null, data); + } else { + return cb("Parsed metadata did not contain a valid video or audio stream. " + + "Either the file is invalid or it has a format unsupported by " + + "this server's version of ffmpeg."); } - - var codec = video.container + "/" + video.codec; - - if (!(codec in acceptedCodecs)) { - return cb("Unsupported video codec " + codec); - } - - var data = { - title: meta.title || "Raw Video", - duration: meta.durationsec, - bitrate: video.bitrate, - codec: codec - }; - - cb(null, data); }); }; + +function isVideo(meta) { + return meta.video && meta.video.bitrate > 0 && meta.video.container && meta.video.codec; +} + +function isAudio(meta) { + return meta.audio && meta.audio.bitrate > 0 && meta.audio.codec; +} diff --git a/www/js/callbacks.js b/www/js/callbacks.js index 5d797b85..3d296bbe 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -846,7 +846,7 @@ Callbacks = { } if (data.type === "fi") { - if (USEROPTS.no_h264 && data.meta.codec !== "matroska/vp8") { + if (USEROPTS.no_h264 && data.meta.codec === "mov/h264") { data.forceFlash = true; } diff --git a/www/js/player.js b/www/js/player.js index d63fd456..58ee605c 100644 --- a/www/js/player.js +++ b/www/js/player.js @@ -1155,7 +1155,14 @@ function FilePlayer(data) { self.init = function (data) { self.videoId = data.id; self.videoURL = data.url; - var video = $("