Skip to content

Commit

Permalink
Remove file check and rename to pyffprobe
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed May 5, 2019
1 parent 1928a42 commit 2f73076
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 57 deletions.
File renamed without changes.
File renamed without changes.
81 changes: 39 additions & 42 deletions ffprobe3/ffprobe.py → pyffprobe3/ffprobe.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,46 @@ def __init__(self, video_file):
subprocess.check_call(["ffprobe", "-h"], stdout=tempf, stderr=tempf)
except:
raise IOError('ffprobe not found.')
if os.path.isfile(video_file):
if str(platform.system()) == 'Windows':
cmd = ["ffprobe", "-show_streams", self.video_file]
else:
cmd = ["ffprobe -show_streams " + pipes.quote(self.video_file)]

p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
self.format = None
self.created = None
self.duration = None
self.start = None
self.bitrate = None
self.streams = []
self.video = []
self.audio = []
data_lines = []
for a in iter(p.stdout.readline, b''):
a = a.decode('UTF-8')
if re.match(r'\[STREAM\]', a):
data_lines = []
elif re.match(r'\[/STREAM\]', a):
self.streams.append(FFStream(data_lines))
data_lines = []
else:
data_lines.append(a)
for a in iter(p.stderr.readline, b''):
a = a.decode('UTF-8')
if re.match(r'\[STREAM\]', a):
data_lines = []
elif re.match(r'\[/STREAM\]', a):
self.streams.append(FFStream(data_lines))
data_lines = []
else:
data_lines.append(a)
p.stdout.close()
p.stderr.close()
for a in self.streams:
if a.is_audio():
self.audio.append(a)
if a.is_video():
self.video.append(a)
if str(platform.system()) == 'Windows':
cmd = ["ffprobe", "-show_streams", self.video_file]
else:
raise IOError('No such media file ' + video_file)
cmd = ["ffprobe -show_streams " + pipes.quote(self.video_file)]

p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
self.format = None
self.created = None
self.duration = None
self.start = None
self.bitrate = None
self.streams = []
self.video = []
self.audio = []
data_lines = []
for a in iter(p.stdout.readline, b''):
a = a.decode('UTF-8')
if re.match(r'\[STREAM\]', a):
data_lines = []
elif re.match(r'\[/STREAM\]', a):
self.streams.append(FFStream(data_lines))
data_lines = []
else:
data_lines.append(a)
for a in iter(p.stderr.readline, b''):
a = a.decode('UTF-8')
if re.match(r'\[STREAM\]', a):
data_lines = []
elif re.match(r'\[/STREAM\]', a):
self.streams.append(FFStream(data_lines))
data_lines = []
else:
data_lines.append(a)
p.stdout.close()
p.stderr.close()
for a in self.streams:
if a.is_audio():
self.audio.append(a)
if a.is_video():
self.video.append(a)


class FFStream:
Expand Down
24 changes: 9 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@
from distutils.core import setup

setup(
name='ffprobe3',
version='0.1.2',
description="""
Original Project: ffprobe (https://pypi.python.org/pypi/ffprobe)
A wrapper around ffprobe command to extract metadata from media files.
This project which is maintained by Dheerendra Rathor is a Python 3 port of original ffprobe.
""",
name='pyffprobe',
version='1.0.0',
description="A wrapper around ffprobe command to extract metadata from media files.",
author='Simon Hargreaves',
author_email='simon@simon-hargreaves.com',
maintainer='Dheerendra Rathor',
maintainer_email='dheeru.rathor14@gmail.com',
url='https://github.com/DheerendraRathor/ffprobe3',
packages=['ffprobe3'],
maintainer='Vereniging Campus Kabel',
maintainer_email='info@vck.utwente.nl',
url='https://github.com/VerenigingCampusKabel/ffprobe3',
packages=['pyffprobe3'],
keywords='ffmpeg, ffprobe, mpeg, mp4',
classifiers=[
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
Expand All @@ -29,7 +23,7 @@
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Natural Language :: English',
'Topic :: Multimedia :: Video',
Expand Down

0 comments on commit 2f73076

Please sign in to comment.