forked from benjamin-weiss/hsrmbeamertheme
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmake_video_preview.py
executable file
·32 lines (27 loc) · 995 Bytes
/
make_video_preview.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env python
import sys
import re
from subprocess import call
if len(sys.argv) < 2:
print("Usage: %s <presentation.tex>" % sys.argv[0])
sys.exit(1)
onlylist = False
if "--list" in sys.argv:
onlylist = True
video = re.compile('.*video.*{(?P<file>.*\..*?)(\?.*?(start=(?P<starttime>\d*).*)?)?}')
with open(sys.argv[1],'r') as tex:
for line in tex.readlines():
found = video.search(line)
if found:
if onlylist:
print(found.group('file'))
continue
starttime = found.group('starttime')
if starttime:
starttime = int(starttime)
else:
starttime = 0
cmd = "ffmpeg -y -i " + found.group('file') + " -r 1 -vframes 1 -ss " + str(starttime) + " " + found.group('file').split('.')[0] + "_thumb.jpg"
print("%s starting at %d" % (found.group('file'), starttime))
print("> " + cmd)
call(cmd, shell=True)