Skip to content

Commit

Permalink
Merge pull request #71 from Zulko/master
Browse files Browse the repository at this point in the history
Properly seek a given time with FFMPEG (solves issue #66)
  • Loading branch information
almarklein committed Feb 13, 2015
2 parents d825593 + 945be77 commit 7dcf943
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions imageio/plugins/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,24 @@ def _reinitialize(self, index=0):
else:
starttime = index / self._meta['fps']
offset = min(1, starttime)

# Create input args -> start time
iargs = ['-ss', "%.03f" % (starttime-offset)]
iargs = ['-ss', "%.03f" % (starttime-offset),
'-i', self._filename,
'-ss', "%.03f" % offset]

# Output args, for writing to pipe
oargs = ['-f', 'image2pipe',
'-pix_fmt', self._pix_fmt,
'-vcodec', 'rawvideo']
oargs.extend(['-s', self._arg_size] if self._arg_size else [])

# Create process
cmd = [self._exe]
cmd += iargs + ['-i', self._filename] + oargs + ['-']
cmd += iargs + oargs + ['-']
self._proc = sp.Popen(cmd, stdin=sp.PIPE,
stdout=sp.PIPE, stderr=sp.PIPE)

# Create thread that keeps reading from stderr
self._stderr_catcher = StreamCatcher(self._proc.stderr)

Expand Down

0 comments on commit 7dcf943

Please sign in to comment.