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

Add ffprobe support #67

merged 5 commits into from
May 9, 2018

Conversation

kkroening
Copy link
Owner
@kkroening kkroening commented Jan 28, 2018

Adds convenient ffprobe support. Example - print duration of file:

import ffmpeg
print(ffmpeg.probe('in.mp4')['format']['duration']))

@depau
Copy link
Collaborator
depau commented Feb 5, 2018

I didn't know Python3 removed .message from Exception, that's interesting.
According to this, str(exception) should return the message. I quickly tested it and it seems it works on both Py2 and 3.

@depau
Copy link
Collaborator
depau commented Mar 8, 2018

This should fix it

@kkroening kkroening merged commit 7077eaa into master May 9, 2018
@kkroening kkroening deleted the probe branch May 9, 2018 06:28
denilsonsa added a commit to denilsonsa/genRSS that referenced this pull request Apr 30, 2022
This is enabled by default, and will gracefully skip the duration if
`ffprobe` is not available or fails to run.

I thought about adding a command-line toggle, but I would prefer to have
it enabled by default (i.e. sane defaults), which would make the
parameter name a bit weird. And then I wonder if the command-line toggle
is actually needed for this. (Why would any user want to not include the
duration? I can't think of any good reason.)

The tests are currently passing, but that's because there is no test
media file with real media data; all of the files in `test/media/` are
either empty or only have metadata without any actual data. In such
cases, the duration is unknown/empty. If anyone can produce a test media
file, we can improve the tests (they are currently marked as TODO).

The code is inspired by
kkroening/ffmpeg-python#67

The code can be one line shorter if we start using the := (walrus)
operator, but it's only available in Python 3.8 and I don't see any
reason to break compatibility with (slightly) older versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0