added basic file info getter (ffprobe must be in PATH)

This commit is contained in:
Jakub Trllo 2019-04-19 10:47:39 +02:00
parent 0a31e71bf4
commit 91b170f0ac

View file

@ -1,5 +1,6 @@
import os import os
import clique import clique
import subprocess
from pypeapp import config from pypeapp import config
from . import QtWidgets, QtCore from . import QtWidgets, QtCore
from . import DropEmpty, ComponentsList, ComponentItem from . import DropEmpty, ComponentsList, ComponentItem
@ -218,15 +219,42 @@ class DropDataFrame(QtWidgets.QFrame):
'files': files, 'files': files,
'name': file_base, 'name': file_base,
'ext': file_ext, 'ext': file_ext,
'file_info': file_info,
'representation': repr_name, 'representation': repr_name,
'folder_path': folder_path, 'folder_path': folder_path,
'is_sequence': False, 'is_sequence': False,
'actions': actions 'actions': actions
} }
data['file_info'] = self.get_file_info(data)
self._process_data(data) self._process_data(data)
def get_file_info(self, data):
output = None
if data['ext'] == '.mov':
try:
# ffProbe must be in PATH
filepath = data['files'][0]
args = ['ffprobe', '-show_streams', filepath]
p = subprocess.Popen(
args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True
)
datalines=[]
for line in iter(p.stdout.readline, b''):
line = line.decode("utf-8").replace('\r\n', '')
datalines.append(line)
find_value = 'codec_name'
for line in datalines:
if line.startswith(find_value):
output = line.replace(find_value + '=', '')
break
except Exception as e:
pass
return output
def _process_data(self, data): def _process_data(self, data):
ext = data['ext'] ext = data['ext']
icon = 'default' icon = 'default'