diff --git a/src/ffmpeg.js b/src/ffmpeg.js index 8480910..edd56d2 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -23,7 +23,35 @@ class FFMPEG extends events.EventEmitter { this.channel = channel this.ffmpegPath = opts.ffmpegPath - var parsed = parseResolutionString(opts.targetResolution); + let resString = opts.targetResolution; + if ( + (typeof(channel.transcoding) !== 'undefined') + && (channel.transcoding.targetResolution != null) + && (typeof(channel.transcoding.targetResolution) != 'undefined') + && (channel.transcoding.targetResolution != "") + ) { + resString = channel.transcoding.targetResolution; + } + + if ( + (typeof(channel.transcoding) !== 'undefined') + && (channel.transcoding.videoBitrate != null) + && (typeof(channel.transcoding.videoBitrate) != 'undefined') + && (channel.transcoding.videoBitrate != 0) + ) { + opts.videoBitrate = channel.transcoding.videoBitrate; + } + + if ( + (typeof(channel.transcoding.videoBufSize) !== 'undefined') + && (channel.transcoding.videoBufSize != null) + && (typeof(channel.transcoding.videoBufSize) != 'undefined') + && (channel.transcoding.videoBufSize != 0) + ) { + opts.videoBufSize = channel.transcoding.videoBufSize; + } + + let parsed = parseResolutionString(resString); this.wantedW = parsed.w; this.wantedH = parsed.h; diff --git a/src/video.js b/src/video.js index 4ebab8f..d82073d 100644 --- a/src/video.js +++ b/src/video.js @@ -287,11 +287,13 @@ function video( channelDB , fillerDB, db) { }; } + let combinedChannel = JSON.parse( JSON.stringify(brandChannel) ); + combinedChannel.transcoding = channel.transcoding; let playerContext = { lineupItem : lineupItem, ffmpegSettings : ffmpegSettings, - channel: brandChannel, + channel: combinedChannel, db: db, m3u8: m3u8, } diff --git a/web/app.js b/web/app.js index b608412..be760c8 100644 --- a/web/app.js +++ b/web/app.js @@ -9,6 +9,7 @@ var app = angular.module('myApp', ['ngRoute', 'vs-repeat', 'angularLazyImg', 'dn app.service('plex', require('./services/plex')) app.service('dizquetv', require('./services/dizquetv')) +app.service('resolutionOptions', require('./services/resolution-options')) app.directive('plexSettings', require('./directives/plex-settings')) app.directive('ffmpegSettings', require('./directives/ffmpeg-settings')) diff --git a/web/directives/channel-config.js b/web/directives/channel-config.js index e5baa83..e9e46dc 100644 --- a/web/directives/channel-config.js +++ b/web/directives/channel-config.js @@ -1,4 +1,4 @@ -module.exports = function ($timeout, $location, dizquetv) { +module.exports = function ($timeout, $location, dizquetv, resolutionOptions) { return { restrict: 'E', templateUrl: 'templates/channel-config.html', @@ -62,6 +62,9 @@ module.exports = function ($timeout, $location, dizquetv) { scope.channel.name = "Channel 1" } scope.showRotatedNote = false; + scope.channel.transcoding = { + targetResolution: "", + } } else { scope.beforeEditChannelNumber = scope.channel.number @@ -95,6 +98,18 @@ module.exports = function ($timeout, $location, dizquetv) { ) { scope.channel.guideMinimumDurationSeconds = 5 * 60; } + + if (typeof(scope.channel.transcoding) ==='undefined') { + scope.channel.transcoding = {}; + } + if ( + (scope.channel.transcoding.targetResolution == null) + || (typeof(scope.channel.transcoding.targetResolution) === 'undefined') + || (scope.channel.transcoding.targetResolution === '') + ) { + scope.channel.transcoding.targetResolution = ""; + } + adjustStartTimeToCurrentProgram(); updateChannelDuration(); @@ -786,6 +801,7 @@ module.exports = function ($timeout, $location, dizquetv) { updateChannelDuration(); } scope.padTimes = (paddingMod, allow5) => { + console.log(paddingMod, allow5) ; let mod = paddingMod * 60 * 1000; if (mod == 0) { mod = 60*60*1000; @@ -1122,6 +1138,7 @@ module.exports = function ($timeout, $location, dizquetv) { scope.showRotatedNote = false; scope.channel.duration = 0 scope.hasFlex = false; + for (let i = 0, l = scope.channel.programs.length; i < l; i++) { scope.channel.programs[i].start = new Date(scope.channel.startTime.valueOf() + scope.channel.duration) scope.channel.programs[i].$index = i; @@ -1133,6 +1150,7 @@ module.exports = function ($timeout, $location, dizquetv) { } scope.maxSize = Math.max(scope.maxSize, scope.channel.programs.length); scope.libraryLimit = Math.max(0, scope.maxSize - scope.channel.programs.length ); + scope.endTime = new Date( scope.channel.startTime.valueOf() + scope.channel.duration ); } scope.error = {} scope._onDone = async (channel) => { @@ -1462,6 +1480,14 @@ module.exports = function ($timeout, $location, dizquetv) { ] } + scope.resolutionOptions = [ + { id: "", description: "(Use global setting)" }, + ]; + resolutionOptions.get() + .forEach( (a) => { + scope.resolutionOptions.push(a) + } ); + scope.nightStartHours = [ { id: -1, description: "Start" } ]; scope.nightEndHours = [ { id: -1, description: "End" } ]; scope.nightStart = -1; @@ -1569,22 +1595,26 @@ module.exports = function ($timeout, $location, dizquetv) { scope.refreshFillerStuff(); refreshFillerOptions(); - let refreshScreenResolution = async () => { - - function parseResolutionString(s) { - var i = s.indexOf('x'); + function parseResolutionString(s) { + var i = s.indexOf('x'); + if (i == -1) { + i = s.indexOf("×"); if (i == -1) { - i = s.indexOf("×"); - if (i == -1) { - return {w:1920, h:1080} - } - } - return { - w: parseInt( s.substring(0,i) , 10 ), - h: parseInt( s.substring(i+1) , 10 ), + return {w:1920, h:1080} } } - + return { + w: parseInt( s.substring(0,i) , 10 ), + h: parseInt( s.substring(i+1) , 10 ), + } + } + + scope.videoRateDefault = "(Use global setting)"; + scope.videoBufSizeDefault = "(Use global setting)"; + + let refreshScreenResolution = async () => { + + try { let ffmpegSettings = await dizquetv.getFfmpegSettings() if ( @@ -1593,8 +1623,16 @@ module.exports = function ($timeout, $location, dizquetv) { && (typeof(ffmpegSettings.targetResolution) !== '') ) { let p = parseResolutionString( ffmpegSettings.targetResolution ); + scope.resolutionOptions[0] = { + id: "", + description: `Use global setting (${ffmpegSettings.targetResolution})`, + } + ffmpegSettings.targetResolution scope.screenW = p.w; scope.screenH = p.h; + scope.videoRateDefault = `global setting=${ffmpegSettings.videoBitrate}`; + scope.videoBufSizeDefault = `global setting=${ffmpegSettings.videoBufSize}`; + $timeout(); } } catch(err) { @@ -1622,6 +1660,9 @@ module.exports = function ($timeout, $location, dizquetv) { } scope.getCurrentWH = () => { + if (scope.channel.transcoding.targetResolution !== '') { + return parseResolutionString( scope.channel.transcoding.targetResolution ); + } return { w: scope.screenW, h: scope.screenH diff --git a/web/directives/ffmpeg-settings.js b/web/directives/ffmpeg-settings.js index efa4c47..6388b55 100644 --- a/web/directives/ffmpeg-settings.js +++ b/web/directives/ffmpeg-settings.js @@ -1,4 +1,4 @@ - module.exports = function (dizquetv) { +module.exports = function (dizquetv, resolutionOptions) { return { restrict: 'E', templateUrl: 'templates/ffmpeg-settings.html', @@ -26,18 +26,7 @@ scope.hideIfNotAutoPlay = () => { return scope.settings.enableAutoPlay != true }; - scope.resolutionOptions=[ - {id:"420x420",description:"420x420 (1:1)"}, - {id:"480x270",description:"480x270 (HD1080/16 16:9)"}, - {id:"576x320",description:"576x320 (18:10)"}, - {id:"640x360",description:"640x360 (nHD 16:9)"}, - {id:"720x480",description:"720x480 (WVGA 3:2)"}, - {id:"800x600",description:"800x600 (SVGA 4:3)"}, - {id:"1024x768",description:"1024x768 (WXGA 4:3)"}, - {id:"1280x720",description:"1280x720 (HD 16:9)"}, - {id:"1920x1080",description:"1920x1080 (FHD 16:9)"}, - {id:"3840x2160",description:"3840x2160 (4K 16:9)"}, - ]; + scope.resolutionOptions= resolutionOptions.get(); scope.muxDelayOptions=[ {id:"0",description:"0 Seconds"}, {id:"1",description:"1 Seconds"}, diff --git a/web/public/templates/channel-config.html b/web/public/templates/channel-config.html index f8fdb38..7240786 100644 --- a/web/public/templates/channel-config.html +++ b/web/public/templates/channel-config.html @@ -47,13 +47,21 @@ -