Package conduit :: Package datatypes :: Module Video
[hide private]

Source Code for Module conduit.datatypes.Video

 1  import conduit 
 2  import conduit.datatypes.File as File 
 3   
 4  #The preset encodings must be robust. That means, in the case of ffmpeg, 
 5  #you must be explicit with the options, otherwise it tries to retain sample 
 6  #rates between the input and output files, leading to invalid rates in the output 
 7  PRESET_ENCODINGS = { 
 8      "divx":{"vcodec":"mpeg4","acodec":"ac3","arate":44100,"abitrate":"64k","format":"avi","vtag":"DIVX","file_extension":"avi", "fps":15}, 
 9      #breaks on single channel audio files because ffmpeg vorbis encoder only suuport stereo 
10      "ogg":{"vcodec":"theora","acodec":"vorbis","format":"ogg","file_extension":"ogg"}, 
11      #needs mencoder or ffmpeg compiled with mp3 support 
12      "flv":{"arate":22050,"abitrate":32,"format":"flv","acodec":"mp3","mencoder":True,"file_extension":"flv"}    
13      } 
14   
15 -def mimetype_is_video(mimetype):
16 """ 17 @returns: True if the given mimetype string represents a video file 18 """ 19 if mimetype.startswith("video/"): 20 return True 21 elif mimetype == "application/ogg": 22 return True 23 else: 24 return False
25
26 -class Video(File.File):
27 28 _name_ = "file/video" 29
30 - def __init__(self, URI, **kwargs):
31 File.File.__init__(self, URI, **kwargs) 32 self._title = None 33 self._description = None
34
35 - def get_video_duration(self):
36 return None
37
38 - def get_video_size(self):
39 return None,None
40
41 - def get_description(self):
42 """ 43 @returns: the video's description 44 """ 45 return self._description
46
47 - def set_description(self, description):
48 self._description = description
49
50 - def __getstate__(self):
51 data = File.File.__getstate__(self) 52 data["description"] = self._description 53 return data
54
55 - def __setstate__(self, data):
56 self.pb = None 57 self._description = data["description"] 58 File.File.__setstate__(self, data)
59