Skip to content

[Feature] Video optimization step 1#6088

Merged
nbradbury merged 17 commits intodevelopfrom
feature/video-compression-framework
Jun 20, 2017
Merged

[Feature] Video optimization step 1#6088
nbradbury merged 17 commits intodevelopfrom
feature/video-compression-framework

Conversation

@daniloercoli
Copy link
Copy Markdown
Contributor

@daniloercoli daniloercoli commented Jun 16, 2017

This PR adds and uses the Media for Mobile library in order to compress and resize video files before uploading to the server.

We need to test video re-encoding capabilities on a large set of devices before shipping it to our end-users, so basically the plan to test this new feature/library is the following:

  • Force enable video optimization to alpha releases
  • Force enable video optimization on any debug build

Our end users will not see this feature until we decide is stable enough, and we've completed the integration of it in Settings screen. I suppose there will be a new setting for it.

Now the process of re-encoding a video is a blocking task, there is a progress dialog in place that is shown until the video is processed. Then, the resulting video is added to the visual editor and the upload starts.
In our final implementation it's better to integrate video re-encoding in the async branch only. Once we've tested that the library works fine.

Videos are re-encoded to 720p (if they're larger) 30 frame per sec, 3000 KBytes rate.

Next steps (step 2) is to start working in the settings screen, and provide the ability to turn this feature ON/OFF (and select different bitrate?).

…r-mobile) to dependencies.

Also added an exception to the main manifest file for it, since the library is built for Android v18+, instead our min SDK is 16.
Enable video optimization flag for Alpha flavour, and for debug build on all flavours.
Also improved the error message shown when we know the video cannot be optimized.
@nbradbury nbradbury self-assigned this Jun 19, 2017
}
}

private class VideoOptimizationProgressListener implements org.m4m.IProgressListener {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about moving all the video optimization code to a separate class? My concern is that EditPostActivity is getting very large and unwieldy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, will move this logic to WPVideoUtils.

@@ -0,0 +1,111 @@
package org.wordpress.android.util;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class would benefit from much more commenting. That would make it much easier for another dev to work on it.


<!-- Video processing -->
<string name="video_optimization_in_progress">Optimizing your video&#8230;</string>
<string name="video_optimization_cant_optimize">Sorry, we can\'t optimize this video. Using the original file.</string>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't appear to use video_optimization_cant_optimize anywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it's not used anymore. Forgot to remove it.

dismissProgressDialog(pd);
Context context = mWeakContext.get();
if (context != null) {
ToastUtils.showToast(context, R.string.video_optimization_generic_error_message, Duration.LONG);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this toast is necessary. The user can't do anything about it, and I can't think of why they'd need to know this information.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's there just to inform our alpha testers of the error occurred compressing the video, but I agree we can remove it and add a Crashlytics log instead to gather stats about compressions problems with videos.

private static final int AUDIO_OUTPUT_BIT_RATE = 96 * 1024;

public static MediaComposer getVideoOptimizationComposer(Context ctx, String inputFile, String outFile, org.m4m.IProgressListener listener) {
if (ctx == null || inputFile == null || listener == null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could skip these null checks and simply make the parameters @NonNull.

@daniloercoli
Copy link
Copy Markdown
Contributor Author

@nbradbury - Ready for another pass!

@nbradbury
Copy link
Copy Markdown
Contributor

Looks good! :shipit:

@nbradbury nbradbury merged commit 9e69265 into develop Jun 20, 2017
@nbradbury nbradbury deleted the feature/video-compression-framework branch June 20, 2017 10:58
theck13 added a commit that referenced this pull request Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants