Support videos with rotation

This commit is contained in:
Alexey Bazhin
2016-07-12 15:13:47 +03:00
parent 6d10dfa851
commit a004ad85c5

View File

@@ -67,11 +67,15 @@ def video_size(source):
ret, stdout, stderr = call_subprocess(['ffmpeg', '-i', source])
pattern = re.compile(r'Stream.*Video.* ([0-9]+)x([0-9]+)')
match = pattern.search(stderr)
rot_pattern = re.compile(r'rotate\s*:\s*-?(90|270)')
rot_match = rot_pattern.search(stderr)
if match:
x, y = int(match.groups()[0]), int(match.groups()[1])
else:
x = y = 0
if rot_match:
x, y = y, x
return x, y