def extract_shots(thresh=0.2, duration=4, padding=0.5):
    shots = {}
    allshots = []

    for f in glob('videos/*.shots.json'):

        with open(f, 'r') as infile:
            data = json.load(infile)

        f = f.replace('.shots.json', '')

        _shots = [d['time'] for d in data if d['score'] > thresh]
        for i, d in enumerate(_shots):

            if i > 0:
                start = _shots[i - 1]
            else:
                start = 0
            end = d

            start += padding
            end -= padding
            end = min(end, start + duration - padding)

            if end - start < 1:
                continue

            print(start, end)

            outname = 'shots/{}_{}_{}.mp4'.format(f.replace('videos/', ''),
                                                  start, end)
            if os.path.exists(outname):
                continue

            clip = Clip(f, start=start, end=end)
            clip.zoompan([0, 0, '100%', '100%'],
                         ['-25%', '-25%', '150%', '150%'], 0, 100)
            clip.save(outname)
Exemplo n.º 2
0
from vidpy import Composition, Clip

url = 'http://webcam.gordon.edu/mjpg/video.mjpg'
clip = Clip(url)
clip.spin(2)

clip.set_duration(10)
clip.save('live_spin.mp4')