prosopopee: add ratio property for videos
To prepare for an alignment fix that requires to know the ratio of the video screenshot, let's add a ratio property. This property is calling `ffprobe` or `avprobe` depending on whether ffmpeg or libav-tools was installed. It is not adding a new dependency. The output of this particular `ffprobe` or `avprobe` returns the width and height of the video, separated by a comma. Signed-off-by: Quentin Schulz <foss@0leil.net>
This commit is contained in:
parent
8b4f645a65
commit
54f47ecd06
@ -140,6 +140,17 @@ class Video(object):
|
|||||||
|
|
||||||
return thumbnail_name
|
return thumbnail_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ratio(self):
|
||||||
|
if self.options["binary"] == "ffmpeg":
|
||||||
|
binary = "ffprobe"
|
||||||
|
else:
|
||||||
|
binary = "avprobe"
|
||||||
|
command = binary + " -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 " + self.base_dir.joinpath(self.name)
|
||||||
|
out = subprocess.check_output(command.split())
|
||||||
|
width,height = out.split(',')
|
||||||
|
return float(width) / int(height)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user