Your SlideShare is downloading. ×
0
Video rotation correction
Video rotation correction
Video rotation correction
Video rotation correction
Video rotation correction
Video rotation correction
Video rotation correction
Video rotation correction
Video rotation correction
Video rotation correction
Video rotation correction
Video rotation correction
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Video rotation correction

5,569

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
5,569
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Video rotation correction Author : Fred Hsu Date : 2011/08/31
  • 2. Problem Statement <ul><li>Video player does not support auto rotation according to sensor. </li></ul><ul><li>Video player shows different orientation from our video recorder. </li></ul>Control Bar A Recorded as portrait style
  • 3. Remove fixed orientation of layout <ul><li>Marvell provides a fixed layout screen orientation on video player of Gallery3D app. </li></ul><ul><li>Remove fixed orientation video player of Gallery3D app AndroidManifest.xml </li></ul><ul><ul><li><activity … android:screenOrientation=&quot;landscape&quot; > … </activity> </li></ul></ul>
  • 4. Result <ul><li>0 degree </li></ul>Control Bar A A Portrait 90 degree 270 degree Landscape Reverse Landscape Control Bar A Control Bar
  • 5. Rotation compensation <ul><li>Check recorder files : The three orientations are the same as previous page shows. </li></ul><ul><li>We need to do a rotation compensation for video player. </li></ul>
  • 6. First stage : trace video recorder rotation parameter <ul><li>Android provides a MediaRecorder object for video/audio recording usage. </li></ul><ul><li>MediaRecorder. setOrientationHint method set the rotation degrees to recorded file. </li></ul><ul><li>Android developer website : </li></ul><ul><ul><li>This method will not trigger the source video frame to rotate during video recording, but to add a composition matrix containing the rotation angle in the output video if the output format is OutputFormat.THREE_GPP or OutputFormat.MPEG_4 so that a video player can choose the proper orientation for playback. </li></ul></ul>
  • 7. MediaRecorder setOrientationHint flow Java MediaRecorder Jni android_media_MediaRecorder Framework MediaRecorder IPC Framework IMediaRecorder Framework MediaRecorderClient Framework StagefrightRecorder Store rotation degrees MPEG4Writer Convert to Composition matrix
  • 8. Check composition matrix(1) <ul><li>MP4 file standard defines a composition matrix, order { a, b, u, c, d, v, x, y, w } </li></ul><ul><li>| a b u | </li></ul><ul><li>| c d v | </li></ul><ul><li>| x y w | </li></ul><ul><li>0 degree : a = 0x00010000, b = 0x00000000, c = 0x00000000, d = 0x00010000 (Recorded as landscape) </li></ul>
  • 9. Check composition matrix(2) <ul><li>90 degree : a = 0x00000000, b = 0x00010000, c = 0xFFFF0000, d = 0x00000000 (Recorded as portrait) </li></ul><ul><li>270 degree : a = 0xFFFF0000, b = 0x00000000, c = 0x00000000, d = 0xFFFF0000 (Recorded as reverse-landscape) </li></ul>
  • 10. Second stage : trace video player rotation parameter(1) <ul><li>Video player create flow: </li></ul><ul><li>Trace the video player (Here we use StagefrightPlayer) : find out the composition matrix will get from recorded file. </li></ul>Java MediaPlayer Jni android_media_MediaPlayer Framework MediaPlayer Framework MediaPlayerService Video Player IPC
  • 11. Second stage : trace video player rotation parameter(2) StagefrightPlayer 3gp file header composition matrix libstagefrighthw Convert to degrees Create renderer with degrees Display with rotation ISurface Part of stagefright system Surface system Overlay Video Device Overlay system
  • 12. Q & A

×