vcs icon indicating copy to clipboard operation
vcs copied to clipboard

Error using regex on ffmpeg

Open ghost opened this issue 8 years ago • 0 comments

@doutriaux1 @chaosphere2112 Given the following doctest:

>>> a=vcs.init()
>>> import cdms2
>>> f = cdms2.open(vcs.sample_data+'/clt.nc')
>>> v = f('v') # use the data file to create a cdms2 slab
>>> u = f('u') # use the data file to create a cdms2 slab
>>> png_files = [] # for saving file names to make the mpeg
>>> for i in range(10): # create a number of pngs to use for an mpeg
...     a.clear()
...     if (i%2):
...         a.plot(u,v)
...     else:
...         a.plot(v,u)
...     a.png('my_png__%i' % i)
...     png_files.append('my_png__%i.png' % i)
>>> a.ffmpeg('mymovie.mpeg',png_files) # generates from list of files
True
>>> a.ffmpeg('mymovie.mpeg',files="my_png__[0-9]*\.png") # generate from files with name matching regex
True
>>> a.ffmpeg('mymovie.mpeg',png_files,bitrate=512) # generates mpeg at 512kbit
True
>>> a.ffmpeg('mymovie.mpeg',png_files,rate=50) # generates movie with 50 frame per second
True

I'm getting the exception:

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-14-221dba5d3e4b> in <module>()
----> 1 a.ffmpeg('mymovie.mpeg',files="my_png__[0-9]*\.png")

/Users/brown308/anaconda/envs/2.8/lib/python2.7/site-packages/vcs/Canvas.pyc in ffmpeg(self, movie, files, bitrate, rate, options)
   4589         args.extend(("-pix_fmt", "yuv420p"))
   4590 
-> 4591         if test_file is not False:
   4592             # H264 requires even numbered heights and widths
   4593             width, height = self.backend.png_dimensions(test_file)

UnboundLocalError: local variable 'test_file' referenced before assignment

I'm not sure if I'm using the regex functionality correctly or if it even works, but it looks like test_file isn't being declared before its value is checked.

ghost avatar Dec 05 '16 20:12 ghost