Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion 10 ffprobe/ffprobe.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self, path_to_video):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

stream = False
ignoreLine = False
self.streams = []
self.video = []
self.audio = []
Expand All @@ -47,13 +48,20 @@ def __init__(self, path_to_video):

if '[STREAM]' in line:
stream = True
ignoreLine = False
data_lines = []
elif '[/STREAM]' in line and stream:
stream = False
ignoreLine = False
# noinspection PyUnboundLocalVariable
self.streams.append(FFStream(data_lines))
elif stream:
data_lines.append(line)
if '[SIDE_DATA]' in line:
ignoreLine = True
elif '[/SIDE_DATA]' in line:
ignoreLine = False
elif ignoreLine == False:
data_lines.append(line)

self.metadata = {}
is_metadata = False
Expand Down
33 changes: 0 additions & 33 deletions 33 tests/ffprobe-test.py

This file was deleted.

32 changes: 32 additions & 0 deletions 32 tests/ffprobe_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import print_function

import os
from ffprobe import FFProbe
from ffprobe.exceptions import FFProbeError

test_dir = os.path.dirname(os.path.abspath(__file__))

test_videos = [
os.path.join(test_dir, './data/SampleVideo_720x480_5mb.mp4'),
os.path.join(test_dir, './data/SampleVideo_1280x720_1mb.mp4'),
]

def test_video ():
for test_video in test_videos:
media = FFProbe(test_video)
print('File:', test_video)
print('\tStreams:', len(media.streams))
for index, stream in enumerate(media.streams, 1):
print('\tStream: ', index)
try:
if stream.is_video():
frame_rate = stream.frames() / stream.duration_seconds()
print('\t\tFrame Rate:', frame_rate)
print('\t\tFrame Size:', stream.frame_size())
print('\t\tDuration:', stream.duration_seconds())
print('\t\tFrames:', stream.frames())
print('\t\tIs video:', stream.is_video())
except FFProbeError as e:
print(e)
except Exception as e:
print(e)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.