List of usage examples for android.media MediaFormat KEY_WIDTH
String KEY_WIDTH
To view the source code for android.media MediaFormat KEY_WIDTH.
Click Source Link
From source file:com.sonymobile.android.media.internal.VUParser.java
@Override protected void updateAspectRatio() { if (mCurrentVideoTrack != null) { if (containsKey(MetaData.KEY_HMMP_PIXEL_ASPECT_RATIO)) { int pixelAspectRatio = getInteger(MetaData.KEY_HMMP_PIXEL_ASPECT_RATIO); int sarWidth = (pixelAspectRatio >> 16) & 0xFFFF; int sarHeight = pixelAspectRatio & 0xFFFF; addMetaDataValue(KEY_WIDTH,/*from www . j a v a2s.c o m*/ (mCurrentVideoTrack.getMediaFormat().getInteger(MediaFormat.KEY_WIDTH) * sarWidth) / sarHeight); } else { super.updateAspectRatio(); } } }
From source file:ca.frozen.rpicameraviewer.activities.VideoFragment.java
@Override public void onCreate(Bundle savedInstanceState) { // configure the activity super.onCreate(savedInstanceState); // load the settings and cameras Utils.loadData();/*from w w w . j a v a 2s.co m*/ // get the parameters camera = getArguments().getParcelable(CAMERA); fullScreen = getArguments().getBoolean(FULL_SCREEN); // create the fade in handler and runnable fadeInHandler = new Handler(); fadeInRunner = new Runnable() { @Override public void run() { Animation fadeInName = new AlphaAnimation(0, 1); fadeInName.setDuration(FADEIN_ANIMATION_TIME); fadeInName.setFillAfter(true); Animation fadeInSnapshot = new AlphaAnimation(0, 1); fadeInSnapshot.setDuration(FADEIN_ANIMATION_TIME); fadeInSnapshot.setFillAfter(true); nameView.startAnimation(fadeInName); snapshotButton.startAnimation(fadeInSnapshot); fadeListener.onStartFadeIn(); } }; // create the fade out handler and runnable fadeOutHandler = new Handler(); fadeOutRunner = new Runnable() { @Override public void run() { Animation fadeOutName = new AlphaAnimation(1, 0); fadeOutName.setDuration(FADEOUT_ANIMATION_TIME); fadeOutName.setFillAfter(true); Animation fadeOutSnapshot = new AlphaAnimation(1, 0); fadeOutSnapshot.setDuration(FADEOUT_ANIMATION_TIME); fadeOutSnapshot.setFillAfter(true); nameView.startAnimation(fadeOutName); snapshotButton.startAnimation(fadeOutSnapshot); fadeListener.onStartFadeOut(); } }; // create the finish handler and runnable finishHandler = new Handler(); finishRunner = new Runnable() { @Override public void run() { getActivity().finish(); } }; // create the start video handler and runnable startVideoHandler = new Handler(); startVideoRunner = new Runnable() { @Override public void run() { MediaFormat format = decoder.getMediaFormat(); int videoWidth = format.getInteger(MediaFormat.KEY_WIDTH); int videoHeight = format.getInteger(MediaFormat.KEY_HEIGHT); textureView.setVideoSize(videoWidth, videoHeight); } }; }
From source file:com.sonymobile.android.media.internal.ISOBMFFParser.java
protected void updateAspectRatio() { if (mCurrentVideoTrack != null) { MediaFormat videoFormat = mCurrentVideoTrack.getMediaFormat(); if (videoFormat.containsKey(MetaData.KEY_SAR_WIDTH) && videoFormat.containsKey(MetaData.KEY_SAR_HEIGHT)) { int sarWidth = videoFormat.getInteger(MetaData.KEY_SAR_WIDTH); int sarHeight = videoFormat.getInteger(MetaData.KEY_SAR_HEIGHT); int adjustedWidth = (int) Math .round(((double) videoFormat.getInteger(MediaFormat.KEY_WIDTH) * sarWidth) / sarHeight); addMetaDataValue(KEY_WIDTH, adjustedWidth); mCurrentVideoTrack.getMetaData().addValue(KEY_WIDTH, adjustedWidth); }/*from ww w . ja va2 s . com*/ } }
From source file:com.serenegiant.media.TLMediaEncoder.java
private static final String asString(final MediaFormat format) { final JSONObject map = new JSONObject(); try {//from w ww .jav a 2 s . c om if (format.containsKey(MediaFormat.KEY_MIME)) map.put(MediaFormat.KEY_MIME, format.getString(MediaFormat.KEY_MIME)); if (format.containsKey(MediaFormat.KEY_WIDTH)) map.put(MediaFormat.KEY_WIDTH, format.getInteger(MediaFormat.KEY_WIDTH)); if (format.containsKey(MediaFormat.KEY_HEIGHT)) map.put(MediaFormat.KEY_HEIGHT, format.getInteger(MediaFormat.KEY_HEIGHT)); if (format.containsKey(MediaFormat.KEY_BIT_RATE)) map.put(MediaFormat.KEY_BIT_RATE, format.getInteger(MediaFormat.KEY_BIT_RATE)); if (format.containsKey(MediaFormat.KEY_COLOR_FORMAT)) map.put(MediaFormat.KEY_COLOR_FORMAT, format.getInteger(MediaFormat.KEY_COLOR_FORMAT)); if (format.containsKey(MediaFormat.KEY_FRAME_RATE)) map.put(MediaFormat.KEY_FRAME_RATE, format.getInteger(MediaFormat.KEY_FRAME_RATE)); if (format.containsKey(MediaFormat.KEY_I_FRAME_INTERVAL)) map.put(MediaFormat.KEY_I_FRAME_INTERVAL, format.getInteger(MediaFormat.KEY_I_FRAME_INTERVAL)); if (format.containsKey(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER)) map.put(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, format.getLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER)); if (format.containsKey(MediaFormat.KEY_MAX_INPUT_SIZE)) map.put(MediaFormat.KEY_MAX_INPUT_SIZE, format.getInteger(MediaFormat.KEY_MAX_INPUT_SIZE)); if (format.containsKey(MediaFormat.KEY_DURATION)) map.put(MediaFormat.KEY_DURATION, format.getInteger(MediaFormat.KEY_DURATION)); if (format.containsKey(MediaFormat.KEY_CHANNEL_COUNT)) map.put(MediaFormat.KEY_CHANNEL_COUNT, format.getInteger(MediaFormat.KEY_CHANNEL_COUNT)); if (format.containsKey(MediaFormat.KEY_SAMPLE_RATE)) map.put(MediaFormat.KEY_SAMPLE_RATE, format.getInteger(MediaFormat.KEY_SAMPLE_RATE)); if (format.containsKey(MediaFormat.KEY_CHANNEL_MASK)) map.put(MediaFormat.KEY_CHANNEL_MASK, format.getInteger(MediaFormat.KEY_CHANNEL_MASK)); if (format.containsKey(MediaFormat.KEY_AAC_PROFILE)) map.put(MediaFormat.KEY_AAC_PROFILE, format.getInteger(MediaFormat.KEY_AAC_PROFILE)); if (format.containsKey(MediaFormat.KEY_AAC_SBR_MODE)) map.put(MediaFormat.KEY_AAC_SBR_MODE, format.getInteger(MediaFormat.KEY_AAC_SBR_MODE)); if (format.containsKey(MediaFormat.KEY_MAX_INPUT_SIZE)) map.put(MediaFormat.KEY_MAX_INPUT_SIZE, format.getInteger(MediaFormat.KEY_MAX_INPUT_SIZE)); if (format.containsKey(MediaFormat.KEY_IS_ADTS)) map.put(MediaFormat.KEY_IS_ADTS, format.getInteger(MediaFormat.KEY_IS_ADTS)); if (format.containsKey("what")) map.put("what", format.getInteger("what")); if (format.containsKey("csd-0")) map.put("csd-0", asString(format.getByteBuffer("csd-0"))); if (format.containsKey("csd-1")) map.put("csd-1", asString(format.getByteBuffer("csd-1"))); } catch (JSONException e) { Log.e(TAG_STATIC, "writeFormat:", e); } return map.toString(); }
From source file:com.serenegiant.media.TLMediaEncoder.java
private static final MediaFormat asMediaFormat(final String format_str) { MediaFormat format = new MediaFormat(); try {//from ww w. ja va2s . c om final JSONObject map = new JSONObject(format_str); if (map.has(MediaFormat.KEY_MIME)) format.setString(MediaFormat.KEY_MIME, (String) map.get(MediaFormat.KEY_MIME)); if (map.has(MediaFormat.KEY_WIDTH)) format.setInteger(MediaFormat.KEY_WIDTH, (Integer) map.get(MediaFormat.KEY_WIDTH)); if (map.has(MediaFormat.KEY_HEIGHT)) format.setInteger(MediaFormat.KEY_HEIGHT, (Integer) map.get(MediaFormat.KEY_HEIGHT)); if (map.has(MediaFormat.KEY_BIT_RATE)) format.setInteger(MediaFormat.KEY_BIT_RATE, (Integer) map.get(MediaFormat.KEY_BIT_RATE)); if (map.has(MediaFormat.KEY_COLOR_FORMAT)) format.setInteger(MediaFormat.KEY_COLOR_FORMAT, (Integer) map.get(MediaFormat.KEY_COLOR_FORMAT)); if (map.has(MediaFormat.KEY_FRAME_RATE)) format.setInteger(MediaFormat.KEY_FRAME_RATE, (Integer) map.get(MediaFormat.KEY_FRAME_RATE)); if (map.has(MediaFormat.KEY_I_FRAME_INTERVAL)) format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, (Integer) map.get(MediaFormat.KEY_I_FRAME_INTERVAL)); if (map.has(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER)) format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, (Long) map.get(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER)); if (map.has(MediaFormat.KEY_MAX_INPUT_SIZE)) format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, (Integer) map.get(MediaFormat.KEY_MAX_INPUT_SIZE)); if (map.has(MediaFormat.KEY_DURATION)) format.setInteger(MediaFormat.KEY_DURATION, (Integer) map.get(MediaFormat.KEY_DURATION)); if (map.has(MediaFormat.KEY_CHANNEL_COUNT)) format.setInteger(MediaFormat.KEY_CHANNEL_COUNT, (Integer) map.get(MediaFormat.KEY_CHANNEL_COUNT)); if (map.has(MediaFormat.KEY_SAMPLE_RATE)) format.setInteger(MediaFormat.KEY_SAMPLE_RATE, (Integer) map.get(MediaFormat.KEY_SAMPLE_RATE)); if (map.has(MediaFormat.KEY_CHANNEL_MASK)) format.setInteger(MediaFormat.KEY_CHANNEL_MASK, (Integer) map.get(MediaFormat.KEY_CHANNEL_MASK)); if (map.has(MediaFormat.KEY_AAC_PROFILE)) format.setInteger(MediaFormat.KEY_AAC_PROFILE, (Integer) map.get(MediaFormat.KEY_AAC_PROFILE)); if (map.has(MediaFormat.KEY_AAC_SBR_MODE)) format.setInteger(MediaFormat.KEY_AAC_SBR_MODE, (Integer) map.get(MediaFormat.KEY_AAC_SBR_MODE)); if (map.has(MediaFormat.KEY_MAX_INPUT_SIZE)) format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, (Integer) map.get(MediaFormat.KEY_MAX_INPUT_SIZE)); if (map.has(MediaFormat.KEY_IS_ADTS)) format.setInteger(MediaFormat.KEY_IS_ADTS, (Integer) map.get(MediaFormat.KEY_IS_ADTS)); if (map.has("what")) format.setInteger("what", (Integer) map.get("what")); if (map.has("csd-0")) format.setByteBuffer("csd-0", asByteBuffer((String) map.get("csd-0"))); if (map.has("csd-1")) format.setByteBuffer("csd-1", asByteBuffer((String) map.get("csd-1"))); } catch (JSONException e) { Log.e(TAG_STATIC, "writeFormat:" + format_str, e); format = null; } return format; }
From source file:com.sonymobile.android.media.internal.ISOBMFFParser.java
protected void parseVisualSampleEntry(byte[] data) { /*/*from w w w . j a v a 2 s . c o m*/ * VisualSampleEntry extends SampleEntry in ISO/IEC 14496 part 12, see * section 8.5.2.2 for structure */ mCurrentOffset += data.length; // SampleEntry // skip 6 for reserved // skip 2 for data_reference_index // VisualSampleEntry // skip 2 for pre_defined // skip 2 for reserved // skip 12 for pre_defined int width = ((data[24] & 0xFF) << 8 | data[25] & 0xFF) & 0x0000FFFF; int height = ((data[26] & 0xFF) << 8 | data[27] & 0xFF) & 0x0000FFFF; // skip 4 for horizresolution // skip 4 for vertresolution // skip 4 for reserved // skip 2 for frame_count // skip 32 for compressorname // skip 2 for depth // skip 2 for pre_defined mCurrentMediaFormat.setInteger(MediaFormat.KEY_WIDTH, width); mCurrentTrack.getMetaData().addValue(KEY_WIDTH, width); mCurrentMediaFormat.setInteger(MediaFormat.KEY_HEIGHT, height); mCurrentTrack.getMetaData().addValue(KEY_HEIGHT, height); int maxSize = ((width + 15) / 16) * ((height + 15) / 16) * 192; mCurrentMediaFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, maxSize); addMetaDataValue(KEY_WIDTH, width); addMetaDataValue(KEY_HEIGHT, height); }
From source file:com.sonymobile.android.media.internal.ISOBMFFParser.java
@Override public TrackInfo[] getTrackInfo() { int numTracks = mTracks.size(); TrackInfo[] trackInfos = new TrackInfo[numTracks]; for (int i = 0; i < numTracks; i++) { IsoTrack track = (IsoTrack) mTracks.get(i); TrackType trackType = track.getTrackType(); if (trackType != TrackType.UNKNOWN) { MediaFormat mediaFormat = track.getMediaFormat(); String mimeType = mediaFormat.getString(MediaFormat.KEY_MIME); long durationUs = track.getDurationUs(); String language = track.getLanguage(); TrackRepresentation representation = null; if (trackType == TrackType.AUDIO) { int channelCount = mediaFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT); int sampleRate = mediaFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE); representation = new AudioTrackRepresentation(-1, channelCount, "", sampleRate); } else if (trackType == TrackType.VIDEO) { int width = mediaFormat.getInteger(MediaFormat.KEY_WIDTH); int height = mediaFormat.getInteger(MediaFormat.KEY_HEIGHT); representation = new VideoTrackRepresentation(-1, width, height, -1f); } else { // SUBTITLE, UNKNOWN representation = new TrackRepresentation(-1); }//from ww w . j a v a 2s . c o m TrackInfo trackInfo = new TrackInfo(trackType, mimeType, durationUs, language); TrackRepresentation[] representations = new TrackRepresentation[1]; representations[0] = representation; trackInfo.setRepresentations(representations); trackInfos[i] = trackInfo; } else { trackInfos[i] = new TrackInfo(TrackType.UNKNOWN, "", 0, ""); } } return trackInfos; }