Skip to content

Commit

Permalink
Raise error if call to ffmpeg fails
Browse files Browse the repository at this point in the history
  • Loading branch information
naglis committed Nov 13, 2024
1 parent 7d5d0f9 commit ce12a28
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions aeneas/ffmpegwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"""

import subprocess
import os.path

from aeneas.logger import Loggable
from aeneas.runtimeconfiguration import RuntimeConfiguration
Expand Down Expand Up @@ -216,16 +217,13 @@ def convert(
arguments.append(output_file_path)
self.log(["Calling with arguments '%s'", arguments])
try:
proc = subprocess.Popen(
proc = subprocess.run(
arguments,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
)
proc.communicate()
proc.stdout.close()
proc.stdin.close()
proc.stderr.close()
except OSError as exc:
self.log_exc(
"Unable to call the '%s' ffmpeg executable"
Expand All @@ -234,12 +232,15 @@ def convert(
True,
FFMPEGPathError,
)
except subprocess.CalledProcessError as e:
self.log_exc("ffmpeg returned non-zero status %r: %s" % (e.returncode, e.stderr), critical=True, raise_type=OSError)

self.log("Call completed")

# check if the output file exists
if not gf.file_exists(output_file_path):
if not os.path.isfile(output_file_path):
self.log_exc(
"Output file '%s' was not written" % (output_file_path),
f"Output file {output_file_path!r} was not written",
None,
True,
OSError,
Expand Down

0 comments on commit ce12a28

Please sign in to comment.