mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 06:16:58 -05:00
Compare commits
6 Commits
e8aa5bd3f4
...
ddcb04892b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddcb04892b | ||
|
|
6076011d1c | ||
|
|
751eaebee9 | ||
|
|
53dc0e127d | ||
|
|
acf72ad109 | ||
|
|
630b8dbf2b |
@ -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)
|
||||
|
||||
@ -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
|
||||
````
|
||||
|
||||
|
||||
|
||||
@ -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(
|
||||
[
|
||||
if not stream_args["transcode_quality"] or stream_args["transcode_quality"] == "heavy":
|
||||
ffmpeg_command.extend([
|
||||
"-c", "copy",
|
||||
"-f", "mpegts",
|
||||
]
|
||||
)
|
||||
elif stream_args["transcode_quality"] == "heavy":
|
||||
ffmpeg_command.extend([])
|
||||
"-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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user