Skip to content

Commit

Permalink
raise exception when retcode != 0
Browse files Browse the repository at this point in the history
  • Loading branch information
rany2 committed Mar 10, 2022
1 parent c24183a commit e08b94c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions examples/02_subrip_to_mp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 = {}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e08b94c

Please sign in to comment.