rename webm_640 to webm_video since it might be a different resolution
authorRodney Ewing <ewing.rj@gmail.com>
Tue, 20 Aug 2013 17:29:38 +0000 (10:29 -0700)
committerRodney Ewing <ewing.rj@gmail.com>
Tue, 20 Aug 2013 17:29:38 +0000 (10:29 -0700)
mediagoblin/media_types/video/__init__.py
mediagoblin/media_types/video/migrations.py
mediagoblin/media_types/video/models.py
mediagoblin/media_types/video/processing.py
mediagoblin/templates/mediagoblin/media_displays/video.html

index 03ffcb1fa3c5f1b9a10fa315740f34b034f277bb..0ed19d1bb28248a7caea5536c28ee925dd00ee3d 100644 (file)
@@ -34,7 +34,7 @@ class VideoMediaManager(MediaManagerBase):
     default_thumb = "images/media_thumbs/video.jpg"
 
     # Used by the media_entry.get_display_media method
-    media_fetch_order = [u'webm_640', u'original']
+    media_fetch_order = [u'webm_video', u'original']
     default_webm_type = 'video/webm; codecs="vp8, vorbis"'
 
 
index 442bbd8d325a3b717bb27b86849e08c8d820a173..b549ca9e5c8662eeb961e20ee71ba43138c319a0 100644 (file)
@@ -20,6 +20,7 @@ from sqlalchemy import MetaData, Column, Unicode
 
 MIGRATIONS = {}
 
+
 @RegisterMigration(1, MIGRATIONS)
 def add_orig_metadata_column(db_conn):
     metadata = MetaData(bind=db_conn.bind)
@@ -30,3 +31,19 @@ def add_orig_metadata_column(db_conn):
                  default=None, nullable=True)
     col.create(vid_data)
     db_conn.commit()
+
+
+@RegisterMigration(2, MIGRATIONS)
+def webm_640_to_wemb_video(db):
+    metadata = MetaData(bind=db.bind)
+
+    file_keynames = inspect_table(metadata, 'core__file_keynames')
+
+    for row in db.execute(file_keynames.select()):
+        if row.name == 'webm_640':
+            db.execute(
+                file_keynames.update(). \
+                where(file_keynames.c.id==row.id).\
+                values(name='webm_video'))
+
+    db.commit()
index 0b52c53f326c13623b9d98227333dd4c2c9f4ed8..be9d258f5f79092e2af038855739d4ce78b04010 100644 (file)
@@ -36,12 +36,12 @@ class VideoData(Base):
      - orig_metadata: A loose json structure containing metadata gstreamer
          pulled from the original video.
          This field is NOT GUARANTEED to exist!
-    
+
          Likely metadata extracted:
            "videoheight", "videolength", "videowidth",
            "audiorate", "audiolength", "audiochannels", "audiowidth",
            "mimetype", "tags"
-     
+
          TODO: document the above better.
     """
     __tablename__ = "video__mediadata"
@@ -68,7 +68,7 @@ class VideoData(Base):
         """
         orig_metadata = self.orig_metadata or {}
 
-        if "webm_640" not in self.get_media_entry.media_files \
+        if "webm_video" not in self.get_media_entry.media_files \
            and "mimetype" in orig_metadata \
            and "tags" in orig_metadata \
            and "audio-codec" in orig_metadata["tags"] \
index a3aa9bcf05dd023fc9a5af0854f7689e40ec6385..ee03d949a32f477c091826c5ee119007c3a68398 100644 (file)
@@ -122,7 +122,7 @@ class CommonVideoProcessor(MediaProcessor):
     """
     Provides a base for various video processing steps
     """
-    acceptable_files = ['original', 'best_quality', 'webm_640']
+    acceptable_files = ['original', 'best_quality', 'webm_video']
 
     def common_setup(self):
         self.video_config = mgg \
@@ -151,16 +151,16 @@ class CommonVideoProcessor(MediaProcessor):
         if not self.entry.media_files.get('best_quality'):
             # Save the best quality file if no original?
             if not self.entry.media_files.get('original') and \
-                    self.entry.media_files.get('webm_640'):
+                    self.entry.media_files.get('webm_video'):
                 self.entry.media_files['best_quality'] = self.entry \
-                    .media_files['webm_640']
+                    .media_files['webm_video']
 
 
     def transcode(self, medium_size=None, vp8_quality=None, vp8_threads=None,
                   vorbis_quality=None):
         progress_callback = ProgressCallback(self.entry)
         tmp_dst = os.path.join(self.workbench.dir,
-                               self.name_builder.fill('{basename}-640p.webm'))
+                               self.name_builder.fill('{basename}.medium.webm'))
 
         if not medium_size:
             medium_size = (
@@ -187,8 +187,8 @@ class CommonVideoProcessor(MediaProcessor):
             # If there is an original and transcoded, delete the transcoded
             # since it must be of lower quality then the original
             if self.entry.media_files.get('original') and \
-               self.entry.media_files.get('webm_640'):
-                self.entry.media_files['webm_640'].delete()
+               self.entry.media_files.get('webm_video'):
+                self.entry.media_files['webm_video'].delete()
 
         else:
             self.transcoder.transcode(self.process_filename, tmp_dst,
@@ -205,8 +205,8 @@ class CommonVideoProcessor(MediaProcessor):
 
             # Push transcoded video to public storage
             _log.debug('Saving medium...')
-            store_public(self.entry, 'webm_640', tmp_dst,
-                         self.name_builder.fill('{basename}-640p.webm'))
+            store_public(self.entry, 'webm_video', tmp_dst,
+                         self.name_builder.fill('{basename}.medium.webm'))
             _log.debug('Saved medium')
 
             self.did_transcode = True
index b0854c9f7135b518849dc6783635d88d6bc434cf..5c52f9f0e5c211d14c717790f930924d6db74c8f 100644 (file)
         </a>
       </li>
     {% endif %}
-    {% if 'webm_640' in media.media_files %}
+    {% if 'webm_video' in media.media_files %}
       <li>
         <a href="{{ request.app.public_store.file_url(
-                       media.media_files.webm_640) }}">
-          {%- trans %}WebM file (640p; VP8/Vorbis){% endtrans -%}
+                       media.media_files.webm_video) }}">
+          {%- trans %}WebM file (VP8/Vorbis){% endtrans -%}
         </a>
       </li>
     {% endif %}