2 # -*- coding: utf-8 -*-
5 # Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 # Import required modules
32 # Start the mlt system
33 mlt.mlt_log_set_level(40) # verbose
36 # Establish a pipeline
37 profile = mlt.Profile("atsc_1080i_5994")
38 #profile = mlt.Profile('square_ntsc_wide')
39 profile.set_explicit(1)
40 tractor = mlt.Tractor()
41 tractor.set('eof', 'loop')
42 playlist = mlt.Playlist()
43 playlist.append(mlt.Producer(profile, 'color:'))
46 consumer = 'decklink:0'
48 consumer = sys.argv[1]
49 consumer = mlt.Consumer(profile, consumer)
50 consumer.connect(playlist)
51 #consumer.set("real_time", -2)
58 playlist.append(mlt.Producer(profile, str(resource)))
63 state['tempdir'] = None
65 class MainHandler(tornado.web.RequestHandler):
67 resource = self.get_argument('url', None)
71 self.write('Playing %s\n' % (resource))
74 olddir = state['tempdir']
76 shutil.rmtree(olddir, True)
77 state['tempdir'] = None
81 <p>POST a bunch of files to / to change the output.</p>
82 <p>Or GET / with query string parameter "url" to display something from the network.</p>
86 if len(self.request.files) == 0:
87 self.write('POST a bunch of files to / to change the output')
90 olddir = state['tempdir']
92 state['tempdir'] = tempfile.mkdtemp()
93 for key, items in self.request.files.iteritems():
95 path = os.path.dirname(key)
98 if not os.path.exists(os.path.join(state['tempdir'], path)):
99 os.makedirs(os.path.join(state['tempdir'], path))
100 fn = os.path.join(path, fn)
101 fn = os.path.join(state['tempdir'], fn)
102 if not path and fn.endswith('.html') or fn.endswith('.qml'):
104 with open(fn, 'w') as fo:
106 self.write("Uploaded %s\n" % (fn))
108 self.write('Playing %s\n' % (resource))
111 shutil.rmtree(olddir, True)
113 application = tornado.web.Application([
117 application.listen(8888)
119 tornado.ioloop.IOLoop.instance().start()
125 shutil.rmtree(state['tempdir'], True)