mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-08 03:02:47 -05:00
Compare commits
No commits in common. "ddcb04892ba04bea4f88b3ffcb4b76e0851b3dcd" and "e8aa5bd3f42ec0a662a2d89ef0a9c22366a78114" have entirely different histories.
ddcb04892b
...
e8aa5bd3f4
@ -1,7 +1,3 @@
|
|||||||
import os
|
# pylama:ignore=W0401,W0611
|
||||||
|
from .zap2it import *
|
||||||
alt_epg_top_dir = os.path.dirname(__file__)
|
from .tvtv import *
|
||||||
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)
|
|
||||||
|
|||||||
@ -32,16 +32,11 @@ Here's the `main` section.
|
|||||||
|
|
||||||
* `method` can be set to `ffmpeg`, `vlc` or `direct`.
|
* `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`.
|
* `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]
|
[streaming]
|
||||||
# method = direct
|
# method = direct
|
||||||
# bytes_per_read = 1152000
|
|
||||||
# origin_quality = None
|
|
||||||
# transcode_quality = None
|
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -103,61 +103,44 @@ class FFMPEG_Stream():
|
|||||||
return ffmpeg_command
|
return ffmpeg_command
|
||||||
|
|
||||||
def transcode_profiles(self, stream_args):
|
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"]:
|
if stream_args["transcode_quality"]:
|
||||||
self.fhdhr.logger.info("Client requested a %s transcode for stream." % 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 = []
|
ffmpeg_command = []
|
||||||
|
|
||||||
if not stream_args["transcode_quality"] or stream_args["transcode_quality"] == "heavy":
|
if not stream_args["transcode_quality"]:
|
||||||
ffmpeg_command.extend([
|
ffmpeg_command.extend(
|
||||||
"-c", "copy",
|
[
|
||||||
"-f", "mpegts"
|
"-c", "copy",
|
||||||
])
|
"-f", "mpegts",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
elif stream_args["transcode_quality"] == "heavy":
|
||||||
|
ffmpeg_command.extend([])
|
||||||
elif stream_args["transcode_quality"] == "mobile":
|
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":
|
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":
|
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":
|
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":
|
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
|
return ffmpeg_command
|
||||||
|
|||||||
@ -86,73 +86,42 @@ class VLC_Stream():
|
|||||||
|
|
||||||
def transcode_profiles(self, stream_args):
|
def transcode_profiles(self, stream_args):
|
||||||
# TODO implement actual profiles here
|
# 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 = []
|
vlc_command = []
|
||||||
|
|
||||||
if stream_args["transcode_quality"]:
|
if stream_args["transcode_quality"]:
|
||||||
self.fhdhr.logger.info("Client requested a %s transcode for stream." % stream_args["transcode_quality"])
|
self.fhdhr.logger.info("Client requested a %s transcode for stream." % stream_args["transcode_quality"])
|
||||||
|
stream_args["transcode_quality"] = None
|
||||||
|
|
||||||
transcode_dict = {}
|
vlc_transcode_string = "#std{mux=ts,access=file,dst=-}"
|
||||||
if not stream_args["transcode_quality"] or stream_args["transcode_quality"] == "heavy":
|
return [vlc_transcode_string]
|
||||||
# dummy do nothing line
|
|
||||||
|
'#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":
|
||||||
|
vlc_command.extend([])
|
||||||
|
elif stream_args["transcode_quality"] == "mobile":
|
||||||
|
vlc_command.extend([])
|
||||||
|
elif stream_args["transcode_quality"] == "internet720":
|
||||||
|
vlc_command.extend([])
|
||||||
|
elif stream_args["transcode_quality"] == "internet480":
|
||||||
|
vlc_command.extend([])
|
||||||
|
elif stream_args["transcode_quality"] == "internet360":
|
||||||
|
vlc_command.extend([])
|
||||||
|
elif stream_args["transcode_quality"] == "internet240":
|
||||||
vlc_command.extend([])
|
vlc_command.extend([])
|
||||||
|
|
||||||
elif stream_args["transcode_quality"] == "mobile":
|
|
||||||
transcode_dict["transcode"] = {
|
|
||||||
"width": "1280",
|
|
||||||
"height": "720",
|
|
||||||
"vb": "500",
|
|
||||||
"ab": "128"
|
|
||||||
}
|
|
||||||
|
|
||||||
elif stream_args["transcode_quality"] == "internet720":
|
|
||||||
transcode_dict["transcode"] = {
|
|
||||||
"width": "1280",
|
|
||||||
"height": "720",
|
|
||||||
"vb": "1000",
|
|
||||||
"ab": "196"
|
|
||||||
}
|
|
||||||
|
|
||||||
elif stream_args["transcode_quality"] == "internet480":
|
|
||||||
transcode_dict["transcode"] = {
|
|
||||||
"width": "848",
|
|
||||||
"height": "480",
|
|
||||||
"vb": "400",
|
|
||||||
"ab": "128"
|
|
||||||
}
|
|
||||||
|
|
||||||
elif stream_args["transcode_quality"] == "internet360":
|
|
||||||
transcode_dict["transcode"] = {
|
|
||||||
"width": "640",
|
|
||||||
"height": "360",
|
|
||||||
"vb": "250",
|
|
||||||
"ab": "96"
|
|
||||||
}
|
|
||||||
|
|
||||||
elif stream_args["transcode_quality"] == "internet240":
|
|
||||||
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
|
return vlc_command
|
||||||
|
|||||||
@ -53,7 +53,10 @@ class Tuners():
|
|||||||
duration = request.args.get('duration', default=0, type=int)
|
duration = request.args.get('duration', default=0, type=int)
|
||||||
|
|
||||||
transcode_quality = request.args.get('transcode', default=None, type=str)
|
transcode_quality = request.args.get('transcode', default=None, type=str)
|
||||||
valid_transcode_types = [None, "heavy", "mobile", "internet720", "internet480", "internet360", "internet240"]
|
valid_transcode_types = [
|
||||||
|
None, "high", "medium", "low"
|
||||||
|
"heavy", "mobile", "internet720", "internet480", "internet360", "internet240"
|
||||||
|
]
|
||||||
if transcode_quality not in valid_transcode_types:
|
if transcode_quality not in valid_transcode_types:
|
||||||
response = Response("Service Unavailable", status=503)
|
response = Response("Service Unavailable", status=503)
|
||||||
response.headers["X-fHDHR-Error"] = "802 - Unknown Transcode Profile"
|
response.headers["X-fHDHR-Error"] = "802 - Unknown Transcode Profile"
|
||||||
@ -65,7 +68,7 @@ class Tuners():
|
|||||||
"method": method,
|
"method": method,
|
||||||
"duration": duration,
|
"duration": duration,
|
||||||
"origin_quality": self.fhdhr.config.dict["streaming"]["origin_quality"],
|
"origin_quality": self.fhdhr.config.dict["streaming"]["origin_quality"],
|
||||||
"transcode_quality": transcode_quality or self.fhdhr.config.dict["streaming"]["transcode_quality"],
|
"transcode_quality": transcode_quality,
|
||||||
"accessed": accessed_url,
|
"accessed": accessed_url,
|
||||||
"client": client_address,
|
"client": client_address,
|
||||||
"client_id": session["session_id"]
|
"client_id": session["session_id"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user