Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to reduce the size of the video by using media3 transformer library #1154

Closed
NagaMoto57 opened this issue Mar 6, 2024 · 7 comments
Closed

Comments

@NagaMoto57
Copy link

NagaMoto57 commented Mar 6, 2024

Hi Team,

I want to reduce the size of the video by using media3 transformer library. I tried by setting the Presentation.createForHeight(360). Still I could see the size is more, when compare with other library compression.

As I compared both the compressed videos (media3 transformed video and other library compressed video), I could notice the Data rate and Total bitrate is high in media3 transformer library.

Please suggest what are the approaches, I need to do to reduce the video size EX : Bitrate, etc..

I am using androidx.media3:media3-transformer:1.2.1, androidx.media3:media3-effect:1.2.1 and androidx.media3:media3-common:1.2.1

@droid-girl
Copy link
Contributor

Hi @NagaMoto57,
You can set bitrate with VideoEncoderSettings when creating Transformer by setting EncoderFactory like this:

transformerBuilder.setEncoderFactory(
          new DefaultEncoderFactory.Builder(/* context= */ this )
              .setRequestedVideoEncoderSettings(
                  new VideoEncoderSettings.Builder()
                      .setBitrate(BITRATE_VALUE)
                      .build())
              .build());

@NagaMoto57
Copy link
Author

Hi Team,

Thanks for the update, Can you please provide the information for below.

  1. Along with passing height and bitrate what else I can do to reduce the video size without losing quality much using the media3 library.
  2. Is their any approach to know what should be the bitrate value to set for losing the size.

Thanks.

@droid-girl
Copy link
Contributor

@ychaparov could you help here?

@claincly
Copy link
Contributor

Along with passing height and bitrate what else I can do to reduce the video size without losing quality much using the media3 library.

VideoEncoderSettings also supports setting encoding profile and level. Higher profile enables more advanced encoding techniques so it's likely you can reduce video size there, but the caveat is, a device may not support the higher encoding profile.

Is their any approach to know what should be the bitrate value to set for losing the size.

What we have used internally previously was a method called Kush gauge, it's a crude way to calculating the bitrate to use given resolution and frame rate. It's basically

$$ \text{Bitrate} = \text{width}\times\text{height}\times\text{frame rate}\times\text{coefficient} $$

Where you can tune the $\text{coefficient}$ to a specific quality. You can find more about how to tune this coefficient online.

@ychaparov ychaparov reopened this Mar 13, 2024
@ychaparov
Copy link
Contributor

Hi @NagaMoto57 !

We're aware of some issues with the output quality of Transformer, and we'd like your feedback to prioritize the most visible issues first.

Can you please share more details about the videos you're trying to process?

Information such as codec, width, height, SDR or HDR, etc. would be helpful. You can get this via ffmpeg or MediaInfo (also available online https://mediaarea.net/MediaInfoOnline ).

Were those videos recorded on the phone running Transformer or do they come from another source?

Is there anything specific about the videos? (animated content? Social media content? Video with text overlay?)

@google-oss-bot
Copy link
Collaborator

Hey @NagaMoto57. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link
Collaborator

Since there haven't been any recent updates here, I am going to close this issue.

@NagaMoto57 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants