~francesco-hermanitosverdes/openshot/hv_francesco

« back to all changes in this revision

Viewing changes to openshot/classes/cli_render.py

  • Committer: francesco fantoni
  • Date: 2010-01-15 10:03:52 UTC
  • Revision ID: francesco@francesco-20100115100352-em209jtq49mvu8ol
Cleaned command-line rendering from all stupid things
I had introduced not knowig enough MLT python api.
Now it looks much more logic and clean, and it handles
correctly keyboard interrupt by user

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
                        spaces = math.floor(width - marks)
259
259
                        loader = '[' + ('=' * int(marks)) + (' ' * int(spaces)) + ']'
260
260
                        sys.stdout.write("%s %d%%\r" % (loader, percent))
261
 
                        if percent >= 100:
262
 
                                sys.stdout.write("\n")
 
261
                        #if percent >= 100:
 
262
                                #sys.stdout.write("\n")
263
263
                        sys.stdout.flush()
264
264
 
265
 
 
266
 
                # track if this thread should die
267
 
                self.amAlive = True                     
268
265
                # Create producer and initialize mlt
 
266
                self.f = mlt.Factory().init()
269
267
                self.p = mlt.Producer( self.profile, 'xml:%s' % self.file_name)
270
 
                self.f = mlt.Factory().init()
271
268
                self.p.set_speed(0)
272
269
                out_folder = self.render_options["folder"]
273
270
                out_file = self.render_options["file"]
276
273
                export_path = "%s.%s" % (os.path.join(out_folder, out_file), self.render_options["f"])
277
274
 
278
275
                # RENDER MOVIE
279
 
                print _("Starting rendering to") + str(export_path)
 
276
                print _("Starting rendering to ") + str(export_path)
280
277
                self.c = mlt.Consumer( self.profile, "avformat", export_path)
281
278
 
282
279
                # set some RENDER specific options
304
301
                
305
302
                # init the render percentage
306
303
                self.fraction_complete = 0.0
 
304
                self.render_interrupted = False
307
305
 
308
 
                
309
 
                while self.amAlive == True:
310
 
                        if self.c.is_stopped() == False:
311
 
                                # update Export Dialog Progress Bar
312
 
                                self.fraction_complete = (float(self.p.position()) / float(self.p.get_length() - 1))
313
 
                                progress(50, int(self.fraction_complete*100))
314
 
                                # wait 1/5 of a second
 
306
                while self.c.is_stopped() == False:
 
307
                        # update Export Dialog Progress Bar
 
308
                        self.fraction_complete = (float(self.p.position()) / float(self.p.get_length() - 1))
 
309
                        progress(50, int(self.fraction_complete*100))
 
310
                        # wait 1/5 of a second
 
311
                        try:
315
312
                                time.sleep( 0.2 )
316
 
                        else:
317
 
                                self.amAlive = False
318
 
                                time.sleep(1)
319
 
 
320
 
                # Go
321
 
                if self.c.is_stopped() == False:
322
 
                        self.c.run()
323
 
 
 
313
                        except KeyboardInterrupt:
 
314
                                print "\n"
 
315
                                print _("program interrupted by user")
 
316
                                self.render_interrupted = True
 
317
                                self.c.stop()
 
318
                
 
319
                if self.render_interrupted == False:
 
320
                        progress(50, 100)
 
321
                        print "\n"
 
322
                        print _("project file correctly rendered")
 
323
                        
324
324
                # clear all the MLT objects
325
325
                self.c.stop()
326
326
                self.p = None