Fixes Issue #2 #4
@ -33,10 +33,16 @@ class Transcoder:
|
|||||||
self.logger.debug("%s - Pool created", package_id)
|
self.logger.debug("%s - Pool created", package_id)
|
||||||
for stream in package['sources']:
|
for stream in package['sources']:
|
||||||
transcodes = {}
|
transcodes = {}
|
||||||
|
|
||||||
|
# If the strean is a colection of slide images that has to be converted to a video
|
||||||
if 'demux_file' in stream:
|
if 'demux_file' in stream:
|
||||||
self.logger.debug("%s - Processing stream %s", package_id, 'slides job in demux.txt')
|
self.logger.debug("%s - Processing stream %s", package_id, 'slides job in demux.txt')
|
||||||
|
|
||||||
|
# Create the different variants
|
||||||
for maxheight in self.variants:
|
for maxheight in self.variants:
|
||||||
crf, preset = self.variants[maxheight]
|
crf, preset = self.variants[maxheight]
|
||||||
|
|
||||||
|
# Call the _Worker function asyncronously
|
||||||
transcodes[maxheight] = pool.apply_async(_Worker.make_slides_video,
|
transcodes[maxheight] = pool.apply_async(_Worker.make_slides_video,
|
||||||
(self.worker,
|
(self.worker,
|
||||||
package_id,
|
package_id,
|
||||||
@ -47,14 +53,21 @@ class Transcoder:
|
|||||||
slides_thumb = 'slides_thumb{}'.format(ext)
|
slides_thumb = 'slides_thumb{}'.format(ext)
|
||||||
shutil.copy2(stream['poster'],os.path.join(workbase, slides_thumb))
|
shutil.copy2(stream['poster'],os.path.join(workbase, slides_thumb))
|
||||||
stream['poster'] = slides_thumb
|
stream['poster'] = slides_thumb
|
||||||
stream.pop('demux_file')
|
|
||||||
|
|
||||||
|
# Remove the reference to the demuxfile since it is no longer needed
|
||||||
|
stream.pop('demux_file')
|
||||||
|
|
||||||
|
# If the strean is a regualr video it needs to be transcoded with new resolution
|
||||||
elif 'video' in stream:
|
elif 'video' in stream:
|
||||||
streampath_rel = stream['video']
|
streampath_rel = stream['video']
|
||||||
streampath_abs = os.path.join(base, streampath_rel)
|
streampath_abs = os.path.join(base, streampath_rel)
|
||||||
self.logger.debug("%s - Processing stream %s", package_id, streampath_rel)
|
self.logger.debug("%s - Processing stream %s", package_id, streampath_rel)
|
||||||
|
|
||||||
|
# Create the different variants
|
||||||
for maxheight in self.variants:
|
for maxheight in self.variants:
|
||||||
crf, preset = self.variants[maxheight]
|
crf, preset = self.variants[maxheight]
|
||||||
|
|
||||||
|
# Call the _Worker function asyncronously
|
||||||
transcodes[maxheight] = pool.apply_async(_Worker.transcode,
|
transcodes[maxheight] = pool.apply_async(_Worker.transcode,
|
||||||
(self.worker,
|
(self.worker,
|
||||||
package_id,
|
package_id,
|
||||||
@ -77,9 +90,11 @@ class Transcoder:
|
|||||||
workbase))
|
workbase))
|
||||||
transcodes['poster'] = thumbjob
|
transcodes['poster'] = thumbjob
|
||||||
|
|
||||||
|
# Store the jobs and streams in the pending array
|
||||||
pending.append({'jobs': transcodes,
|
pending.append({'jobs': transcodes,
|
||||||
'data': stream})
|
'data': stream})
|
||||||
|
|
||||||
|
# Close the pool
|
||||||
pool.close()
|
pool.close()
|
||||||
pool.join()
|
pool.join()
|
||||||
self.logger.info("%s - Finished transcoding", package_id)
|
self.logger.info("%s - Finished transcoding", package_id)
|
||||||
@ -90,6 +105,7 @@ class Transcoder:
|
|||||||
jobs = item['jobs']
|
jobs = item['jobs']
|
||||||
streams = {}
|
streams = {}
|
||||||
for maxheight in self.variants:
|
for maxheight in self.variants:
|
||||||
|
# Get the jobs. If not done wait until they are ready.
|
||||||
streams[maxheight] = jobs[maxheight].get()
|
streams[maxheight] = jobs[maxheight].get()
|
||||||
stream['video'] = streams
|
stream['video'] = streams
|
||||||
if 'poster' in jobs:
|
if 'poster' in jobs:
|
||||||
@ -98,6 +114,7 @@ class Transcoder:
|
|||||||
package['thumb'] = stream['poster']
|
package['thumb'] = stream['poster']
|
||||||
package['sources'].append(stream)
|
package['sources'].append(stream)
|
||||||
|
|
||||||
|
# Return the finished streams
|
||||||
return package
|
return package
|
||||||
|
|
||||||
class _Worker:
|
class _Worker:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user