Skip to content

Commit

Permalink
include video framerate in output png filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
mkjones committed Apr 27, 2015
1 parent e6d9b1f commit bd82193
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 9 additions & 2 deletions SlitProcessor.py
Expand Up @@ -51,5 +51,12 @@ def getImageFilename(self):
filename_parts = filename.split('/')
name = filename_parts[-1]
name = name.split('.')[0]
return '%s/%s-%d-%03d.png' % ('/'.join(filename_parts[0:-1]), name,
self.numRows, self.slitPosition)


return '%s/%s-%dfps-%d-%03d.png' % (
'/'.join(filename_parts[0:-1]),
name,
self.video.getFramerate(),
self.numRows,
self.slitPosition
)
9 changes: 9 additions & 0 deletions Video.py
Expand Up @@ -47,6 +47,7 @@ class VideoReader:
numFrames = None
width = None
height = None
framerate = None

def __init__(self, filename):
self.filename = filename
Expand All @@ -70,6 +71,11 @@ def getHeight(self):
self._populateMetadata()
return self.height

def getFramerate(self):
if self.framerate is None:
self._populateMetadata()
return self.framerate

def _populateMetadata(self):
info_args = ('ffmpeg', '-i', self.filename, '-vcodec', 'copy',
'-f', 'rawvideo', '-y', '/dev/null')
Expand All @@ -85,6 +91,9 @@ def _populateMetadata(self):
self.width = int(matches.group(1))
self.height = int(matches.group(2))

matches = re.search(' ([\d\.]+) fps[,$]', stderr)
self.framerate = int(round(float(matches.group(1))))

def getFrames(self):
args = [
"ffmpeg",
Expand Down

0 comments on commit bd82193

Please sign in to comment.