+import bt
+
+
+class CIWorker(threading.Thread):
+ """
+ Content Ingestion Worker. A class which executes content ingestion jobs
+ on a separate thread.
+
+ CIWorker shares a Queue with its master where jobs are submitted.
+ """
+
+ def __init__(self, queue):
+ threading.Thread.__init__(self)
+
+ self.queue = queue
+
+ def run(self):
+ while True:
+ job = self.queue.get()
+
+ # * TRANSFER RAW VIDEO IN
+ file_transfer = config.FILE_TRANSFERER_CLASS( \
+ 'tmp/raw', config.INPUT_PATH)
+ file_transfer.get([job.raw_video])
+ file_transfer.close()
+
+ # * TRANSCODE RAW VIDEO
+ transcoder = config.TRANSCODER_CLASS(input_file = job.raw_video, \
+ name = job.name, prog_bin = config.TRANSCODER_BIN)
+
+ # Transcode the raw video in each requested format.
+ for transcode_config in job.transcode_configs:
+ transcode_config['output_file'] = transcoder.transcode( \
+ container = transcode_config.container, \
+ a_codec = transcode_config.a_codec, \
+ a_bitrate = transcode_config.a_bitrate, \
+ a_samplingrate = transcode_config.a_samplingrate, \
+ a_channels = transcode_config.a_channels, \
+ v_codec = transcode_config.v_codec, \
+ v_bitrate = transcode_config.v_bitrate, \
+ v_framerate = transcode_config.v_framerate, \
+ v_resolution = transcode_config.v_resolution, \
+ v_dar = transcode_config.dar)
+
+ # * EXTRACT THUMBNAIL IMAGES
+ thumb_extractor = config.THUMB_EXTRACTOR_CLASS( \
+ input_file = job.raw_video, name = job.name, \
+ prog_bin = config.THUMB_EXTRACTOR_BIN)
+ # TODO thumbnail extraction type must be got from input
+ thumb_extractor.extract_random_thumb()
+ print thumb_extractor.extract_summary_thumbs(5)
+
+
+ queue.task_done()