From 9de4fab437558d101e801a02240ca3772c590ace Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Tue, 20 Aug 2013 10:29:38 -0700 Subject: [PATCH] rename webm_640 to webm_video since it might be a different resolution --- mediagoblin/media_types/video/__init__.py | 2 +- mediagoblin/media_types/video/migrations.py | 17 +++++++++++++++++ mediagoblin/media_types/video/models.py | 6 +++--- mediagoblin/media_types/video/processing.py | 16 ++++++++-------- .../mediagoblin/media_displays/video.html | 6 +++--- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/mediagoblin/media_types/video/__init__.py b/mediagoblin/media_types/video/__init__.py index 03ffcb1f..0ed19d1b 100644 --- a/mediagoblin/media_types/video/__init__.py +++ b/mediagoblin/media_types/video/__init__.py @@ -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"' diff --git a/mediagoblin/media_types/video/migrations.py b/mediagoblin/media_types/video/migrations.py index 442bbd8d..b549ca9e 100644 --- a/mediagoblin/media_types/video/migrations.py +++ b/mediagoblin/media_types/video/migrations.py @@ -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() diff --git a/mediagoblin/media_types/video/models.py b/mediagoblin/media_types/video/models.py index 0b52c53f..be9d258f 100644 --- a/mediagoblin/media_types/video/models.py +++ b/mediagoblin/media_types/video/models.py @@ -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"] \ diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py index a3aa9bcf..ee03d949 100644 --- a/mediagoblin/media_types/video/processing.py +++ b/mediagoblin/media_types/video/processing.py @@ -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 diff --git a/mediagoblin/templates/mediagoblin/media_displays/video.html b/mediagoblin/templates/mediagoblin/media_displays/video.html index b0854c9f..5c52f9f0 100644 --- a/mediagoblin/templates/mediagoblin/media_displays/video.html +++ b/mediagoblin/templates/mediagoblin/media_displays/video.html @@ -62,11 +62,11 @@ {% endif %} - {% if 'webm_640' in media.media_files %} + {% if 'webm_video' in media.media_files %}
  • - {%- trans %}WebM file (640p; VP8/Vorbis){% endtrans -%} + media.media_files.webm_video) }}"> + {%- trans %}WebM file (VP8/Vorbis){% endtrans -%}
  • {% endif %} -- 2.25.1