Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions better_ffmpeg_progress/better_ffmpeg_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def __init__(

self._ffmpeg_log_file = Path(
ffmpeg_log_file or f"{self._input_filepath.name}_ffmpeg_log.txt"
)
) if (isinstance(ffmpeg_log_file, os.PathLike) or ffmpeg_log_file is None) else ffmpeg_log_file

self._print_detected_duration = print_detected_duration
self._duration_secs = get_media_duration(input_file_path_str)

Expand Down Expand Up @@ -151,7 +152,22 @@ def run(
self._return_code = 1

try:
with open(self._ffmpeg_log_file, "w", encoding="utf-8") as f:
if isinstance(self._ffmpeg_log_file, (str, Path)):
with open(self._ffmpeg_log_file, "w", encoding="utf-8") as f:
creationflags = 0

if os.name == "nt":
creationflags = subprocess.CREATE_NEW_PROCESS_GROUP

self._process = subprocess.Popen(
current_ffmpeg_command,
shell=self._shell_needed,
stdout=subprocess.PIPE,
stderr=f,
creationflags=creationflags,
)
else:
# Assume it's a valid file descriptor like sys.stdout
creationflags = 0

if os.name == "nt":
Expand All @@ -161,7 +177,7 @@ def run(
current_ffmpeg_command,
shell=self._shell_needed,
stdout=subprocess.PIPE,
stderr=f,
stderr=self._ffmpeg_log_file,
creationflags=creationflags,
)
except Exception as e:
Expand Down