updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / thinliquidfilm / 0002-Fix-regular-expression-matching-of-ffmpeg-output.patch
blob98420cf0c94d3f7e263d2bf8eae63078627cd726
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).
9 ---
10 getFileInfo.py | 26 ++++++++++----------------
11 main.py | 4 +---
12 2 files changed, 11 insertions(+), 19 deletions(-)
14 diff --git a/getFileInfo.py b/getFileInfo.py
15 index 6456c19..bbbd18c 100644
16 --- a/getFileInfo.py
17 +++ b/getFileInfo.py
18 @@ -5,33 +5,27 @@ def getInfo(file):
19 try:
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)
22 - print output
23 - regexp = r'''(?isx)
24 - .*?Duration:\s(?P<hours>\d{2}):(?P<minutes>\d{2}):(?P<seconds>\d{2}.\d),\s
25 - '''
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'))
32 - regexp = r'''(?isx)
33 - .*?bitrate:\s(?P<bitrate>.*?)\s|$
34 - '''
36 + regexp = r'''(?isx).*?bitrate:\s(?P<bitrate>.*?)\s|$'''
37 match = re.search(regexp, output)
38 bitrate = match.group('bitrate')
39 - regexp = r'''(?isx)
40 - .*?Video:\s(?P<type>.*?),\s
41 - '''
43 + regexp = r'''(?isx).*?Video:\s(?P<type>.*?),\s'''
44 match = re.search(regexp, output)
45 type = match.group('type')
46 - regexp = r'''(?isx)
47 - .*?,\s(?P<width>\d*?)x(?P<height>\d*?),\s
48 - '''
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')
54 - regexp = r'''(?isx)
55 - .*?\s(?P<fps>\d{1,2}\.\d{1,2})\sfps
56 - '''
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
64 --- a/main.py
65 +++ b/main.py
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)
69 j = 0
70 - regexp = r'''(?isx)
71 - .*?frame=\s*?(?P<frames>\d*?)\sq=
72 - '''
73 + regexp = r'''(?isx).*?frame=\s*?(?P<frames>\d*?)\sfps='''
74 cancelled = 0
75 resultmessage = "The following files were successfully encoded:\n\n"
76 for i in range(len(self.encodeSettings)):
77 --
78 1.6.1