Loading apex/media/framework/java/android/media/MediaTranscodingManager.java +10 −9 Original line number Original line Diff line number Diff line Loading @@ -946,6 +946,8 @@ public final class MediaTranscodingManager { * * * @return the video track format to be used if transcoding should be performed, * @return the video track format to be used if transcoding should be performed, * and null otherwise. * and null otherwise. * @throws IllegalArgumentException if the hinted source video format contains invalid * parameters. */ */ @Nullable @Nullable public MediaFormat resolveVideoFormat() { public MediaFormat resolveVideoFormat() { Loading @@ -956,21 +958,20 @@ public final class MediaTranscodingManager { MediaFormat videoTrackFormat = new MediaFormat(mSrcVideoFormatHint); MediaFormat videoTrackFormat = new MediaFormat(mSrcVideoFormatHint); videoTrackFormat.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_VIDEO_AVC); videoTrackFormat.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_VIDEO_AVC); int width = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_WIDTH); int width = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_WIDTH, -1); int height = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_HEIGHT); int height = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_HEIGHT, -1); if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) { throw new IllegalArgumentException( throw new IllegalArgumentException( "Source Width and height must be larger than 0"); "Source Width and height must be larger than 0"); } } float frameRate = 30.0f; // default to 30fps. float frameRate = if (mSrcVideoFormatHint.containsKey(MediaFormat.KEY_FRAME_RATE)) { mSrcVideoFormatHint.getNumber(MediaFormat.KEY_FRAME_RATE, 30.0) frameRate = mSrcVideoFormatHint.getFloat(MediaFormat.KEY_FRAME_RATE); .floatValue(); if (frameRate <= 0) { if (frameRate <= 0) { throw new IllegalArgumentException( throw new IllegalArgumentException( "frameRate must be larger than 0"); "frameRate must be larger than 0"); } } } int bitrate = getAVCBitrate(width, height, frameRate); int bitrate = getAVCBitrate(width, height, frameRate); videoTrackFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate); videoTrackFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate); Loading Loading
apex/media/framework/java/android/media/MediaTranscodingManager.java +10 −9 Original line number Original line Diff line number Diff line Loading @@ -946,6 +946,8 @@ public final class MediaTranscodingManager { * * * @return the video track format to be used if transcoding should be performed, * @return the video track format to be used if transcoding should be performed, * and null otherwise. * and null otherwise. * @throws IllegalArgumentException if the hinted source video format contains invalid * parameters. */ */ @Nullable @Nullable public MediaFormat resolveVideoFormat() { public MediaFormat resolveVideoFormat() { Loading @@ -956,21 +958,20 @@ public final class MediaTranscodingManager { MediaFormat videoTrackFormat = new MediaFormat(mSrcVideoFormatHint); MediaFormat videoTrackFormat = new MediaFormat(mSrcVideoFormatHint); videoTrackFormat.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_VIDEO_AVC); videoTrackFormat.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_VIDEO_AVC); int width = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_WIDTH); int width = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_WIDTH, -1); int height = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_HEIGHT); int height = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_HEIGHT, -1); if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) { throw new IllegalArgumentException( throw new IllegalArgumentException( "Source Width and height must be larger than 0"); "Source Width and height must be larger than 0"); } } float frameRate = 30.0f; // default to 30fps. float frameRate = if (mSrcVideoFormatHint.containsKey(MediaFormat.KEY_FRAME_RATE)) { mSrcVideoFormatHint.getNumber(MediaFormat.KEY_FRAME_RATE, 30.0) frameRate = mSrcVideoFormatHint.getFloat(MediaFormat.KEY_FRAME_RATE); .floatValue(); if (frameRate <= 0) { if (frameRate <= 0) { throw new IllegalArgumentException( throw new IllegalArgumentException( "frameRate must be larger than 0"); "frameRate must be larger than 0"); } } } int bitrate = getAVCBitrate(width, height, frameRate); int bitrate = getAVCBitrate(width, height, frameRate); videoTrackFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate); videoTrackFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate); Loading