1 From d35a10dee269f7a780ec9560e9820f78d0968c0c Mon Sep 17 00:00:00 2001
2 From: Gergely Imreh <imrehg@gmail.com>
3 Date: Wed, 7 Jan 2009 13:45:20 +0800
4 Subject: [PATCH 2/2] Fix: regular expression matching of ffmpeg output
6 The regular expressions were borked, not sure if due to python or ffmpeg
7 changes (since last version of TLF). Nevertheless, they were working for me
8 at the moment with ffmpeg Arch Linux compile, 2008-Jul-20 (unknown version).
10 getFileInfo.py | 26 ++++++++++----------------
12 2 files changed, 11 insertions(+), 19 deletions(-)
14 diff --git a/getFileInfo.py b/getFileInfo.py
15 index 6456c19..bbbd18c 100644
18 @@ -5,33 +5,27 @@ def getInfo(file):
20 cmd = ('ffmpeg -i "%s" -vframes 10 -vcodec mpeg4 -r 29.970030 -b 768k -ar 24000 -ab 128k -s 320x180 -f avi - > /dev/null' %(file))
21 output = commands.getoutput(cmd)
24 - .*?Duration:\s(?P<hours>\d{2}):(?P<minutes>\d{2}):(?P<seconds>\d{2}.\d),\s
27 + regexp = r'''(?isx).*?Duration:\s(?P<hours>\d{2}):(?P<minutes>\d{2}):(?P<seconds>\d{2}.\d)'''
28 match = re.search(regexp, output)
29 hours = int(match.group('hours'))
30 minutes = int(match.group('minutes'))
31 seconds = float(match.group('seconds'))
33 - .*?bitrate:\s(?P<bitrate>.*?)\s|$
36 + regexp = r'''(?isx).*?bitrate:\s(?P<bitrate>.*?)\s|$'''
37 match = re.search(regexp, output)
38 bitrate = match.group('bitrate')
40 - .*?Video:\s(?P<type>.*?),\s
43 + regexp = r'''(?isx).*?Video:\s(?P<type>.*?),\s'''
44 match = re.search(regexp, output)
45 type = match.group('type')
47 - .*?,\s(?P<width>\d*?)x(?P<height>\d*?),\s
50 + regexp = r'''(?isx).*?,\s(?P<width>\d*?)x(?P<height>\d*?)\s'''
51 match = re.search(regexp, output)
52 aspect = str(float(match.group('width'))/float(match.group('height')))[:6]
53 size = match.group('width') + 'x' + match.group('height')
55 - .*?\s(?P<fps>\d{1,2}\.\d{1,2})\sfps
58 + regexp = r'''(?isx).*?\s(?P<fps>\d{1,2}\.\d{1,2})\stb'''
59 match = re.search(regexp, output)
60 fps = float(match.group('fps'))
61 length = int((hours*3600 + minutes*60 + seconds)*1000)
62 diff --git a/main.py b/main.py
63 index 6bfed9c..b927788 100644
66 @@ -2677,9 +2677,7 @@ class main(QDialog):
67 total_frames += frames_count
68 self.prog_dialog = QProgressDialog("Encoding ...", "Cancel Encoding", total_frames, self, "progress", True)
71 - .*?frame=\s*?(?P<frames>\d*?)\sq=
73 + regexp = r'''(?isx).*?frame=\s*?(?P<frames>\d*?)\sfps='''
75 resultmessage = "The following files were successfully encoded:\n\n"
76 for i in range(len(self.encodeSettings)):