Permalink
Browse files

show poster, default to uploaded image when conversions are missing2

  • Loading branch information...
1 parent 24bb729 commit 8af75d7ca240cef15593254ece754a4d8fe8f21b @pvl pvl committed Oct 26, 2011
Showing with 19 additions and 10 deletions.
  1. +8 −1 filer/models/videomodels.py
  2. +5 −4 filer/settings.py
  3. +6 −5 filer/templates/filer/video.html
@@ -59,7 +59,8 @@ def set_initial_dimensions(self):
def save(self, *args, **kwargs):
self.has_all_mandatory_data = self._check_validity()
- if not self.original_width and not self.original_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,6 +79,12 @@ def formats(self):
pass
return _formats
+ def original_format(self):
+ url = self.file.storage.url(self.file.name)
+ name, ext = os.path.splitext(self.file.name)
+ format = ext.replace('.','')
+ return {'url':url, 'format':format}
+
def formats_html5(self):
""" Video formats supported by HTML5 browsers """
HTML5_FORMATS = ('mp4','ogv','webm')
View
@@ -115,14 +115,15 @@
# formats recognized as video file formats (no leading dot)
FILER_SOURCE_VIDEO_FORMATS = ('mp4', 'avi', 'wmv', 'mov', 'mpg')
# formats to convert into (no leading dot)
-FILER_VIDEO_FORMATS = ('flv', 'mp4','ogv','webm')
+FILER_VIDEO_FORMATS = ('flv', 'mp4','webm')
# command line for video checking of dimensions
FFMPEG_CHECK_CMD = "ffmpeg -i %(input_file)s"
# command line for video conversion
FFMPEG_CMD = "ffmpeg -i %(input_file)s -y -b 2326k -ar 44100 -ab 224k -ac 2 -f %(format)s %(dimensions)s %(target_file)s"
-# dimensions of the converted videos - leave blank to keep the original video size
-FFMPEG_TARGET_DIMENSIONS = "640x480"
+# dimensions of the converted videos
+FFMPEG_TARGET_DIMENSIONS = "" #maintain original video dimensions
+#FFMPEG_TARGET_DIMENSIONS = "640x480" #always change to given dimensions
# argument for setting the size in ffmpeg
FFMPEG_SIZE_ARGUMENT = "-s %(dimensions)s"
# command line for grabbing preview image from video
-GRABIMG_CMD = "ffmpeg -y -i %(input_file)s -vframes 1 -ss 00:00:05 -an -vcodec png -f rawvideo %(dimensions)s %(target_file)s"
+GRABIMG_CMD = "ffmpeg -y -i %(input_file)s -vframes 1 -ss 00:00:02 -an -vcodec png -f rawvideo %(dimensions)s %(target_file)s"
@@ -1,11 +1,12 @@
{% load filermedia %}
<!-- from: http://camendesign.com/code/video_for_everybody -->
<!-- first try HTML5 playback: if serving as XML, expand `controls` to `controls="controls"` and autoplay likewise -->
-<!-- warning: playback does not work on iOS3 if you include the poster attribute! fixed in iOS4.0 -->
-<video width="{{ dimensions.0 }}" height="{{ dimensions.1 }}" controls>
+<video {% if poster %} poster="{{ video.poster }}"{% endif %} width="{{ dimensions.0 }}" height="{{ dimensions.1 }}" controls>
<!-- MP4 must be first for iPad! -->
{% for fileformat in video.formats_html5 %}
<source src="{{ fileformat.url }}" type='video/{{ fileformat.format }}' />
+ {% empty %}
+ <source src="{{ video.original_format.url }}" type='video/{{ video.original_format.format }}' />
{% endfor %}
{% if video.format_flash %}
@@ -14,10 +15,10 @@
<!-- Firefox uses the `data` attribute above, IE/Safari uses the param below -->
<param name="movie" value="{% filer_staticmedia_prefix %}flash/flowplayer-3.2.7.swf" />
<param name="wmode" value="transparent" />
- <param name="flashVars" value="config={'playlist':['/media/app24.png',{'url':'{{ video.format_flash }}','autoPlay':false}]}" />
+ <param name="flashVars" value="config={'playlist':['{{ video.poster }}',{'url':'{{ video.format_flash }}','autoPlay':false}]}" />
<!-- fallback image. note the title field below, put the title of the video there -->
- <img src="/media/app24.png" width="640" height="360" alt="__TITLE__"
- title="No video playback capabilities, please download the video below" />
+ <img src="{{ video.poster }}" alt="{{ video.default_alt_text }}"
+ title="No video playback capabilities" />
</object>
{% endif %}
</video>

0 comments on commit 8af75d7

Please sign in to comment.