Example #1
0
def processClips(clips, output_dir, resolution=None):
    duration = 0
    start = datetime.datetime.now()
    success = []
    for i, clip in enumerate(clips):
        output = os.path.join(output_dir, '{:05d}.mp4'.format(clip.id_))
        if os.path.exists(output):
            success.append(clip)
            continue
        fp = clip.moviefile.getActivePath()
        if not fp:
            print "Missing file for Clip", clip.id_
            continue
        input_ = fp.path
        mp = player.identify(fp)
        if not extract.extractClip(clip, output, resolution, mp, cleanup=False):
            continue
        #if not extract.testExtraction(output):
        #    continue
        duration += clip.duration
        print "Done with {} from Clip {} for {} seconds total ({})".format(
            i, clip.id_, duration, datetime.datetime.now() - start)
        success.append(clip)
    return success
Example #2
0
    logging.debug('filepaths: %s', len(filepaths))
    db.getSession().commit()
    logging.debug('%s files loaded', len(filepaths))

    all_filters = filters.applyArgs(ARGS, db.getSession())

    all_clips = []
    for filepath in movie.MovieInventory(filepaths, False, all_filters):
        for clip in filepath.pornfile._clips:
            if clip.active and clip.project_id == ARGS.project_id:
                all_clips.append(clip)

    for clip in all_clips:
        output = os.path.join(ARGS.output_dir, '{:06d}.mp4'.format(clip.id_))
        if os.path.exists(output):
            continue
        try:
            if resolution:
                mp = player.identify(clip.moviefile.getActivePath())
                extract.extractClip(clip, output, resolution, mp)
            else:
                extract.extractClip(clip, output)
        except KeyboardInterrupt:
            raise
        except:
            logging.exception('A bad thing happened on %s', clip.id_)
            continue
finally:
    script.standardCleanup()
    logging.info('****** End of Script *********')
    logging.debug('filepaths: %s', len(filepaths))
    db.getSession().commit()
    logging.debug('%s files loaded', len(filepaths))

    all_filters = filters.applyArgs(ARGS, db.getSession())

    all_clips = []
    for filepath in movie.MovieInventory(filepaths, False, all_filters):
        for clip in filepath.pornfile._clips:
            if clip.active and clip.project_id == ARGS.project_id:
                all_clips.append(clip)

    for clip in all_clips:
        output = os.path.join(ARGS.output_dir, '{:06d}.mp4'.format(clip.id_))
        if os.path.exists(output):
            continue
        try:
            if resolution:
                mp = player.identify(clip.moviefile.getActivePath())
                extract.extractClip(clip, output, resolution, mp)
            else:
                extract.extractClip(clip, output)
        except KeyboardInterrupt:
            raise
        except:
            logging.exception('A bad thing happened on %s', clip.id_)
            continue
finally:
    script.standardCleanup()
    logging.info('****** End of Script *********')