1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 06:56:57 -05:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Deathbybandaid
ddcb04892b
Merge pull request #144 from deathbybandaid/dev
Make alt_epg loading more abstract
2021-01-21 15:29:44 -05:00
deathbybandaid
6076011d1c Make alt_epg loading more abstract 2021-01-21 15:20:28 -05:00
Deathbybandaid
751eaebee9
Merge pull request #143 from deathbybandaid/dev
Update Streaming Config Docs
2021-01-21 12:23:49 -05:00
deathbybandaid
53dc0e127d Update Streaming Config Docs 2021-01-21 12:17:39 -05:00
Deathbybandaid
acf72ad109
Merge pull request #142 from deathbybandaid/dev
Implement Transcode Profiles for ffmpeg/vlc
2021-01-21 11:49:23 -05:00
deathbybandaid
630b8dbf2b Implement Transcode Profiles for ffmpeg/vlc 2021-01-21 11:46:44 -05:00
5 changed files with 116 additions and 62 deletions

View File

@ -1,3 +1,7 @@
# pylama:ignore=W0401,W0611
from .zap2it import *
from .tvtv import *
import os
alt_epg_top_dir = os.path.dirname(__file__)
for entry in os.scandir(alt_epg_top_dir):
if entry.is_dir() and not entry.is_file() and entry.name[0] != '_':
imp_string = "from .%s import *" % entry.name
exec(imp_string)

View File

@ -32,11 +32,16 @@ Here's the `main` section.
* `method` can be set to `ffmpeg`, `vlc` or `direct`.
* `bytes_per_read` determines how many bytes of the stream to read before sending the data to your client. Increasing this value may cause longer load times, and lowering it may effect `stuttering`.
* `origin_quality` can be set to high,medium,low for most variants. Variants that make use of m3u8 will Autoselect High for the direct method if not set. ffmpeg/vlc will determine the best stream on their own. Some Variants can allow alternative values.
* `transcode_quality` works with ffmpeg/vlc to use fHDHR for handling quality instead of the origin. Valid settings include: heavy,mobile,internet720,internet480,internet360,internet240
````
[streaming]
# method = direct
# bytes_per_read = 1152000
# origin_quality = None
# transcode_quality = None
````

View File

@ -103,44 +103,61 @@ class FFMPEG_Stream():
return ffmpeg_command
def transcode_profiles(self, stream_args):
# TODO implement actual profiles here
"""
heavy: transcode to AVC with the same resolution, frame-rate, and interlacing as the
original stream. For example 1080i60 AVC 1080i60, 720p60 AVC 720p60.
mobile: trancode to AVC progressive not exceeding 1280x720 30fps.
internet720: transcode to low bitrate AVC progressive not exceeding 1280x720 30fps.
internet480: transcode to low bitrate AVC progressive not exceeding 848x480 30fps for
16:9 content, not exceeding 640x480 30fps for 4:3 content.
internet360: transcode to low bitrate AVC progressive not exceeding 640x360 30fps for
16:9 content, not exceeding 480x360 30fps for 4:3 content.
internet240: transcode to low bitrate AVC progressive not exceeding 432x240 30fps for
16:9 content, not exceeding 320x240 30fps for 4:3 content
"""
if stream_args["transcode_quality"]:
self.fhdhr.logger.info("Client requested a %s transcode for stream." % stream_args["transcode_quality"])
stream_args["transcode_quality"] = None
ffmpeg_command = []
if not stream_args["transcode_quality"]:
ffmpeg_command.extend(
[
"-c", "copy",
"-f", "mpegts",
]
)
elif stream_args["transcode_quality"] == "heavy":
ffmpeg_command.extend([])
if not stream_args["transcode_quality"] or stream_args["transcode_quality"] == "heavy":
ffmpeg_command.extend([
"-c", "copy",
"-f", "mpegts"
])
elif stream_args["transcode_quality"] == "mobile":
ffmpeg_command.extend([])
ffmpeg_command.extend([
"-c", "copy",
"-s", "1280X720",
"-b:v", "500k",
"-b:a", "128k",
"-f", "mpegts"
])
elif stream_args["transcode_quality"] == "internet720":
ffmpeg_command.extend([])
ffmpeg_command.extend([
"-c", "copy",
"-s", "1280X720",
"-b:v", "1000k",
"-b:a", "196k",
"-f", "mpegts"
])
elif stream_args["transcode_quality"] == "internet480":
ffmpeg_command.extend([])
ffmpeg_command.extend([
"-c", "copy",
"-s", "848X480",
"-b:v", "400k",
"-b:a", "128k",
"-f", "mpegts"
])
elif stream_args["transcode_quality"] == "internet360":
ffmpeg_command.extend([])
ffmpeg_command.extend([
"-c", "copy",
"-s", "640X360",
"-b:v", "250k",
"-b:a", "96k",
"-f", "mpegts"
])
elif stream_args["transcode_quality"] == "internet240":
ffmpeg_command.extend([])
ffmpeg_command.extend([
"-c", "copy",
"-s", "432X240",
"-b:v", "250k",
"-b:a", "96k",
"-f", "mpegts"
])
return ffmpeg_command

View File

@ -86,42 +86,73 @@ class VLC_Stream():
def transcode_profiles(self, stream_args):
# TODO implement actual profiles here
"""
heavy: transcode to AVC with the same resolution, frame-rate, and interlacing as the
original stream. For example 1080i60 AVC 1080i60, 720p60 AVC 720p60.
mobile: trancode to AVC progressive not exceeding 1280x720 30fps.
internet720: transcode to low bitrate AVC progressive not exceeding 1280x720 30fps.
internet480: transcode to low bitrate AVC progressive not exceeding 848x480 30fps for
16:9 content, not exceeding 640x480 30fps for 4:3 content.
internet360: transcode to low bitrate AVC progressive not exceeding 640x360 30fps for
16:9 content, not exceeding 480x360 30fps for 4:3 content.
internet240: transcode to low bitrate AVC progressive not exceeding 432x240 30fps for
16:9 content, not exceeding 320x240 30fps for 4:3 content
"""
vlc_command = []
if stream_args["transcode_quality"]:
self.fhdhr.logger.info("Client requested a %s transcode for stream." % stream_args["transcode_quality"])
stream_args["transcode_quality"] = None
vlc_transcode_string = "#std{mux=ts,access=file,dst=-}"
return [vlc_transcode_string]
'#transcode{vcodec=mp2v,vb=4096,acodec=mp2a,ab=192,scale=1,channels=2,deinterlace}:std{access=file,mux=ts,dst=-"}'
if not stream_args["transcode_quality"]:
vlc_command.extend([])
elif stream_args["transcode_quality"] == "heavy":
transcode_dict = {}
if not stream_args["transcode_quality"] or stream_args["transcode_quality"] == "heavy":
# dummy do nothing line
vlc_command.extend([])
elif stream_args["transcode_quality"] == "mobile":
vlc_command.extend([])
transcode_dict["transcode"] = {
"width": "1280",
"height": "720",
"vb": "500",
"ab": "128"
}
elif stream_args["transcode_quality"] == "internet720":
vlc_command.extend([])
transcode_dict["transcode"] = {
"width": "1280",
"height": "720",
"vb": "1000",
"ab": "196"
}
elif stream_args["transcode_quality"] == "internet480":
vlc_command.extend([])
transcode_dict["transcode"] = {
"width": "848",
"height": "480",
"vb": "400",
"ab": "128"
}
elif stream_args["transcode_quality"] == "internet360":
vlc_command.extend([])
transcode_dict["transcode"] = {
"width": "640",
"height": "360",
"vb": "250",
"ab": "96"
}
elif stream_args["transcode_quality"] == "internet240":
vlc_command.extend([])
transcode_dict["transcode"] = {
"width": "432",
"height": "240",
"vb": "250",
"ab": "96"
}
transcode_dict["std"] = {
"mux": "ts",
"access": "file",
"dst": "-"
}
topkey_index = 0
vlc_transcode_string = ""
for topkey in list(transcode_dict.keys()):
if not topkey_index:
topkey_index += 1
vlc_transcode_string += "#"
else:
vlc_transcode_string += ":"
vlc_transcode_string += "%s{" % topkey
vlc_transcode_string += ",".join(["%s=%s" % (x, transcode_dict[topkey][x]) for x in list(transcode_dict[topkey].keys())])
vlc_transcode_string += "}"
vlc_command.extend([vlc_transcode_string])
return vlc_command

View File

@ -53,10 +53,7 @@ class Tuners():
duration = request.args.get('duration', default=0, type=int)
transcode_quality = request.args.get('transcode', default=None, type=str)
valid_transcode_types = [
None, "high", "medium", "low"
"heavy", "mobile", "internet720", "internet480", "internet360", "internet240"
]
valid_transcode_types = [None, "heavy", "mobile", "internet720", "internet480", "internet360", "internet240"]
if transcode_quality not in valid_transcode_types:
response = Response("Service Unavailable", status=503)
response.headers["X-fHDHR-Error"] = "802 - Unknown Transcode Profile"
@ -68,7 +65,7 @@ class Tuners():
"method": method,
"duration": duration,
"origin_quality": self.fhdhr.config.dict["streaming"]["origin_quality"],
"transcode_quality": transcode_quality,
"transcode_quality": transcode_quality or self.fhdhr.config.dict["streaming"]["transcode_quality"],
"accessed": accessed_url,
"client": client_address,
"client_id": session["session_id"]