Skip to content

Commit 5177e51

Browse files
committed
Will throw exceptions on windows
1 parent ebb6ea5 commit 5177e51

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

octoprint_obico/webcam_stream.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import sarge
88
import sys
99
import flask
10+
import traceback
1011
from collections import deque
1112
try:
1213
import queue
@@ -85,15 +86,18 @@ def get_webcam_resolution(webcam_config):
8586
def find_ffmpeg_h264_encoder():
8687
test_video = os.path.join(FFMPEG_DIR, 'test-video.mp4')
8788
FNULL = open(os.devnull, 'w')
88-
for encoder in ['h264_omx', 'h264_v4l2m2m']:
89-
ffmpeg_cmd = '{} -re -i {} -pix_fmt yuv420p -vcodec {} -an -f rtp rtp://127.0.0.1:8014?pkt_size=1300'.format(FFMPEG, test_video, encoder)
90-
_logger.debug('Popen: {}'.format(ffmpeg_cmd))
91-
ffmpeg_test_proc = subprocess.Popen(ffmpeg_cmd.split(' '), stdout=FNULL, stderr=FNULL)
92-
if ffmpeg_test_proc.wait() == 0:
93-
if encoder == 'h264_omx':
94-
return '-flags:v +global_header -c:v {} -bsf dump_extra'.format(encoder) # Apparently OMX encoder needs extra param to get the stream to work
95-
else:
96-
return '-c:v {}'.format(encoder)
89+
try:
90+
for encoder in ['h264_omx', 'h264_v4l2m2m']:
91+
ffmpeg_cmd = '{} -re -i {} -pix_fmt yuv420p -vcodec {} -an -f rtp rtp://127.0.0.1:8014?pkt_size=1300'.format(FFMPEG, test_video, encoder)
92+
_logger.debug('Popen: {}'.format(ffmpeg_cmd))
93+
ffmpeg_test_proc = subprocess.Popen(ffmpeg_cmd.split(' '), stdout=FNULL, stderr=FNULL)
94+
if ffmpeg_test_proc.wait() == 0:
95+
if encoder == 'h264_omx':
96+
return '-flags:v +global_header -c:v {} -bsf dump_extra'.format(encoder) # Apparently OMX encoder needs extra param to get the stream to work
97+
else:
98+
return '-c:v {}'.format(encoder)
99+
except Exception as e:
100+
_logger.exception('Failed to find ffmpeg h264 encoder. Exception: %s\n%s', e, traceback.format_exc())
97101

98102
_logger.warn('No ffmpeg found, or ffmpeg does NOT support h264_omx/h264_v4l2m2m encoding.')
99103
return None

0 commit comments

Comments
 (0)