Fixes Issue #2 #4

Merged
dafo5502 merged 59 commits from developer into master 2021-10-25 14:41:37 +02:00
2 changed files with 41 additions and 6 deletions
Showing only changes of commit 1cdf3e6f67 - Show all commits

View File

@ -61,11 +61,19 @@ class Mediasite:
slides_path = os.join.path(base, 'slides') slides_path = os.join.path(base, 'slides')
os.mkdir(slides_path) os.mkdir(slides_path)
mypackage['slides'] = [] mypackage['slides'] = []
for slide in data['slides']: demux_file = os.join.path(slides_path, 'demux.txt')
myslide = { 'url': os.join.path(slides_path, self._download(slides_path, slide['url'], session)), with open(demux_file, 'w') as f:
'duration': slide['duration'] } for slide in data['slides']:
mypackage['slides'].append(myslide) 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 return mypackage
def _download(self, base, remotefile, session): def _download(self, base, remotefile, session):

View File

@ -1,6 +1,6 @@
import logging import logging
import multiprocessing as mp import multiprocessing as mp
import os import oset = True
import shutil import shutil
import time import time
@ -66,6 +66,15 @@ class Transcoder:
pending.append({'jobs': transcodes, pending.append({'jobs': transcodes,
'data': stream}) '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.close()
pool.join() pool.join()
self.logger.info("%s - Finished transcoding", package_id) self.logger.info("%s - Finished transcoding", package_id)
@ -148,3 +157,21 @@ class _Worker:
self.logger.info("%s - Transcoded %s in %s seconds", self.logger.info("%s - Transcoded %s in %s seconds",
package_id, outstream, runtime) package_id, outstream, runtime)
return outstream 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))