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 _log
= logging
.getLogger(__name__
)
24 def skip_transcode(metadata
):
26 Checks video metadata against configuration values for skip_transcode.
28 Returns True if the video matches the requirements in the configuration.
30 config
= mgg
.global_config
['media_type:mediagoblin.media_types.video']\
33 medium_config
= mgg
.global_config
['media:medium']
35 _log
.debug('skip_transcode config: {0}'.format(config
))
37 if config
['mime_types'] and metadata
.get('mimetype'):
38 if not metadata
['mimetype'] in config
['mime_types']:
41 if config
['container_formats'] and metadata
['tags'].get('audio-codec'):
42 if not metadata
['tags']['container-format'] in config
['container_formats']:
45 if config
['video_codecs'] and metadata
['tags'].get('audio-codec'):
46 if not metadata
['tags']['video-codec'] in config
['video_codecs']:
49 if config
['audio_codecs'] and metadata
['tags'].get('audio-codec'):
50 if not metadata
['tags']['audio-codec'] in config
['audio_codecs']:
53 if config
['dimensions_match']:
54 if not metadata
['videoheight'] <= medium_config
['max_height']:
56 if not metadata
['videowidth'] <= medium_config
['max_width']: