MasayukiSuda / Mp4Composer-android

This library generate an Mp4 movie using Android MediaCodec API and apply filter, scale, trim, transcode, crop, timeScale, mute and rotate Mp4.
MIT License
956 stars 219 forks source link

how can i select output size? #91

Open happyHou opened 3 years ago

happyHou commented 3 years ago

thanks author,you are great. when i user size() function set exact value,this lib not working.so how can i select output size?

happyHou commented 3 years ago

i found /etc/media_codecs.xml record current device support size。

happyHou commented 3 years ago

we can first check size value!!

for (MediaCodecInfo codecInfo : new MediaCodecList(MediaCodecList.ALL_CODECS).getCodecInfos()) {
            if (!codecInfo.isEncoder())
                continue;
            String[] types = codecInfo.getSupportedTypes();
            for (int j = 0; j < types.length; j++) {
                if ("video/avc".equalsIgnoreCase(types[j])) {
                    MediaCodecInfo.CodecCapabilities codecCaps = codecInfo.getCapabilitiesForType("video/avc");
                    MediaCodecInfo.VideoCapabilities vidCaps = codecCaps.getVideoCapabilities();
                    Range<Integer> framerates = vidCaps.getSupportedFrameRates();
                    Range<Integer> widths = vidCaps.getSupportedWidths();
                    Range<Integer> heights = vidCaps.getSupportedHeights();
                    Log.d("H.264Encoder", "Found encoder with\n" + widths.toString()
                            + " x " + heights.toString() + " @ " + framerates.toString() + " fps aligned to " + vidCaps.getWidthAlignment());
                }
            }
        }