Fixes Issue #2 #4
@ -62,7 +62,7 @@ class Mediasite:
|
||||
if 'slides' in data:
|
||||
slides_path = os.path.join(base, 'slides')
|
||||
os.mkdir(slides_path)
|
||||
mypackage['slides'] = []
|
||||
slides = []
|
||||
demux_file = os.path.join(slides_path, 'demux.txt')
|
||||
with open(demux_file, 'w') as f:
|
||||
for slide in data['slides']:
|
||||
@ -70,11 +70,13 @@ class Mediasite:
|
||||
'duration': '{}ms'.format(slide['duration'])}
|
||||
f.write('file \'{}\'\n'.format(myslide['url']))
|
||||
f.write('duration {}ms\n'.format(slide['duration']))
|
||||
mypackage['slides'].append(myslide)
|
||||
slides.append(myslide)
|
||||
|
||||
# to accomodate for an ffmpeg quirk that needs the last slide twice
|
||||
f.write('file \'{}\'\n'.format(mypackage['slides'][-1]['url']))
|
||||
mypackage['demux_file'] = demux_file
|
||||
f.write('file \'{}\'\n'.format(slides[-1]['url']))
|
||||
mypackage['sources'].append({ 'demux_file': demux_file,
|
||||
'poster': slides[0]['url'],
|
||||
'playAudio': "false" })
|
||||
return mypackage
|
||||
|
||||
def _download(self, base, remotefile, session):
|
||||
|
@ -3,7 +3,6 @@ import multiprocessing as mp
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
#from typing_extensions import runtime
|
||||
|
||||
import ffmpeg
|
||||
|
||||
@ -34,26 +33,38 @@ class Transcoder:
|
||||
self.logger.debug("%s - Pool created", package_id)
|
||||
for stream in package['sources']:
|
||||
transcodes = {}
|
||||
streampath_rel = stream['video']
|
||||
streampath_abs = os.path.join(base, streampath_rel)
|
||||
self.logger.debug("%s - Processing stream %s",
|
||||
package_id,
|
||||
streampath_rel)
|
||||
if 'demux_file' in stream:
|
||||
self.logger.debug("%s - Processing stream %s", package_id, 'slides job in demux.txt')
|
||||
for maxheight in self.variants:
|
||||
crf, preset = self.variants[maxheight]
|
||||
videojob = pool.apply_async(_Worker.transcode,
|
||||
transcodes[maxheight] = pool.apply_async(_Worker.make_slides_video,
|
||||
(self.worker,
|
||||
package_id,
|
||||
stream['demux_file'],
|
||||
workbase,
|
||||
maxheight, preset, crf))
|
||||
_, ext = os.path.splitext(stream['poster'])
|
||||
slides_thumb = 'slides_thumb{}'.format(ext)
|
||||
shutil.copy2(stream['poster'],os.path.join(workbase, slides_thumb))
|
||||
stream['poster'] = slides_thumb
|
||||
|
||||
elif 'video' in stream:
|
||||
streampath_rel = stream['video']
|
||||
streampath_abs = os.path.join(base, streampath_rel)
|
||||
self.logger.debug("%s - Processing stream %s", package_id, streampath_rel)
|
||||
for maxheight in self.variants:
|
||||
crf, preset = self.variants[maxheight]
|
||||
transcodes[maxheight] = pool.apply_async(_Worker.transcode,
|
||||
(self.worker,
|
||||
package_id,
|
||||
streampath_abs,
|
||||
workbase,
|
||||
maxheight, preset, crf))
|
||||
transcodes[maxheight] = videojob
|
||||
|
||||
thumbpath_rel = stream['poster']
|
||||
if thumbpath_rel:
|
||||
_, ext = os.path.splitext(thumbpath_rel)
|
||||
thumbbase, _ = os.path.splitext(
|
||||
os.path.basename(streampath_abs))
|
||||
thumbbase, _ = os.path.splitext(os.path.basename(streampath_abs))
|
||||
thumbname = '{}{}'.format(thumbbase, ext)
|
||||
shutil.copy2(os.path.join(base, thumbpath_rel),
|
||||
os.path.join(workbase, thumbname))
|
||||
@ -65,21 +76,8 @@ class Transcoder:
|
||||
workbase))
|
||||
transcodes['poster'] = thumbjob
|
||||
|
||||
obj = {'jobs': transcodes,
|
||||
'data': stream}
|
||||
if 'slides' in package:
|
||||
slides = {}
|
||||
for maxheight in self.variants:
|
||||
crf, preset = self.variants[maxheight]
|
||||
slides[maxheight] = pool.apply_async(_Worker.make_slides_video,
|
||||
(self.worker,
|
||||
package_id,
|
||||
package['demux_file'],
|
||||
workbase,
|
||||
maxheight, preset, crf))
|
||||
|
||||
obj['slides'] = slides
|
||||
pending.append(obj)
|
||||
pending.append({'jobs': transcodes,
|
||||
'data': stream})
|
||||
|
||||
pool.close()
|
||||
pool.join()
|
||||
@ -89,16 +87,10 @@ class Transcoder:
|
||||
for item in pending:
|
||||
stream = item['data']
|
||||
jobs = item['jobs']
|
||||
slide_jobs = item.get('slides')
|
||||
streams = {}
|
||||
slides = {}
|
||||
for maxheight in self.variants:
|
||||
streams[maxheight] = jobs[maxheight].get()
|
||||
if slide_jobs is not None:
|
||||
slides[maxheight] = slide_jobs[maxheight].get()
|
||||
stream['video'] = streams
|
||||
if slide_jobs is not None:
|
||||
stream['slides'] = slides
|
||||
if 'poster' in jobs:
|
||||
stream['poster'] = jobs['poster'].get()
|
||||
if not package['thumb'] and stream['playAudio']:
|
||||
|
Loading…
x
Reference in New Issue
Block a user