Skip to content

Commit e6f2055

Browse files
TEST movie: check number of frames
1 parent 314cc2a commit e6f2055

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

surfer/tests/test_viz.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import os
33
import os.path as op
44
from os.path import join as pjoin
5+
import re
56
import shutil
7+
import subprocess
8+
from nose.tools import assert_equal
69
from numpy.testing import assert_raises, assert_array_equal
710
from tempfile import mkdtemp, mktemp
811
import nibabel as nib
@@ -226,9 +229,19 @@ def test_movie():
226229
# save movies with different options
227230
tempdir = mkdtemp()
228231
try:
229-
dst = os.path.join(tempdir, 'test')
232+
dst = os.path.join(tempdir, 'test.mov')
230233
brain.save_movie(dst)
231234
brain.save_movie(dst, tmin=0.081, tmax=0.102)
235+
# test the number of frames in the movie
236+
sp = subprocess.Popen(('ffmpeg', '-i', 'test.mov', '-vcodec', 'copy',
237+
'-f', 'null', '/dev/null'), cwd=tempdir,
238+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
239+
stdout, stderr = sp.communicate()
240+
m = re.search('frame=\s*(\d+)\s', stderr)
241+
if not m:
242+
raise RuntimeError(stderr)
243+
n_frames = int(m.group(1))
244+
assert_equal(n_frames, 3)
232245
finally:
233246
# clean up
234247
shutil.rmtree(tempdir)

0 commit comments

Comments
 (0)