mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Try to fix stuttering (ep_3)
This commit is contained in:
parent
3091eed167
commit
0df589600a
@ -230,7 +230,7 @@ def add_subtitle(input_video_path: str, input_subtitle_path: str, output_video_p
|
|||||||
return output_video_path
|
return output_video_path
|
||||||
|
|
||||||
|
|
||||||
def concatenate_and_save(file_list_path: str, output_filename: str, v_codec: str = None, a_codec: str = None, bandwidth: int = None, prefix: str = "segments", output_directory: str = None) -> str:
|
def concatenate_and_save(file_list_path: str, output_filename: str, v_codec: str = None, a_codec: str = None, bandwidth: int = None, prefix: str = "segments", output_directory: str = None):
|
||||||
"""
|
"""
|
||||||
Concatenate input files and save the output with specified decoding parameters.
|
Concatenate input files and save the output with specified decoding parameters.
|
||||||
|
|
||||||
@ -249,70 +249,36 @@ def concatenate_and_save(file_list_path: str, output_filename: str, v_codec: str
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Input and output arguments
|
|
||||||
input_args = {
|
|
||||||
'format': 'concat',
|
|
||||||
'safe': 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
# Output arguments
|
||||||
output_args = {
|
output_args = {
|
||||||
#'preset': 'ultrafast',
|
|
||||||
'c': 'copy',
|
'c': 'copy',
|
||||||
'loglevel': DEBUG_FFMPEG,
|
'loglevel': DEBUG_FFMPEG,
|
||||||
'y': None,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add BANDWIDTH and CODECS if provided
|
|
||||||
if bandwidth is not None:
|
|
||||||
output_args['b:v'] = str(bandwidth)
|
|
||||||
if USE_CODECS:
|
|
||||||
if v_codec is not None:
|
|
||||||
output_args['vcodec'] = v_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 = output_filename
|
||||||
|
output_file_path = os.path.join(output_directory, output_file_name) if output_directory else output_file_name
|
||||||
|
|
||||||
# Determine output directory
|
# Concatenate input file list and output
|
||||||
if output_directory:
|
|
||||||
output_file_path = os.path.join(output_directory, output_file_name)
|
|
||||||
else:
|
|
||||||
output_file_path = output_file_name
|
|
||||||
|
|
||||||
# Concatenate input files and output
|
|
||||||
output = (
|
output = (
|
||||||
ffmpeg.input(
|
ffmpeg.input(file_list_path, safe=0, f='concat')
|
||||||
file_list_path,
|
.output(output_file_path, **output_args)
|
||||||
**input_args
|
|
||||||
)
|
|
||||||
.output(
|
|
||||||
output_file_path,
|
|
||||||
**output_args
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Overwrite output file if exists
|
# Overwrite output file if exists
|
||||||
output = ffmpeg.overwrite_output(output)
|
output = ffmpeg.overwrite_output(output)
|
||||||
|
|
||||||
# Retrieve the command that will be executed
|
|
||||||
command = output.compile()
|
|
||||||
logging.info(f"Execute command: {command}")
|
|
||||||
|
|
||||||
# Execute the process
|
# Execute the process
|
||||||
process = output.run()
|
process = output.run()
|
||||||
|
|
||||||
except ffmpeg.Error as ffmpeg_error:
|
except ffmpeg.Error as ffmpeg_error:
|
||||||
|
logging.error(f"Error saving MP4: {ffmpeg_error.stderr.decode('utf-8')}")
|
||||||
logging.error(f"Error saving MP4: {ffmpeg_error.stdout}")
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
# Remove the temporary file list and folder and completely remove tmp folder
|
# Remove the temporary file list and folder and completely remove tmp folder
|
||||||
logging.info("Cleanup...")
|
|
||||||
os.remove(file_list_path)
|
os.remove(file_list_path)
|
||||||
shutil.rmtree("tmp", ignore_errors=True)
|
shutil.rmtree("tmp", ignore_errors=True)
|
||||||
|
|
||||||
# Return
|
|
||||||
return output_file_path
|
return output_file_path
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,18 +25,18 @@ def update():
|
|||||||
|
|
||||||
# Make the GitHub API requests and handle potential errors
|
# Make the GitHub API requests and handle potential errors
|
||||||
try:
|
try:
|
||||||
repo_info = requests.get(f"https://api.github.com/repos/{repo_user}/{repo_name}").json()
|
response_reposity = requests.get(f"https://api.github.com/repos/{repo_user}/{repo_name}").json()
|
||||||
release_info = requests.get(f"https://api.github.com/repos/{repo_user}/{repo_name}/releases").json()[0]
|
response_releases = requests.get(f"https://api.github.com/repos/{repo_user}/{repo_name}/releases").json()
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
console.print(f"[red]Error accessing GitHub API: {e}")
|
console.print(f"[red]Error accessing GitHub API: {e}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get start of the reposity
|
# Get start of the reposity
|
||||||
stargazers_count = repo_info['stargazers_count']
|
stargazers_count = response_reposity['stargazers_count']
|
||||||
|
|
||||||
# Find info about latest versione deploy and the donwload count
|
# Find info about latest versione deploy and the donwload count
|
||||||
last_version = release_info['name']
|
last_version = response_releases[0]['name']
|
||||||
down_count = release_info['assets'][0]['download_count']
|
down_count = response_releases[0]['assets'][0]['download_count']
|
||||||
|
|
||||||
# Calculate percentual of start base on download count
|
# Calculate percentual of start base on download count
|
||||||
if down_count > 0 and stargazers_count > 0:
|
if down_count > 0 and stargazers_count > 0:
|
||||||
|
@ -54,4 +54,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user