fixed dropdown bar visibility
This commit is contained in:
@ -13,6 +13,20 @@ from typing import List
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _get_codec_args(format_hint: str, has_video: bool = True) -> list:
|
||||
"""Return FFmpeg codec arguments for the given format."""
|
||||
if format_hint == "wav":
|
||||
return ["-c:a", "pcm_s16le"]
|
||||
if format_hint == "webm":
|
||||
if has_video:
|
||||
return ["-c:v", "libvpx-vp9", "-crf", "30", "-b:v", "0", "-c:a", "libopus"]
|
||||
return ["-c:a", "libopus", "-b:a", "160k"]
|
||||
# Default: MP4
|
||||
if has_video:
|
||||
return ["-c:v", "libx264", "-preset", "medium", "-crf", "18", "-c:a", "aac", "-b:a", "192k"]
|
||||
return ["-c:a", "aac", "-b:a", "192k"]
|
||||
|
||||
|
||||
def _input_has_video_stream(ffmpeg_cmd: str, input_path: str) -> bool:
|
||||
"""Return True if the input contains at least one video stream."""
|
||||
ffprobe = ffmpeg_cmd.replace("ffmpeg", "ffprobe")
|
||||
@ -135,7 +149,7 @@ def export_stream_copy(
|
||||
output_path on success
|
||||
"""
|
||||
if mute_ranges:
|
||||
# Mute ranges require audio filtering, so fall back to re-encoding
|
||||
# Mute ranges require audio filtering, so fall back to re-encode
|
||||
return export_reencode(input_path, output_path, keep_segments, "1080p", "mp4", mute_ranges)
|
||||
ffmpeg = _find_ffmpeg()
|
||||
if not _input_has_video_stream(ffmpeg, input_path):
|
||||
@ -283,16 +297,14 @@ def export_reencode(
|
||||
|
||||
filter_complex = "".join(filter_parts)
|
||||
|
||||
audio_codec_args = ["-c:a", "aac", "-b:a", "192k"]
|
||||
if format_hint == "webm":
|
||||
audio_codec_args = ["-c:a", "libopus", "-b:a", "160k"]
|
||||
codec_args = _get_codec_args(format_hint, has_video=False)
|
||||
|
||||
cmd = [
|
||||
ffmpeg, "-y",
|
||||
"-i", input_path,
|
||||
"-filter_complex", filter_complex,
|
||||
"-map", audio_map,
|
||||
*audio_codec_args,
|
||||
*codec_args,
|
||||
output_path,
|
||||
]
|
||||
|
||||
@ -324,9 +336,7 @@ def export_reencode(
|
||||
|
||||
filter_complex = f"[0:a]{audio_filter}[a];[0:v]{video_filter}{video_map}"
|
||||
|
||||
codec_args = ["-c:v", "libx264", "-preset", "medium", "-crf", "18", "-c:a", "aac", "-b:a", "192k"]
|
||||
if format_hint == "webm":
|
||||
codec_args = ["-c:v", "libvpx-vp9", "-crf", "30", "-b:v", "0", "-c:a", "libopus"]
|
||||
codec_args = _get_codec_args(format_hint, has_video)
|
||||
|
||||
cmd = [
|
||||
ffmpeg, "-y",
|
||||
@ -385,9 +395,7 @@ def export_reencode(
|
||||
else:
|
||||
video_map = "[outv]"
|
||||
|
||||
codec_args = ["-c:v", "libx264", "-preset", "medium", "-crf", "18", "-c:a", "aac", "-b:a", "192k"]
|
||||
if format_hint == "webm":
|
||||
codec_args = ["-c:v", "libvpx-vp9", "-crf", "30", "-b:v", "0", "-c:a", "libopus"]
|
||||
codec_args = _get_codec_args(format_hint, has_video)
|
||||
|
||||
cmd = [
|
||||
ffmpeg, "-y",
|
||||
@ -489,9 +497,7 @@ def export_reencode_with_subs(
|
||||
|
||||
filter_complex = f"[0:a]{audio_filter}[a];[0:v]{video_filter}[v]"
|
||||
|
||||
codec_args = ["-c:v", "libx264", "-preset", "medium", "-crf", "18", "-c:a", "aac", "-b:a", "192k"]
|
||||
if format_hint == "webm":
|
||||
codec_args = ["-c:v", "libvpx-vp9", "-crf", "30", "-b:v", "0", "-c:a", "libopus"]
|
||||
codec_args = _get_codec_args(format_hint, has_video=True)
|
||||
|
||||
cmd = [
|
||||
ffmpeg, "-y",
|
||||
@ -547,9 +553,7 @@ def export_reencode_with_subs(
|
||||
filter_complex += f";[outv]ass='{escaped_sub}'[outv_final]"
|
||||
video_map = "[outv_final]"
|
||||
|
||||
codec_args = ["-c:v", "libx264", "-preset", "medium", "-crf", "18", "-c:a", "aac", "-b:a", "192k"]
|
||||
if format_hint == "webm":
|
||||
codec_args = ["-c:v", "libvpx-vp9", "-crf", "30", "-b:v", "0", "-c:a", "libopus"]
|
||||
codec_args = _get_codec_args(format_hint, has_video=True)
|
||||
|
||||
cmd = [
|
||||
ffmpeg, "-y",
|
||||
|
||||
Reference in New Issue
Block a user