From 4c68bac1892242ac301993223fb8e2f8c40cb774 Mon Sep 17 00:00:00 2001 From: spl0k Date: Sun, 20 Oct 2013 17:27:20 +0200 Subject: [PATCH] Transcoding supbprocess error handling --- api/media.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/api/media.py b/api/media.py index 13322d7..0c4a564 100755 --- a/api/media.py +++ b/api/media.py @@ -60,11 +60,14 @@ def stream_media(): return request.error_formatter(0, 'No way to transcode from {} to {}'.format(src_suffix, dst_suffix)) transcoder, decoder, encoder = map(lambda x: prepare_transcoding_cmdline(x, res.path, src_suffix, dst_suffix, dst_bitrate), [ transcoder, decoder, encoder ]) - if transcoder: - proc = subprocess.Popen(transcoder, stdout = subprocess.PIPE) - else: - dec_proc = subprocess.Popen(decoder, stdout = subprocess.PIPE) - proc = subprocess.Popen(encoder, stdin = dec_proc.stdout, stdout = subprocess.PIPE) + try: + if transcoder: + proc = subprocess.Popen(transcoder, stdout = subprocess.PIPE) + else: + dec_proc = subprocess.Popen(decoder, stdout = subprocess.PIPE) + proc = subprocess.Popen(encoder, stdin = dec_proc.stdout, stdout = subprocess.PIPE) + except: + return request.error_formatter(0, 'Error while running the transcoding process') def transcode(): while True: