Skip to content

Commit 58acf44

Browse files
committed
Fix bad aspect ratios for recorded effects
Fix b/6530189 Fix b/6535207 Change-Id: I6ef09bd619acc31af53d9991335cda33b7c08908
1 parent 956f28e commit 58acf44

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

media/mca/filterpacks/java/android/filterpacks/videosink/MediaEncoderFilter.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ public class MediaEncoderFilter extends Filter {
111111
/** Frame width to be encoded, defaults to 320.
112112
* Actual received frame size has to match this */
113113
@GenerateFieldPort(name = "width", hasDefault = true)
114-
private int mWidth = 320;
114+
private int mWidth = 0;
115115

116116
/** Frame height to to be encoded, defaults to 240.
117117
* Actual received frame size has to match */
118118
@GenerateFieldPort(name = "height", hasDefault = true)
119-
private int mHeight = 240;
119+
private int mHeight = 0;
120120

121121
/** Stream framerate to encode the frames at.
122122
* By default, frames are encoded at 30 FPS*/
@@ -245,6 +245,11 @@ private void updateMediaRecorderParams() {
245245
if (mProfile != null) {
246246
mMediaRecorder.setProfile(mProfile);
247247
mFps = mProfile.videoFrameRate;
248+
// If width and height are set larger than 0, then those
249+
// overwrite the ones in the profile.
250+
if (mWidth > 0 && mHeight > 0) {
251+
mMediaRecorder.setVideoSize(mWidth, mHeight);
252+
}
248253
} else {
249254
mMediaRecorder.setOutputFormat(mOutputFormat);
250255
mMediaRecorder.setVideoEncoder(mVideoEncoder);
@@ -298,7 +303,10 @@ private void startRecording(FilterContext context) {
298303
screenFormat.setBytesPerSample(4);
299304

300305
int width, height;
301-
if (mProfile != null) {
306+
boolean widthHeightSpecified = mWidth > 0 && mHeight > 0;
307+
// If width and height are specified, then use those instead
308+
// of that in the profile.
309+
if (mProfile != null && !widthHeightSpecified) {
302310
width = mProfile.videoFrameWidth;
303311
height = mProfile.videoFrameHeight;
304312
} else {
@@ -410,7 +418,6 @@ public void process(FilterContext context) {
410418
// And swap buffers
411419
glEnv.swapBuffers();
412420
mNumFramesEncoded++;
413-
if (mLogVerbose) Log.v(TAG, "numFramesEncoded = " + mNumFramesEncoded);
414421
}
415422

416423
private void stopRecording(FilterContext context) {

0 commit comments

Comments
 (0)