Permalink
Browse files

Merge branch 'feature/video' of github.com:nmfm/django-filer into fea…

…ture/video
  • Loading branch information...
2 parents 6713abe + 2ca2018 commit e34f9f398fb72ede534a854019f05eab104f993d @nmfm committed Nov 2, 2011
View
@@ -17,16 +17,16 @@ class VideoAdmin(FileAdmin):
FileAdmin.fieldsets[0],
(_('Advanced'), {
'fields': ('default_alt_text', 'default_caption',
- 'author', 'file', 'sha1',),
- 'classes': ('collapse',),
+ 'author', 'file', 'sha1', ),
+ 'classes': ('collapse', ),
}),
(_('Conversion'), {
- 'fields': ('conversion_status', 'height','width',
- 'conversion_output',),
- 'classes': ('collapse',),
+ 'fields': ('conversion_status', 'height', 'width',
+ 'conversion_output', ),
+ 'classes': ('collapse', ),
})
)
-
+
def render_change_form(self, request, context, *args, **kwargs):
video = Video.objects.get(pk=context['object_id'])
context['adminform'].form.fields['width'].help_text = _('Uploaded video width %s px') % video.original_width
View
@@ -14,4 +14,4 @@ class AdminVideoFormField(AdminFileFormField):
class FilerVideoField(FilerFileField):
default_form_class = AdminVideoFormField
- default_model_class = Video
+ default_model_class = Video
@@ -3,6 +3,7 @@
from filer.models.videomodels import Video
from filer.utils.video import format_to_original_filename
+
class Command(NoArgsCommand):
help = "Deletes video formats that no longer have an original file."
requires_model_validation = False
@@ -61,8 +61,8 @@ def set_initial_dimensions(self):
def save(self, *args, **kwargs):
self.has_all_mandatory_data = self._check_validity()
- if not ( self.original_width or self.original_height or \
- self.width or self.height ):
+ if not (self.original_width or self.original_height or \
+ self.width or self.height):
self.set_initial_dimensions()
super(Video, self).save(*args, **kwargs)
@@ -78,7 +78,7 @@ def formats(self):
try:
url = self.file.get_format_url(ext)
filepath = self.file.get_format_filepath(ext)
- _formats.append({'url': url, 'format':ext, 'filepath':filepath})
+ _formats.append({'url': url, 'format': ext, 'filepath': filepath})
except Exception, e:
pass
return _formats
@@ -91,10 +91,10 @@ def original_format(self):
return {'url': url, 'format': fmt, 'mimetype': mimetype}
def formats_html5(self):
- """
- Subset of video formats to use with HTML5 browsers
"""
- HTML5_FORMATS = {'mp4': 'video/mp4', 'ogv':'video/ogg', 'webm': 'video/webm'}
+ Subset of video formats to use with HTML5 browsers
+ """
+ HTML5_FORMATS = {'mp4': 'video/mp4', 'ogv': 'video/ogg', 'webm': 'video/webm'}
_formats = []
for entry in self.formats:
fmt = entry['format']
@@ -103,8 +103,8 @@ def formats_html5(self):
return _formats
def format_flash(self):
- """
- Returns the flash video file if available
+ """
+ Returns the flash video file if available
"""
for entry in self.formats:
if entry['format'] == 'flv':
@@ -120,13 +120,13 @@ def poster(self):
ext = 'png'
url = self.file.get_format_url(ext)
filepath = self.file.get_format_filepath(ext)
- return {'url': url, 'format':ext, 'filepath':filepath}
+ return {'url': url, 'format': ext, 'filepath': filepath}
except Exception, e:
- return {'url': '', 'format':ext, 'filepath':''}
+ return {'url': '', 'format': ext, 'filepath': ''}
def convert(self):
"""
- Conversion of video file to alternative formats and capture of
+ Conversion of video file to alternative formats and capture of
poster image file
"""
original_path = self.file.storage.path(self.file.name)
@@ -169,7 +169,7 @@ def _move_file(self):
dst_storage = self.file.storages['private']
src_fmt_storage = self.file.format_storages['public']
dst_fmt_storage = self.file.format_storages['private']
-
+
# delete the thumbnail
# We are toggling the is_public to make sure that easy_thumbnails can
# delete the thumbnails
@@ -229,4 +229,4 @@ def _copy_file(self, destination, overwrite=False):
fmt_storage.save(dst_fmt_name, ContentFile(src_file.read()))
src_file.close()
- return newfile
+ return newfile
View
@@ -124,7 +124,7 @@
#maintain original video dimensions
FFMPEG_TARGET_DIMENSIONS = ""
#always change to given dimensions; use <width>x<height> format
-#FFMPEG_TARGET_DIMENSIONS = "640x480"
+#FFMPEG_TARGET_DIMENSIONS = "640x480"
# argument for setting the size in ffmpeg
FFMPEG_SIZE_ARGUMENT = "-s %(dimensions)s"
# command line for grabbing preview image from video
@@ -10,18 +10,18 @@
def filer_video(source, video_dimensions=None):
"""
- Creates HTML5 video tag with the alternative video formats and fallback to
+ Creates HTML5 video tag with the alternative video formats and fallback to
flash if that format is available.
-
+
Tag Syntax
-
+
{% filer_video [source] [dimensions] %}
-
+
*source* must be a Django Filer video object
-
- *dimensions* is the display width and height and can be a string with
- ``[width]x[height]`` (for example ``{% filer_video obj 320x240 %}``) or
- a tuple variable with two integers. If no display dimensions are given
+
+ *dimensions* is the display width and height and can be a string with
+ ``[width]x[height]`` (for example ``{% filer_video obj 320x240 %}``) or
+ a tuple variable with two integers. If no display dimensions are given
the movie dimensions are used.
"""
tag_syntax_error = False
@@ -40,11 +40,11 @@ def filer_video(source, video_dimensions=None):
dimensions = (source.width, source.height)
except:
tag_syntax_error
-
+
if tag_syntax_error:
raise TemplateSyntaxError("Invalid syntax. Expected "
"'{%% %s source [dimensions] %%}'" % tag)
return {'video': source, 'dimensions': dimensions}
-register.inclusion_tag('filer/video.html')(filer_video)
+register.inclusion_tag('filer/video.html')(filer_video)
View
@@ -14,6 +14,7 @@
FFMPEG_DIMENSIONS_RE = re.compile(r'Stream.*Video.*([0-9]{3,})x([0-9]{3,})')
LAST_UNDERSCORE_RE = re.compile(r'\_(?=[^_]*$)')
+
def get_format_name(name, ext):
path, original_ext = os.path.splitext(name)
return u'%s%s.%s' % (path, original_ext.replace('.', '_'), ext)
@@ -25,7 +26,7 @@ def format_to_original_filename(name):
def check_ffmpeg_available():
- status, output = execute_ffmpeg_command('ffmpeg','')
+ status, output = execute_ffmpeg_command('ffmpeg', '')
res = re.search('usage: ffmpeg', output)
return True if res else False

0 comments on commit e34f9f3

Please sign in to comment.