From 18bd87dcafff60ddc6b33bffd271f965976c68f1 Mon Sep 17 00:00:00 2001 From: vexorian Date: Sat, 26 Sep 2020 12:08:48 -0400 Subject: [PATCH 1/6] Fix anamorphic video (again), when audio is transcoded by plex but video is direct played. #127 --- src/plexTranscoder.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/plexTranscoder.js b/src/plexTranscoder.js index 47caba5..ee1a79a 100644 --- a/src/plexTranscoder.js +++ b/src/plexTranscoder.js @@ -16,6 +16,7 @@ class PlexTranscoder { this.log("Debug logging enabled") this.key = lineupItem.key + this.metadataPath = `${server.uri}${lineupItem.key}?X-Plex-Token=${server.accessToken}` this.plexFile = `${server.uri}${lineupItem.plexFile}?X-Plex-Token=${server.accessToken}` if (typeof(lineupItem.file)!=='undefined') { this.file = lineupItem.file.replace(settings.pathReplace, settings.pathReplaceWith) @@ -87,6 +88,8 @@ class PlexTranscoder { this.log("Decision: Direct stream. Audio is being transcoded") stream.separateVideoStream = (this.settings.streamPath === 'direct') ? this.file : this.plexFile; stream.streamUrl = `${this.transcodeUrlBase}${this.transcodingArgs}` + this.directInfo = await this.getDirectInfo(); + this.videoIsDirect = true; } stream.streamStats = this.getVideoStats(); @@ -207,10 +210,14 @@ lang=en` let streams = this.decisionJson.MediaContainer.Metadata[0].Media[0].Part[0].Stream ret.duration = parseFloat( this.decisionJson.MediaContainer.Metadata[0].Media[0].Part[0].duration ); - streams.forEach(function (stream) { + streams.forEach(function (_stream, $index) { // Video + let stream = _stream; if (stream["streamType"] == "1") { - ret.anamorphic = (stream.anamorphic === "1"); + if ( this.videoIsDirect === true && typeof(this.directInfo) !== 'undefined') { + stream = this.directInfo.MediaContainer.Metadata[0].Media[0].Part[0].Stream[$index]; + } + ret.anamorphic = ( (stream.anamorphic === "1") || (stream.anamorphic === true) ); if (ret.anamorphic) { let parsed = parsePixelAspectRatio(stream.pixelAspectRatio); if (isNaN(parsed.p) || isNaN(parsed.q) ) { @@ -236,7 +243,7 @@ lang=en` ret.audioCodec = stream["codec"]; ret.audioDecision = (typeof stream.decision === 'undefined') ? 'copy' : stream.decision; } - }) + }.bind(this) ) } catch (e) { console.log("Error at decision:" + e); } @@ -277,11 +284,15 @@ lang=en` return index } + async getDirectInfo() { + return (await axios.get(this.metadataPath) ).data; + + } + async getDecision(directPlay) { - await axios.get(`${this.server.uri}/video/:/transcode/universal/decision?${this.transcodingArgs}`, { + let res = await axios.get(`${this.server.uri}/video/:/transcode/universal/decision?${this.transcodingArgs}`, { headers: { Accept: 'application/json' } }) - .then((res) => { this.decisionJson = res.data; this.log("Recieved transcode decision:") @@ -294,7 +305,6 @@ lang=en` console.log(`IMPORTANT: Recieved transcode decision code ${transcodeDecisionCode}! Expected code 1001.`) console.log(`Error message: '${res.data.MediaContainer.transcodeDecisionText}'`) } - }) } getStatusUrl() { From c114cab269e431374ae0b79d445bec41849b99b4 Mon Sep 17 00:00:00 2001 From: vexorian Date: Sat, 26 Sep 2020 12:53:32 -0400 Subject: [PATCH 2/6] #110 expose url-tvg and x-tvg-url fields in m3u --- src/api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api.js b/src/api.js index 9a44617..752b505 100644 --- a/src/api.js +++ b/src/api.js @@ -453,7 +453,8 @@ function api(db, channelDB, xmltvInterval, guideService ) { res.type('text') let channels = await channelDB.getAllChannels(); channels.sort((a, b) => { return a.number < b.number ? -1 : 1 }) - var data = "#EXTM3U\n" + let tvg = `${req.protocol}://${req.get('host')}/api/xmltv.xml` + var data = `#EXTM3U url-tvg="${tvg}" x-tvg-url="${tvg}"\n`; for (var i = 0; i < channels.length; i++) { if (channels[i].stealth!==true) { data += `#EXTINF:0 tvg-id="${channels[i].number}" tvg-chno="${channels[i].number}" tvg-name="${channels[i].name}" tvg-logo="${channels[i].icon}" group-title="dizqueTV",${channels[i].name}\n` From c2a8bdc4c97c31dcc5cbae63d877aeab630584df Mon Sep 17 00:00:00 2001 From: vexorian Date: Sat, 26 Sep 2020 13:40:47 -0400 Subject: [PATCH 3/6] Fix xmltv writer crashing when a rating in the channel json is null for some reason (usually because of the python library) --- src/xmltv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xmltv.js b/src/xmltv.js index 054bf81..d1596be 100644 --- a/src/xmltv.js +++ b/src/xmltv.js @@ -105,7 +105,7 @@ async function _writeProgramme(channel, program, xw) { } xw.endElement() // Rating - if (typeof program.rating !== 'undefined') { + if ( (program.rating != null) && (typeof program.rating !== 'undefined') ) { xw.startElement('rating') xw.writeAttribute('system', 'MPAA') xw.writeElement('value', program.rating) From 10e231adb10055ffb090d8c6393f47c6db33237a Mon Sep 17 00:00:00 2001 From: vexorian Date: Sat, 26 Sep 2020 13:41:03 -0400 Subject: [PATCH 4/6] Add explanations to EPG settings. --- web/public/templates/xmltv-settings.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/public/templates/xmltv-settings.html b/web/public/templates/xmltv-settings.html index f5cb495..1707974 100644 --- a/web/public/templates/xmltv-settings.html +++ b/web/public/templates/xmltv-settings.html @@ -15,11 +15,13 @@
- + + How many hours of programming to include in the xmltv file.
- + + How often should the xmltv file be updated.
From c5a3a0de89e0f16a3c999b12f3174829a3a98ca9 Mon Sep 17 00:00:00 2001 From: vexorian Date: Sat, 26 Sep 2020 15:01:42 -0400 Subject: [PATCH 5/6] Tweak default bitrates a bit. Clarify that they are in Kbps in Plex settings --- src/api.js | 4 ++-- src/database-migration.js | 6 +++--- web/public/templates/plex-settings.html | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/api.js b/src/api.js index 752b505..ee40c54 100644 --- a/src/api.js +++ b/src/api.js @@ -268,8 +268,8 @@ function api(db, channelDB, xmltvInterval, guideService ) { db['plex-settings'].update({ _id: req.body._id }, { streamPath: 'plex', debugLogging: true, - directStreamBitrate: '40000', - transcodeBitrate: '3000', + directStreamBitrate: '20000', + transcodeBitrate: '2000', mediaBufferSize: 1000, transcodeMediaBufferSize: 20000, maxPlayableResolution: "1920x1080", diff --git a/src/database-migration.js b/src/database-migration.js index 3da674c..e1a5912 100644 --- a/src/database-migration.js +++ b/src/database-migration.js @@ -78,8 +78,8 @@ function basicDB(db) { db['plex-settings'].save({ streamPath: 'plex', debugLogging: true, - directStreamBitrate: '40000', - transcodeBitrate: '3000', + directStreamBitrate: '20000', + transcodeBitrate: '2000', mediaBufferSize: 1000, transcodeMediaBufferSize: 20000, maxPlayableResolution: "1920x1080", @@ -379,7 +379,7 @@ function ffmpeg() { videoEncoder: "mpeg2video", audioEncoder: "ac3", targetResolution: "1920x1080", - videoBitrate: 10000, + videoBitrate: 2000, videoBufSize: 2000, audioBitrate: 192, audioBufSize: 50, diff --git a/web/public/templates/plex-settings.html b/web/public/templates/plex-settings.html index a28803d..1324bf1 100644 --- a/web/public/templates/plex-settings.html +++ b/web/public/templates/plex-settings.html @@ -146,12 +146,14 @@
Miscellaneous Options
- +
- - + + + Plex will decide to transcode or direct play based on these settings and if Plex transcodes, it will try to match the transcode bitrate. +
From 435e151258d3e2f0befd66c30560ce3c69ab7e30 Mon Sep 17 00:00:00 2001 From: vexorian Date: Sat, 26 Sep 2020 15:02:01 -0400 Subject: [PATCH 6/6] Phonetic pronuntiation to avoid confusion --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 94d22b4..f7335f4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Create live TV channel streams from media on your Plex servers. -dizqueTV is a fork of the project previously-known as [pseudotv-plex](https://gitlab.com/DEFENDORe/pseudotv-plex) or [pseudotv](https://github.com/DEFENDORe/pseudotv). New repository because of lack of activity from the main repository and the name change is because projects with the old name already existed and were created long before this approach and it was causing confusion. You can migrate from pseudoTV 0.0.51 to dizqueTV by renaming the .pseudotv folder to .dizquetv and running the new executable (or doing a similar trick with the volumes used by the docker containers). +**dizqueTV** ( *dis·keˈtiːˈvi* ) is a fork of the project previously-known as [pseudotv-plex](https://gitlab.com/DEFENDORe/pseudotv-plex) or [pseudotv](https://github.com/DEFENDORe/pseudotv). New repository because of lack of activity from the main repository and the name change is because projects with the old name already existed and were created long before this approach and it was causing confusion. You can migrate from pseudoTV 0.0.51 to dizqueTV by renaming the .pseudotv folder to .dizquetv and running the new executable (or doing a similar trick with the volumes used by the docker containers).