Skip to content

Using stories lib in video compression scenario#14256

Merged
mzorz merged 16 commits intodevelopfrom
try/using-lib-in-video-compression-scenario
May 24, 2021
Merged

Using stories lib in video compression scenario#14256
mzorz merged 16 commits intodevelopfrom
try/using-lib-in-video-compression-scenario

Conversation

@develric
Copy link
Copy Markdown
Contributor

@develric develric commented Mar 15, 2021

This PR aims to use the stories library to manage the video compression/optimization scenario in WPAndroid.

Companion stories PR in Automattic/stories-android#652

NOTE: the feature flag currently is disabled, and it covers the video compression only part. The stories lib modifications are not feature flagged so we need to test them well to avoid regressions or issues since we will not be able to remote disable the changes. Once we are ok with testing of stories and video compression we can decide to merge this PR and create another dedicated PR to activate the flag for video compression in production. We will keep the flag so that we can monitor the release and eventually disable remotely the video compression feature, falling back to the original implementation of the video compression.

To test

The feature is behind feature flag, you need to activate the MP4_COMPOSER_VIDEO_OPTIMIZATION in App Settings > Test feature configuration, then restart the app to make the flag active.

Also please turn on Optimize Videos option in App Settings.

Stories use case

First things first 😄 , we need to test the stories scenarios to make sure no issues are introduced by the changes

Video compression ON

  • Make sure you activated Optimize Videos and MP4_COMPOSER_VIDEO_OPTIMIZATION
  • In the Media library and in the Editor try to upload various types and sizes of videos from device or google drive
  • Check the video is uploaded correctly
  • Check both audio and video playback is as expected
  • in the app storage space > cache folder (on the device or emulator) check you get the compressed copy named like wp-<auto created unique id>.<video format extension>

Video compression OFF

  • Make sure you de-activated Optimize Videos and MP4_COMPOSER_VIDEO_OPTIMIZATION is ON
  • In the Media library and in the Editor try to upload various types and sizes of videos from device or google drive
  • Check the video is uploaded correctly
  • Publish the post
  • Check both audio and video playback is as expected
  • in the app storage space > cache folder (on the device or emulator) check you DO NOT get the compressed copy named like wp-<auto created unique id>.<video format extension>

Check everything works if feature flag is off

  • Test stories and video compression with feature flag off

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Mar 15, 2021

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@develric develric requested review from daniloercoli and mzorz March 15, 2021 02:14
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Mar 15, 2021

You can test the changes on this Pull Request by downloading the APK here.

String strSavingsKb = new DecimalFormat("0.00").format(savingsKb).concat("KB");

// make sure the resulting file is smaller than the original
if (savings <= 0) {
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.

Would it be nice to delete the produced file in mOutputPath, once we realize we're not going to be using it after all?

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 point 👍 ! if you agree I created a dedicated issue for this here

package org.wordpress.android.ui.uploads

// TODO: move here the VideoOptimizationListener interface and ProgressEvent. Leaving them in their original
// position for now to not change the files as they are
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.

👍 agreed, it might be good to have them together

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.

Moved interfaces and data classe used by them to VideoOptimizerContracts.

VideoFormatMimeType.AVC,
bitrate * 1024,
2,
96 * 1024,
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.

Could we maybe move these to constants and add a comment next to each one, explaining the reasoning why these values are passed like this?
Also wondering, could it be possible that we need to pass any other values or will this work universally?

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.

Not a great study behind that tbh 😄 ....I basically just tried to use the set of parameters that were used (as a fixed set like here) in the previous implementation. Added a comment in the code that hope can help to clarify, let me know 🙇

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.

thanks for your answer! sounds good 👍

Copy link
Copy Markdown
Contributor

@mzorz mzorz left a comment

Choose a reason for hiding this comment

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

Nice work here @develric 👏

Left a few comments but overall nothing really pressing to change. Already reviewed and approved the Stories PR Automattic/stories-android#652 so feel free to tackle the comments here and merge after everything is up to date with develop.
Ping me once it's updated (or let me know and I can open a new PR to update with develop, against your branch), so I can give it another good pass on both PRs 👍

@develric develric marked this pull request as ready for review May 21, 2021 10:03
@develric
Copy link
Copy Markdown
Contributor Author

Hi @mzorz 👋 , merged from develop and followed up to your feedbacks, let me know wdyt 🙇

@mzorz mzorz self-assigned this May 24, 2021
Copy link
Copy Markdown
Contributor

@mzorz mzorz left a comment

Choose a reason for hiding this comment

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

Awesome job @develric, took the liberty to update the stories library hash after merging PR Automattic/stories-android#652 first in b56413c, leaving the same summary of things tested here as well so it's easier to track later.

Pixel 4a:

  • tried with videos on device of a size smaller than the optimize target, verified the original file is returned
  • tried with videos on device of a size larger than the optimize target, verified the conversion happens
  • tried with videos on google drive, also worked fine for both cases above
  • Also tested the optimizer gets called as well for videos being added to Stories (kind of schroedinger cat), and verified it plays along well with the web player (i.e. when you upload a video and add text to a video story slide, the mp4composer will be used once to process the new video, then called another time for optimizing)
  • Also tested turning optimization off, verified it doesn't go through the mp4composer optimization process.

Samsung J2:

  • tried with videos on device of a size smaller than the optimize target, verified the original file is returned
  • tried with videos on device of a size larger than the optimize target, verified the conversion happens
  • Also tested turning optimization off, verified it doesn't go through the mp4composer optimization process.

@mzorz mzorz enabled auto-merge May 24, 2021 09:13
@peril-wordpress-mobile
Copy link
Copy Markdown

Warnings
⚠️ PR is not assigned to a milestone.

Generated by 🚫 dangerJS

@mzorz mzorz merged commit 4e1c718 into develop May 24, 2021
@mzorz mzorz deleted the try/using-lib-in-video-compression-scenario branch May 24, 2021 09:20
@mzorz mzorz added this to the 17.5 milestone May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants