mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-07-24 19:10:04 +00:00
try fix stuttering 2
This commit is contained in:
parent
dafb0f201b
commit
a2958360bd
@ -587,7 +587,8 @@ class Downloader():
|
|||||||
|
|
||||||
# Get obj codec
|
# Get obj codec
|
||||||
self.codec: M3U8_Codec = parse_class_m3u8.codec
|
self.codec: M3U8_Codec = parse_class_m3u8.codec
|
||||||
logging.info(f"Get coded: {self.codec}")
|
logging.info(f"Get codeds: {self.codec}")
|
||||||
|
console.log(f"[cyan]Use codecs: [red]({self.codec.video_codec_name};{self.codec.audio_codec_name})")
|
||||||
|
|
||||||
def manage_subtitle(self):
|
def manage_subtitle(self):
|
||||||
"""
|
"""
|
||||||
@ -735,8 +736,8 @@ class Downloader():
|
|||||||
return concatenate_and_save(
|
return concatenate_and_save(
|
||||||
file_list_path=file_list_path,
|
file_list_path=file_list_path,
|
||||||
output_filename=out_file_name,
|
output_filename=out_file_name,
|
||||||
v_codec=self.codec.video_codec,
|
v_codec=self.codec.video_codec_name,
|
||||||
a_codec=self.codec.audio_codec,
|
a_codec=self.codec.audio_codec_name,
|
||||||
bandwidth=self.codec.bandwidth
|
bandwidth=self.codec.bandwidth
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ from Src.Util.config import config_manager
|
|||||||
# Variable
|
# Variable
|
||||||
DEBUG_MODE = config_manager.get_bool("DEFAULT", "debug")
|
DEBUG_MODE = config_manager.get_bool("DEFAULT", "debug")
|
||||||
DEBUG_FFMPEG = "debug" if DEBUG_MODE else "error"
|
DEBUG_FFMPEG = "debug" if DEBUG_MODE else "error"
|
||||||
|
USE_CODECS = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -210,6 +211,7 @@ def concatenate_and_save(file_list_path: str, output_filename: str, v_codec: str
|
|||||||
|
|
||||||
output_args = {
|
output_args = {
|
||||||
'c': 'copy',
|
'c': 'copy',
|
||||||
|
'preset': 'ultrafast',
|
||||||
'loglevel': DEBUG_FFMPEG,
|
'loglevel': DEBUG_FFMPEG,
|
||||||
'y': None,
|
'y': None,
|
||||||
}
|
}
|
||||||
@ -217,10 +219,11 @@ def concatenate_and_save(file_list_path: str, output_filename: str, v_codec: str
|
|||||||
# Add BANDWIDTH and CODECS if provided
|
# Add BANDWIDTH and CODECS if provided
|
||||||
if bandwidth is not None:
|
if bandwidth is not None:
|
||||||
output_args['b:v'] = str(bandwidth)
|
output_args['b:v'] = str(bandwidth)
|
||||||
"""if v_codec is not None:
|
if USE_CODECS:
|
||||||
output_args['vcodec'] = v_codec
|
if v_codec is not None:
|
||||||
if a_codec is not None:
|
output_args['vcodec'] = v_codec
|
||||||
output_args['acodec'] = a_codec"""
|
if a_codec is not None:
|
||||||
|
output_args['acodec'] = a_codec
|
||||||
|
|
||||||
# Set up the output file name by modifying the video file name
|
# Set up the output file name by modifying the video file name
|
||||||
output_file_name = os.path.splitext(output_filename)[0] + f"_{prefix}.mp4"
|
output_file_name = os.path.splitext(output_filename)[0] + f"_{prefix}.mp4"
|
||||||
|
@ -12,6 +12,32 @@ import requests
|
|||||||
from m3u8 import M3U8
|
from m3u8 import M3U8
|
||||||
|
|
||||||
|
|
||||||
|
# Costant
|
||||||
|
CODEC_MAPPINGS = {
|
||||||
|
"video": {
|
||||||
|
"avc1": "libx264",
|
||||||
|
"avc2": "libx264",
|
||||||
|
"avc3": "libx264",
|
||||||
|
"avc4": "libx264",
|
||||||
|
"hev1": "libx265",
|
||||||
|
"hev2": "libx265",
|
||||||
|
"hvc1": "libx265",
|
||||||
|
"hvc2": "libx265",
|
||||||
|
"vp8": "libvpx",
|
||||||
|
"vp9": "libvpx-vp9",
|
||||||
|
"vp10": "libvpx-vp9"
|
||||||
|
},
|
||||||
|
"audio": {
|
||||||
|
"mp4a": "aac",
|
||||||
|
"mp3": "libmp3lame",
|
||||||
|
"ac-3": "ac3",
|
||||||
|
"ec-3": "eac3",
|
||||||
|
"opus": "libopus",
|
||||||
|
"vorbis": "libvorbis"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class M3U8_Codec():
|
class M3U8_Codec():
|
||||||
"""
|
"""
|
||||||
@ -39,9 +65,10 @@ class M3U8_Codec():
|
|||||||
self.codecs = codecs
|
self.codecs = codecs
|
||||||
self.audio_codec = None
|
self.audio_codec = None
|
||||||
self.video_codec = None
|
self.video_codec = None
|
||||||
|
self.extract_codecs()
|
||||||
self.parse_codecs()
|
self.parse_codecs()
|
||||||
|
|
||||||
def parse_codecs(self):
|
def extract_codecs(self):
|
||||||
"""
|
"""
|
||||||
Parses the codecs information to extract audio and video codecs.
|
Parses the codecs information to extract audio and video codecs.
|
||||||
|
|
||||||
@ -57,6 +84,69 @@ class M3U8_Codec():
|
|||||||
elif codec.startswith('mp4a'):
|
elif codec.startswith('mp4a'):
|
||||||
self.audio_codec = codec
|
self.audio_codec = codec
|
||||||
|
|
||||||
|
def convert_video_codec(self, video_codec_identifier) -> str:
|
||||||
|
|
||||||
|
"""
|
||||||
|
Convert video codec identifier to codec name.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- video_codec_identifier (str): Identifier of the video codec.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
- str: Codec name corresponding to the identifier.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Extract codec type from the identifier
|
||||||
|
codec_type = video_codec_identifier.split('.')[0]
|
||||||
|
|
||||||
|
# Retrieve codec mapping from the provided mappings or fallback to static mappings
|
||||||
|
video_codec_mapping = CODEC_MAPPINGS.get('video', {})
|
||||||
|
codec_name = video_codec_mapping.get(codec_type)
|
||||||
|
|
||||||
|
if codec_name:
|
||||||
|
return codec_name
|
||||||
|
|
||||||
|
else:
|
||||||
|
logging.warning(f"No corresponding video codec found for {video_codec_identifier}. Using default codec libx264.")
|
||||||
|
return "libx264" # Default
|
||||||
|
|
||||||
|
def convert_audio_codec(self, audio_codec_identifier) -> str:
|
||||||
|
|
||||||
|
"""
|
||||||
|
Convert audio codec identifier to codec name.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- audio_codec_identifier (str): Identifier of the audio codec.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
- str: Codec name corresponding to the identifier.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Extract codec type from the identifier
|
||||||
|
codec_type = audio_codec_identifier.split('.')[0]
|
||||||
|
|
||||||
|
# Retrieve codec mapping from the provided mappings or fallback to static mappings
|
||||||
|
audio_codec_mapping = CODEC_MAPPINGS.get('audio', {})
|
||||||
|
codec_name = audio_codec_mapping.get(codec_type)
|
||||||
|
|
||||||
|
if codec_name:
|
||||||
|
return codec_name
|
||||||
|
|
||||||
|
else:
|
||||||
|
logging.warning(f"No corresponding audio codec found for {audio_codec_identifier}. Using default codec aac.")
|
||||||
|
return "aac" # Default
|
||||||
|
|
||||||
|
def parse_codecs(self):
|
||||||
|
"""
|
||||||
|
Parse video and audio codecs.
|
||||||
|
|
||||||
|
This method updates `video_codec_name` and `audio_codec_name` attributes.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.video_codec_name = self.convert_video_codec(self.video_codec)
|
||||||
|
self.audio_codec_name = self.convert_audio_codec(self.audio_codec)
|
||||||
|
logging.info(f"CODECS={self.video_codec_name},{self.audio_codec_name}")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""
|
"""
|
||||||
Returns a string representation of the M3U8Codec object.
|
Returns a string representation of the M3U8Codec object.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user