def split_clip_ffmpeg(video_file, start_time, end_time, output_filepath):
duration = end_time - start_time
'-y', # Overwrite output files without asking
'-ss', str(start_time), # Input level seek (fast, but less accurate)
'-t', str(duration), # Duration of the output clip
'-c:v', 'h264_nvenc', # Use NVIDIA GPU encoding
'-c:a', 'aac', # Re-encode audio to AAC
'-b:v', '5M', # Set video bitrate (optional, can adjust as needed)
'-preset', 'fast', # Set nvenc preset (e.g., slow, medium, fast)
subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print(f"Created {output_filepath}")
except subprocess.CalledProcessError as e:
print(f"Error creating {output_filepath}: {e.stderr.decode()}")