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

TransformationOptions giving corrupt video #224

Open
AsitDixit opened this issue Nov 11, 2022 · 3 comments
Open

TransformationOptions giving corrupt video #224

AsitDixit opened this issue Nov 11, 2022 · 3 comments

Comments

@AsitDixit
Copy link

AsitDixit commented Nov 11, 2022

I don't know is this a right place to ask doubts, but I need your help. My problem is this lib has less documetation.
I want to:

  1. Trim vieo
  2. compress video (maintaining original aspect ratio, width height can be decreased)
  3. adding my custom image at bottom left corner with some margin to bottom and left side. One thing I want to maintain constant ratio of bitmap overlay width and height to the height & width of video.
        TransformationOptions transformationOptions = new TransformationOptions.Builder()
                .setGranularity(MediaTransformer.GRANULARITY_DEFAULT)
                .setVideoFilters(null)
                .setSourceMediaRange(new MediaRange(1000,5000))
                .build();

When adding null in place of TransformationOptions in mediaTransformer.transform it is working fine. But with above code it is not giving any error but producing an empty file. Am I missing something?

SORRY I'm beginner

@AsitDixit AsitDixit changed the title How to trim and add own bitmap overlay? TransformationOptions giving corrupt video Nov 11, 2022
@izzytwosheds
Copy link
Contributor

I think the problem here is with MediaRange values. They are supposed to be in microseconds, not in milliseconds. I assume you are trying to trim the video between 1 and 5 seconds. So values here should be 1_000_000 and 5_000_000, not 1_000 and 5_000

@AsitDixit
Copy link
Author

AsitDixit commented Nov 12, 2022

I think the problem here is with MediaRange values. They are supposed to be in microseconds, not in milliseconds. I assume you are trying to trim the video between 1 and 5 seconds. So values here should be 1_000_000 and 5_000_000, not 1_000 and 5_000

Okay but I saw LiTr is using many deprecated api please update them.

  MediaFormat targetVideoFormat = new MediaFormat();
                targetVideoFormat.setString(MediaFormat.KEY_MIME, "video/avc");
                targetVideoFormat.setInteger(MediaFormat.KEY_WIDTH, 100);
                targetVideoFormat.setInteger(MediaFormat.KEY_HEIGHT, 150);
                targetVideoFormat.setInteger(MediaFormat.KEY_BIT_RATE, 4800);
                targetVideoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 5);
                targetVideoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 30);
                targetVideoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);

Here HEIGHT=150 & WIDTH=100 but output is opposite of this.

@izzytwosheds
Copy link
Contributor

Here HEIGHT=150 & WIDTH=100 but output is opposite of this.

Is there a rotation flag? If rotation flag is present (90 or 270 degrees) it is preserved and video will be rotated when played, which will make it look like that width and height are switched.

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

No branches or pull requests

2 participants