diff options
5 files changed, 47 insertions, 4 deletions
diff --git a/mediagoblin/db/migrations/versions/cc3651803714_add_main_transcoding_progress_column_to_.py b/mediagoblin/db/migrations/versions/cc3651803714_add_main_transcoding_progress_column_to_.py new file mode 100644 index 00000000..fdcde3ba --- /dev/null +++ b/mediagoblin/db/migrations/versions/cc3651803714_add_main_transcoding_progress_column_to_.py @@ -0,0 +1,28 @@ +"""add main transcoding progress column to MediaEntry + +Revision ID: cc3651803714 +Revises: 228916769bd2 +Create Date: 2017-08-21 23:33:01.401589 + +""" + +# revision identifiers, used by Alembic. +revision = 'cc3651803714' +down_revision = '228916769bd2' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + """ + Addition of main_transcoding_progress is required to save the progress of the + default resolution (other than the total progress of the video). + """ + op.add_column('core__media_entries', sa.Column('main_transcoding_progress', sa.Float(), default=0)) + + +def downgrade(): + pass diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index cc06b12f..b2dcb6ad 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -543,6 +543,7 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin): fail_metadata = Column(JSONEncoded) transcoding_progress = Column(Float, default=0) + main_transcoding_progress = Column(Float, default=0) queued_media_file = Column(PathTupleWithSlashes) diff --git a/mediagoblin/media_types/video/transcoders.py b/mediagoblin/media_types/video/transcoders.py index 437b0bf8..75f5ef86 100644 --- a/mediagoblin/media_types/video/transcoders.py +++ b/mediagoblin/media_types/video/transcoders.py @@ -189,6 +189,7 @@ class VideoTranscoder(object): # Get number of resolutions available for the video video_config = mgg.global_config['plugins']['mediagoblin.media_types.video'] self.num_of_resolutions = len(video_config['available_resolutions']) + self.default_resolution = video_config['default_resolution'] if not type(self.destination_dimensions) == tuple: raise Exception('dimensions must be tuple: (width, height)') @@ -367,7 +368,10 @@ class VideoTranscoder(object): percent_increment = percent - self.progress_percentage self.progress_percentage = percent if self._progress_callback: - self._progress_callback(percent_increment/self.num_of_resolutions) + if ACCEPTED_RESOLUTIONS[self.default_resolution] == self.destination_dimensions: + self._progress_callback(percent_increment/self.num_of_resolutions, percent) + else: + self._progress_callback(percent_increment/self.num_of_resolutions) _log.info('{percent}% of {dest} resolution done..' '.'.format(percent=percent, dest=self.destination_dimensions)) elif message.type == Gst.MessageType.ERROR: diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index a9d5442b..2897b5e7 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -39,12 +39,14 @@ class ProgressCallback(object): def __init__(self, entry): self.entry = entry - def __call__(self, progress): + def __call__(self, progress, default_quality_progress=None): if progress: if 100 - (self.entry.transcoding_progress + progress) < 0.01: self.entry.transcoding_progress = 100 else: - self.entry.transcoding_progress += progress + self.entry.transcoding_progress += round(progress, 2) + if default_quality_progress: + self.entry.main_transcoding_progress = default_quality_progress self.entry.save() diff --git a/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html b/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html index ee7b646a..287bd6f2 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html +++ b/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html @@ -23,6 +23,7 @@ {% trans %}Media processing panel{% endtrans %} — {{ super() }} {%- endblock %} + {% block mediagoblin_content %} <h1>{% trans %}Media processing panel{% endtrans %}</h1> @@ -50,7 +51,8 @@ Show: <th width="210">Thumbnail</th> <th>Title</th> <th width="20%">When submitted</th> - <th width="200">Transcoding progress</th> + <th width="200">Total transcoding progress</th> + <th width="200">Default resolution transcoding progress</th> </tr> {% for media_entry in entries %} <tr> @@ -84,6 +86,11 @@ Show: {% else %} <td>Unknown</td> {% endif %} + {% if media_entry.main_transcoding_progress %} + <td>{{ media_entry.main_transcoding_progress }}%</td> + {% else %} + <td>Unknown</td> + {% endif %} {% endif %} </tr> {% endfor %} @@ -93,3 +100,4 @@ Show: <p><em>{% trans %}You have not uploaded anything yet!{% endtrans %}</em></p> {% endif %} {% endblock %} + |