From e08b94c6aca0ab68cc1646df6e03f19771d37ad1 Mon Sep 17 00:00:00 2001 From: rany Date: Thu, 10 Mar 2022 15:22:25 +0200 Subject: [PATCH] raise exception when retcode != 0 --- examples/02_subrip_to_mp3.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/02_subrip_to_mp3.py b/examples/02_subrip_to_mp3.py index e72e926..f5df159 100755 --- a/examples/02_subrip_to_mp3.py +++ b/examples/02_subrip_to_mp3.py @@ -71,7 +71,7 @@ async def _main(srt_data, voice_name, out_file): ) mother_temp_file = tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) try: - subprocess.call( + process = subprocess.call( [ "ffmpeg", "-y", @@ -86,6 +86,8 @@ async def _main(srt_data, voice_name, out_file): stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) + if process != 0: + raise Exception("ffmpeg failed") input_files = [] input_files_start = {} @@ -150,13 +152,15 @@ async def _main(srt_data, voice_name, out_file): temporary_file2 = tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) try: print("Concatenating...") - subprocess.call( + process = subprocess.call( ["ffmpeg", "-y", "-i", mother_temp_file.name] + ffmpeg_opts + [temporary_file2.name], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, + #stdout=subprocess.DEVNULL, + #stderr=subprocess.DEVNULL, ) + if process != 0: + raise Exception("ffmpeg failed") finally: temporary_file2.close() mother_temp_file.close()