mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-18 12:00:21 +01:00
added EXIF patch and misc in lib
removed some cruft
This commit is contained in:
@@ -251,40 +251,54 @@ EXIF_TAGS = {
|
||||
2: 'CenterWeightedAverage',
|
||||
3: 'Spot',
|
||||
4: 'MultiSpot',
|
||||
5: 'Pattern'}),
|
||||
5: 'Pattern',
|
||||
6: 'Partial',
|
||||
255: 'other'}),
|
||||
0x9208: ('LightSource',
|
||||
{0: 'Unknown',
|
||||
1: 'Daylight',
|
||||
2: 'Fluorescent',
|
||||
3: 'Tungsten',
|
||||
9: 'Fine Weather',
|
||||
10: 'Flash',
|
||||
3: 'Tungsten (incandescent light)',
|
||||
4: 'Flash',
|
||||
9: 'Fine weather',
|
||||
10: 'Cloudy weather',
|
||||
11: 'Shade',
|
||||
12: 'Daylight Fluorescent',
|
||||
13: 'Day White Fluorescent',
|
||||
14: 'Cool White Fluorescent',
|
||||
15: 'White Fluorescent',
|
||||
17: 'Standard Light A',
|
||||
18: 'Standard Light B',
|
||||
19: 'Standard Light C',
|
||||
12: 'Daylight fluorescent (D 5700 - 7100K)',
|
||||
13: 'Day white fluorescent (N 4600 - 5400K)',
|
||||
14: 'Cool white fluorescent (W 3900 - 4500K)',
|
||||
15: 'White fluorescent (WW 3200 - 3700K)',
|
||||
17: 'Standard light A',
|
||||
18: 'Standard light B',
|
||||
19: 'Standard light C',
|
||||
20: 'D55',
|
||||
21: 'D65',
|
||||
22: 'D75',
|
||||
255: 'Other'}),
|
||||
23: 'D50',
|
||||
24: 'ISO studio tungsten',
|
||||
255: 'other light source',}),
|
||||
0x9209: ('Flash',
|
||||
{0: 'No',
|
||||
1: 'Fired',
|
||||
5: 'Fired (?)', # no return sensed
|
||||
7: 'Fired (!)', # return sensed
|
||||
9: 'Fill Fired',
|
||||
13: 'Fill Fired (?)',
|
||||
15: 'Fill Fired (!)',
|
||||
16: 'Off',
|
||||
24: 'Auto Off',
|
||||
25: 'Auto Fired',
|
||||
29: 'Auto Fired (?)',
|
||||
31: 'Auto Fired (!)',
|
||||
32: 'Not Available'}),
|
||||
{0: 'Flash did not fire',
|
||||
1: 'Flash fired',
|
||||
5: 'Strobe return light not detected',
|
||||
7: 'Strobe return light detected',
|
||||
9: 'Flash fired, compulsory flash mode',
|
||||
13: 'Flash fired, compulsory flash mode, return light not detected',
|
||||
15: 'Flash fired, compulsory flash mode, return light detected',
|
||||
16: 'Flash did not fire, compulsory flash mode',
|
||||
24: 'Flash did not fire, auto mode',
|
||||
25: 'Flash fired, auto mode',
|
||||
29: 'Flash fired, auto mode, return light not detected',
|
||||
31: 'Flash fired, auto mode, return light detected',
|
||||
32: 'No flash function',
|
||||
65: 'Flash fired, red-eye reduction mode',
|
||||
69: 'Flash fired, red-eye reduction mode, return light not detected',
|
||||
71: 'Flash fired, red-eye reduction mode, return light detected',
|
||||
73: 'Flash fired, compulsory flash mode, red-eye reduction mode',
|
||||
77: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected',
|
||||
79: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected',
|
||||
89: 'Flash fired, auto mode, red-eye reduction mode',
|
||||
93: 'Flash fired, auto mode, return light not detected, red-eye reduction mode',
|
||||
95: 'Flash fired, auto mode, return light detected, red-eye reduction mode'}),
|
||||
0x920A: ('FocalLength', ),
|
||||
0x9214: ('SubjectArea', ),
|
||||
0x927C: ('MakerNote', ),
|
||||
|
||||
83
src/lib/EXIF_light_source_and_flash.patch
Normal file
83
src/lib/EXIF_light_source_and_flash.patch
Normal file
@@ -0,0 +1,83 @@
|
||||
diff -au EXIF.py EXIF_mine.py
|
||||
--- EXIF.py 2008-07-31 15:53:50.000000000 +0200
|
||||
+++ EXIF_mine.py 2009-02-25 18:39:48.000000000 +0100
|
||||
@@ -251,40 +251,54 @@
|
||||
2: 'CenterWeightedAverage',
|
||||
3: 'Spot',
|
||||
4: 'MultiSpot',
|
||||
- 5: 'Pattern'}),
|
||||
+ 5: 'Pattern',
|
||||
+ 6: 'Partial',
|
||||
+ 255: 'other'}),
|
||||
0x9208: ('LightSource',
|
||||
{0: 'Unknown',
|
||||
1: 'Daylight',
|
||||
2: 'Fluorescent',
|
||||
- 3: 'Tungsten',
|
||||
- 9: 'Fine Weather',
|
||||
- 10: 'Flash',
|
||||
+ 3: 'Tungsten (incandescent light)',
|
||||
+ 4: 'Flash',
|
||||
+ 9: 'Fine weather',
|
||||
+ 10: 'Cloudy weather',
|
||||
11: 'Shade',
|
||||
- 12: 'Daylight Fluorescent',
|
||||
- 13: 'Day White Fluorescent',
|
||||
- 14: 'Cool White Fluorescent',
|
||||
- 15: 'White Fluorescent',
|
||||
- 17: 'Standard Light A',
|
||||
- 18: 'Standard Light B',
|
||||
- 19: 'Standard Light C',
|
||||
+ 12: 'Daylight fluorescent (D 5700 - 7100K)',
|
||||
+ 13: 'Day white fluorescent (N 4600 - 5400K)',
|
||||
+ 14: 'Cool white fluorescent (W 3900 - 4500K)',
|
||||
+ 15: 'White fluorescent (WW 3200 - 3700K)',
|
||||
+ 17: 'Standard light A',
|
||||
+ 18: 'Standard light B',
|
||||
+ 19: 'Standard light C',
|
||||
20: 'D55',
|
||||
21: 'D65',
|
||||
22: 'D75',
|
||||
- 255: 'Other'}),
|
||||
+ 23: 'D50',
|
||||
+ 24: 'ISO studio tungsten',
|
||||
+ 255: 'other light source',}),
|
||||
0x9209: ('Flash',
|
||||
- {0: 'No',
|
||||
- 1: 'Fired',
|
||||
- 5: 'Fired (?)', # no return sensed
|
||||
- 7: 'Fired (!)', # return sensed
|
||||
- 9: 'Fill Fired',
|
||||
- 13: 'Fill Fired (?)',
|
||||
- 15: 'Fill Fired (!)',
|
||||
- 16: 'Off',
|
||||
- 24: 'Auto Off',
|
||||
- 25: 'Auto Fired',
|
||||
- 29: 'Auto Fired (?)',
|
||||
- 31: 'Auto Fired (!)',
|
||||
- 32: 'Not Available'}),
|
||||
+ {0: 'Flash did not fire',
|
||||
+ 1: 'Flash fired',
|
||||
+ 5: 'Strobe return light not detected',
|
||||
+ 7: 'Strobe return light detected',
|
||||
+ 9: 'Flash fired, compulsory flash mode',
|
||||
+ 13: 'Flash fired, compulsory flash mode, return light not detected',
|
||||
+ 15: 'Flash fired, compulsory flash mode, return light detected',
|
||||
+ 16: 'Flash did not fire, compulsory flash mode',
|
||||
+ 24: 'Flash did not fire, auto mode',
|
||||
+ 25: 'Flash fired, auto mode',
|
||||
+ 29: 'Flash fired, auto mode, return light not detected',
|
||||
+ 31: 'Flash fired, auto mode, return light detected',
|
||||
+ 32: 'No flash function',
|
||||
+ 65: 'Flash fired, red-eye reduction mode',
|
||||
+ 69: 'Flash fired, red-eye reduction mode, return light not detected',
|
||||
+ 71: 'Flash fired, red-eye reduction mode, return light detected',
|
||||
+ 73: 'Flash fired, compulsory flash mode, red-eye reduction mode',
|
||||
+ 77: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected',
|
||||
+ 79: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected',
|
||||
+ 89: 'Flash fired, auto mode, red-eye reduction mode',
|
||||
+ 93: 'Flash fired, auto mode, return light not detected, red-eye reduction mode',
|
||||
+ 95: 'Flash fired, auto mode, return light detected, red-eye reduction mode'}),
|
||||
0x920A: ('FocalLength', ),
|
||||
0x9214: ('SubjectArea', ),
|
||||
0x927C: ('MakerNote', ),
|
||||
@@ -1,61 +0,0 @@
|
||||
"""
|
||||
Project: pyGTKtalog
|
||||
Description: Gather video file information. Uses external tools.
|
||||
Type: lib
|
||||
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
||||
Created: 2008-12-15
|
||||
"""
|
||||
from os import popen
|
||||
import sys
|
||||
|
||||
class Midentify(object):
|
||||
"""Class for retrive midentify script output and put it in dict.
|
||||
Usually there is no need for such a detailed movie/clip information.
|
||||
Midentify script belongs to mplayer package.
|
||||
"""
|
||||
|
||||
def __init__(self, filename):
|
||||
"""Init class instance. Filename of a video file is required."""
|
||||
self.filename = filename
|
||||
self.tags = {}
|
||||
|
||||
def get_data(self):
|
||||
"""return dict with clip information"""
|
||||
output = popen('midentify "%s"' % self.filename).readlines()
|
||||
|
||||
attrs = {'ID_VIDEO_WIDTH': ['width', int],
|
||||
'ID_VIDEO_HEIGHT': ['height', int],
|
||||
'ID_LENGTH': ['length', lambda x: int(x.split(".")[0])],
|
||||
# length is in seconds
|
||||
'ID_DEMUXER': ['container', str],
|
||||
'ID_VIDEO_FORMAT': ['video_format', str],
|
||||
'ID_VIDEO_CODEC': ['video_codec', str],
|
||||
'ID_AUDIO_CODEC': ['audio_codec', str],
|
||||
'ID_AUDIO_FORMAT': ['audio_format', str],
|
||||
'ID_AUDIO_NCH': ['audio_no_channels', int],}
|
||||
|
||||
for line in output:
|
||||
line = line.strip()
|
||||
for attr in attrs:
|
||||
if attr in line:
|
||||
self.tags[attrs[attr][0]] = \
|
||||
attrs[attr][1](line.replace("%s=" % attr, ""))
|
||||
|
||||
if 'length' in self.tags:
|
||||
if self.tags['length'] > 0:
|
||||
hours = self.tags['length'] / 3600
|
||||
seconds = self.tags['length'] - hours * 3600
|
||||
minutes = seconds / 60
|
||||
seconds -= minutes * 60
|
||||
length_str = "%02d:%02d:%02d" % (hours, minutes, seconds)
|
||||
self.tags['duration'] = length_str
|
||||
return self.tags
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print "usage: %s filename" % sys.argv[0]
|
||||
sys.exit()
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
mid = Midentify(arg)
|
||||
print mid.get_data()
|
||||
22
src/lib/misc.py
Normal file
22
src/lib/misc.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
Project: pyGTKtalog
|
||||
Description: Misc functions used more than once in src
|
||||
Type: lib
|
||||
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
||||
Created: 2008-12-15
|
||||
"""
|
||||
|
||||
def float_to_string(float_length):
|
||||
"""
|
||||
Parse float digit into time string
|
||||
Arguments:
|
||||
@string - width of generated image. If actual image width
|
||||
exceeds this number scale is performed.
|
||||
Returns HH:MM:SS formatted string
|
||||
"""
|
||||
hour = int(float_length / 3600);
|
||||
float_length -= hour*3600
|
||||
minutes = int(float_length / 60)
|
||||
float_length -= minutes * 60
|
||||
sec = int(float_length)
|
||||
return "%02d:%02d:%02d" % (hour, minutes, sec)
|
||||
@@ -1,99 +0,0 @@
|
||||
"""
|
||||
Project: pyGTKtalog
|
||||
Description: Tests for Midentify class.
|
||||
Type: test
|
||||
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
||||
Created: 2008-12-15
|
||||
"""
|
||||
import unittest
|
||||
from lib.midentify import Midentify
|
||||
|
||||
class TestMidentify(unittest.TestCase):
|
||||
"""Class for retrive midentify script output and put it in dict.
|
||||
Usually there is no need for such a detailed movie/clip information.
|
||||
Midentify script belongs to mplayer package.
|
||||
"""
|
||||
|
||||
def test_avi(self):
|
||||
"""test mock avi file, should return dict with expected values"""
|
||||
avi = Midentify("mocks/m.avi")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(result_dict['audio_format'], '85')
|
||||
self.assertEqual(result_dict['width'], 128)
|
||||
self.assertEqual(result_dict['audio_no_channels'], 2)
|
||||
self.assertEqual(result_dict['height'], 96)
|
||||
self.assertEqual(result_dict['video_format'], 'XVID')
|
||||
self.assertEqual(result_dict['length'], 4)
|
||||
self.assertEqual(result_dict['audio_codec'], 'mp3')
|
||||
self.assertEqual(result_dict['video_codec'], 'ffodivx')
|
||||
self.assertEqual(result_dict['duration'], '00:00:04')
|
||||
self.assertEqual(result_dict['container'], 'avi')
|
||||
|
||||
def test_avi2(self):
|
||||
"""test another mock avi file, should return dict with expected
|
||||
values"""
|
||||
avi = Midentify("mocks/m1.avi")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(result_dict['audio_format'], '85')
|
||||
self.assertEqual(result_dict['width'], 128)
|
||||
self.assertEqual(result_dict['audio_no_channels'], 2)
|
||||
self.assertEqual(result_dict['height'], 96)
|
||||
self.assertEqual(result_dict['video_format'], 'H264')
|
||||
self.assertEqual(result_dict['length'], 4)
|
||||
self.assertEqual(result_dict['audio_codec'], 'mp3')
|
||||
self.assertEqual(result_dict['video_codec'], 'ffh264')
|
||||
self.assertEqual(result_dict['duration'], '00:00:04')
|
||||
self.assertEqual(result_dict['container'], 'avi')
|
||||
|
||||
def test_mkv(self):
|
||||
"""test mock mkv file, should return dict with expected values"""
|
||||
avi = Midentify("mocks/m.mkv")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(result_dict['audio_format'], '8192')
|
||||
self.assertEqual(result_dict['width'], 128)
|
||||
self.assertEqual(result_dict['audio_no_channels'], 2)
|
||||
self.assertEqual(result_dict['height'], 96)
|
||||
self.assertEqual(result_dict['video_format'], 'mp4v')
|
||||
self.assertEqual(result_dict['length'], 4)
|
||||
self.assertEqual(result_dict['audio_codec'], 'a52')
|
||||
self.assertEqual(result_dict['video_codec'], 'ffodivx')
|
||||
self.assertEqual(result_dict['duration'], '00:00:04')
|
||||
self.assertEqual(result_dict['container'], 'mkv')
|
||||
|
||||
def test_mpg(self):
|
||||
"""test mock mpg file, should return dict with expected values"""
|
||||
avi = Midentify("mocks/m.mpg")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertFalse(result_dict.has_key('audio_format'))
|
||||
self.assertEqual(result_dict['width'], 128)
|
||||
self.assertFalse(result_dict.has_key('audio_no_channels'))
|
||||
self.assertEqual(result_dict['height'], 96)
|
||||
self.assertEqual(result_dict['video_format'], '0x10000001')
|
||||
self.assertFalse(result_dict.has_key('lenght'))
|
||||
self.assertFalse(result_dict.has_key('audio_codec'))
|
||||
self.assertEqual(result_dict['video_codec'], 'ffmpeg1')
|
||||
self.assertFalse(result_dict.has_key('duration'))
|
||||
self.assertEqual(result_dict['container'], 'mpeges')
|
||||
|
||||
def test_ogm(self):
|
||||
"""test mock ogm file, should return dict with expected values"""
|
||||
avi = Midentify("mocks/m.ogm")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(result_dict['audio_format'], '8192')
|
||||
self.assertEqual(result_dict['width'], 160)
|
||||
self.assertEqual(result_dict['audio_no_channels'], 2)
|
||||
self.assertEqual(result_dict['height'], 120)
|
||||
self.assertEqual(result_dict['video_format'], 'H264')
|
||||
self.assertEqual(result_dict['length'], 4)
|
||||
self.assertEqual(result_dict['audio_codec'], 'a52')
|
||||
self.assertEqual(result_dict['video_codec'], 'ffh264')
|
||||
self.assertEqual(result_dict['duration'], '00:00:04')
|
||||
self.assertEqual(result_dict['container'], 'ogg')
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user