hoolrory / androidvideosamples Goto Github PK
View Code? Open in Web Editor NEWSample code for working with video on Android
License: Apache License 2.0
Sample code for working with video on Android
License: Apache License 2.0
I recored one video from camera with width=864 and height=480.
When I scale it down by 2, then the video get compressed with no issues.
But when I scale it down by 4, then I get warning : width or height not multiple of 16 and below exception :
java.lang.IllegalStateException at android.media.MediaCodec.dequeueOutputBuffer(Native Method) at VideoResampler.resampleVideo(VideoResampler.java:376) at VideoResampler.feedClipToEncoder(VideoResampler.java:245) at VideoResampler.resampleVideo(VideoResampler.java:208) at VideoResampler.access$200(VideoResampler.java:37) at VideoResampler$VideoEditWrapper.run(VideoResampler.java:165) at java.lang.Thread.run(Thread.java:841)
Is the issue related to scaling?
There is no audio in generated video file.
I have used this code,
VideoResampler resampler = new VideoResampler();
resampler.addSamplerClip(new SamplerClip(inputUri));
resampler.setOutput(outputUri);
resampler.setOutputResolution(Resolution.RESOLUTION_360P.getWidth(), Resolution.RESOLUTION_360P.getHeight());
try {
resampler.start();
} catch (Throwable e) {
e.printStackTrace();
}
Input: front Camera captured videos with OrientationHint set at 270 to make end result as Portrait video.
Action: Resize(Downsample)
Behaviour in Lollipop: The videos are auto rotated to portrait format. So we have to pass Resolution.360p.getWidth() as height and Resolution.360p.getHeight() as width. The end result is proper portrait videos (video completely changed to portrait, not the metadata or container orientation)
Behaviour in Kitkat: The videos are in landscape mode.
Why this difference in behaviour? I would like to get the behaviour as in Lollipop, so that the video is completely transformed to 360x640 portrait resolution
Your code work perfectly when set birate greater than 2073600, however when i set it lower than 2073600 (1000000 for example), it will automatically change back to 2073600. I using Android 12 API 31 Pixel 5.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.