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