Better input handling
This commit is contained in:
parent
8edf92e0cc
commit
1e6f056156
|
@ -45,10 +45,10 @@ def get_tag() -> str:
|
|||
return ''.join(random.choices(string.ascii_uppercase + string.digits, k=5))
|
||||
|
||||
|
||||
def call_ffmpeg(command: str) -> bool:
|
||||
print("ffmpeg", *command.split(' '))
|
||||
process = subprocess.run(["ffmpeg", '-hide_banner', '-loglevel', 'error',
|
||||
*command.split(' ')])
|
||||
def call_ffmpeg(command: List[str]) -> bool:
|
||||
print("ffmpeg", ' '.join(command))
|
||||
full_command = ["ffmpeg", '-hide_banner', '-loglevel', 'error'] + command
|
||||
process = subprocess.run(full_command)
|
||||
return process.returncode == 0
|
||||
|
||||
|
||||
|
@ -61,16 +61,16 @@ def generate_gif_files(inputs: List[str], args: Dict[str, Any]) -> Dict[str, Tup
|
|||
|
||||
interpolate_cmd = ''
|
||||
if interpolate != 'none':
|
||||
interpolate_cmd = f"minterpolate=fps={ \
|
||||
interpolate_cmd = f"minterpolate=fps={
|
||||
framerate}:mi_mode={interpolate},"
|
||||
|
||||
output_map = {}
|
||||
for input in inputs:
|
||||
file_name = f"{Path(input).stem}_{tag}.gif"
|
||||
full_path = f"{Path(input).parent}/{file_name}"
|
||||
success = call_ffmpeg(f"-i {input} -f gif -r {framerate} -filter_complex {interpolate_cmd}scale={ \
|
||||
width}:-1:flags={scaler},split[v1][v2];[v1]palettegen[plt];[v2][plt]paletteuse { \
|
||||
full_path}")
|
||||
command = ['-i', input, '-f', 'gif', '-r', f"{framerate}", '-filter_complex', f"{interpolate_cmd}scale={ \
|
||||
width}:-1:flags={scaler},split[v1][v2];[v1]palettegen[plt];[v2][plt]paletteuse", f"{full_path}"]
|
||||
success = call_ffmpeg(command)
|
||||
# Tuple of (was it successful?, path of output)
|
||||
output_map[input] = (success, full_path)
|
||||
|
||||
|
|
Loading…
Reference in New Issue