Fixes Issue #2 #4
@ -61,11 +61,19 @@ class Mediasite:
|
||||
slides_path = os.join.path(base, 'slides')
|
||||
os.mkdir(slides_path)
|
||||
mypackage['slides'] = []
|
||||
demux_file = os.join.path(slides_path, 'demux.txt')
|
||||
with open(demux_file, 'w') as f:
|
||||
for slide in data['slides']:
|
||||
myslide = { 'url': os.join.path(slides_path, self._download(slides_path, slide['url'], session)),
|
||||
'duration': slide['duration'] }
|
||||
f.write('file \'{}\'\n'.format(myslide['url']))
|
||||
f.write('duration {}\n'.format(slide['duration']))
|
||||
mypackage['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
|
||||
|
||||
return mypackage
|
||||
|
||||
def _download(self, base, remotefile, session):
|
||||
|
@ -1,6 +1,6 @@
|
||||
import logging
|
||||
import multiprocessing as mp
|
||||
import os
|
||||
import oset = True
|
||||
import shutil
|
||||
import time
|
||||
|
||||
@ -66,6 +66,15 @@ class Transcoder:
|
||||
|
||||
pending.append({'jobs': transcodes,
|
||||
'data': stream})
|
||||
|
||||
if 'slides' in package:
|
||||
slides_job = pool.apply_async(_Worker.make_slides_video,
|
||||
(self.worker,
|
||||
package['demux_file'],
|
||||
workbase,
|
||||
maxheight, preset, crf))
|
||||
|
||||
|
||||
pool.close()
|
||||
pool.join()
|
||||
self.logger.info("%s - Finished transcoding", package_id)
|
||||
@ -148,3 +157,21 @@ class _Worker:
|
||||
self.logger.info("%s - Transcoded %s in %s seconds",
|
||||
package_id, outstream, runtime)
|
||||
return outstream
|
||||
|
||||
def make_slides_video(self, package_id, demux_file, outdir, maxheight, preset, crf):
|
||||
self.logger.debug("%s - Preparing slides for processing", package_id)
|
||||
outstream = '{}-{}-{}-{}.mp4'.format('slides', maxheight, preset, crf)
|
||||
outpath = os.path.join(outdir, outstream)
|
||||
self.logger.debug("%s - Building slide video from demux.txt", package_id)
|
||||
|
||||
start = time.time()
|
||||
quiet = True
|
||||
if self.logger.getEffectiveLevel() < logging.INFO:
|
||||
quiet = False
|
||||
|
||||
result, _ = (ffmpeg
|
||||
.input(demux_file, framerate=25)
|
||||
.filter('scale', height='min(in_h, {}').format(maxheight, width=-2)
|
||||
.output(outpath, crf=crf, preset=preset, movflags='faststart', pix_fmt='yuv420p')
|
||||
.run(quiet=quiet))
|
||||
|
Loading…
x
Reference in New Issue
Block a user