1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 from mediagoblin
import mg_globals
as mgg
21 ACCEPTED_RESOLUTIONS
= {
27 '1080p' : (1920, 1080),
30 _log
= logging
.getLogger(__name__
)
33 def skip_transcode(metadata
, size
):
35 Checks video metadata against configuration values for skip_transcode.
37 Returns True if the video matches the requirements in the configuration.
39 config
= mgg
.global_config
['plugins']['mediagoblin.media_types.video']\
42 # XXX: how were we supposed to use it?
43 medium_config
= mgg
.global_config
['media:medium']
45 _log
.debug('skip_transcode config: {0}'.format(config
))
47 metadata_tags
= metadata
.get_tags()
51 if config
['mime_types'] and metadata_tags
.get_string('mimetype')[0]:
52 if not metadata_tags
.get_string('mimetype')[1] in config
['mime_types']:
55 if (config
['container_formats'] and
56 metadata_tags
.get_string('container-format')[0]):
57 if not (metadata_tags
.get_string('container-format')[1] in
58 config
['container_formats']):
61 if config
['video_codecs']:
62 for video_info
in metadata
.get_video_streams():
63 video_tags
= video_info
.get_tags()
66 if not (video_tags
.get_string('video-codec')[1] in
67 config
['video_codecs']):
70 if config
['audio_codecs']:
71 for audio_info
in metadata
.get_audio_streams():
72 audio_tags
= audio_info
.get_tags()
75 if not (audio_tags
.get_string('audio-codec')[1] in
76 config
['audio_codecs']):
79 if config
['dimensions_match']:
80 for video_info
in metadata
.get_video_streams():
81 if not video_info
.get_height() <= size
[1]:
83 if not video_info
.get_width() <= size
[0]: