8000 Fix probe exception handling and add test · Powercoder64/ffmpeg-python@2fff94a · GitHub
[go: up one dir, main page]

Skip to content

Commit 2fff94a

Browse files
committed
Fix probe exception handling and add test
1 parent 24e737f commit 2fff94a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ffmpeg/_probe.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ def probe(filename):
1919
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2020
out, err = p.communicate()
2121
if p.returncode != 0:
22-
raise ExecException(err)
22+
raise ProbeException(err)
2323
return json.loads(out.decode('utf-8'))
2424

2525

2626
__all__ = [
2727
'probe',
28+
'ProbeException',
2829
]

ffmpeg/tests/test_ffmpeg.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
TEST_OVERLAY_FILE = os.path.join(SAMPLE_DATA_DIR, 'overlay.png')
1717
TEST_OUTPUT_FILE1 = os.path.join(SAMPLE_DATA_DIR, 'out1.mp4')
1818
TEST_OUTPUT_FILE2 = os.path.join(SAMPLE_DATA_DIR, 'out2.mp4')
19+
BOGUS_INPUT_FILE = os.path.join(SAMPLE_DATA_DIR, 'bogus')
1920

2021

2122
subprocess.check_call(['ffmpeg', '-version'])
@@ -359,3 +360,10 @@ def test_ffprobe():
359360
data = ffmpeg.probe(TEST_INPUT_FILE1)
360361
assert set(data.keys()) == {'format', 'streams'}
361362
assert data['format']['duration'] == '7.036000'
363+
364+
365+
def test_ffprobe_exception():
366+
with pytest.raises(ffmpeg.ProbeException) as excinfo:
367+
ffmpeg.probe(BOGUS_INPUT_FILE)
368+
assert excinfo.value.message == 'ffprobe error'
369+
assert 'No such file or directory' in excinfo.value.stderr_output

0 commit comments

Comments
 (0)
97
0