8000 Add ffprobe support by kkroening · Pull Request #67 · kkroening/ffmpeg-python · GitHub
[go: up one dir, main page]

Skip to content

Add ffprobe support #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix probe exception 8000 handling and add test
  • Loading branch information
kkroening committed Jan 28, 2018
commit 2fff94af6c61530230d27c1a2e84ac1f1bc07c0c
3 changes: 2 additions & 1 deletion ffmpeg/_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ def probe(filename):
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode != 0:
raise ExecException(err)
raise ProbeException(err)
return json.loads(out.decode('utf-8'))


__all__ = [
'probe',
'ProbeException',
]
8 changes: 8 additions & 0 deletions
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
TEST_OVERLAY_FILE = os.path.join(SAMPLE_DATA_DIR, 'overlay.png')
TEST_OUTPUT_FILE1 = os.path.join(SAMPLE_DATA_DIR, 'out1.mp4')
TEST_OUTPUT_FILE2 = os.path.join(SAMPLE_DATA_DIR, 'out2.mp4')
BOGUS_INPUT_FILE = os.path.join(SAMPLE_DATA_DIR, 'bogus')


subprocess.check_call(['ffmpeg', '-version'])
Expand Down Expand Up @@ -359,3 +360,10 @@ def test_ffprobe():
data = ffmpeg.probe(TEST_INPUT_FILE1)
assert set(data.keys()) == {'format', 'streams'}
assert data['format']['duration'] == '7.036000'


def test_ffprobe_exception():
with pytest.raises(ffmpeg.ProbeException) as excinfo:
ffmpeg.probe(BOGUS_INPUT_FILE)
assert excinfo.value.message == 'ffprobe error'
assert 'No such file or directory' in excinfo.value.stderr_output
0