Video rotation correction Author : Fred Hsu Date : 2011/08/31
Problem Statement <ul><li>Video player does not support auto rotation according to sensor. </li></ul><ul><li>Video player ...
Remove fixed orientation of layout <ul><li>Marvell provides a fixed layout screen orientation on video player of Gallery3D...
Result <ul><li>0 degree  </li></ul>Control Bar A A Portrait 90 degree  270 degree  Landscape Reverse Landscape Control Bar...
Rotation compensation <ul><li>Check recorder files :  The three orientations are the same as previous page shows. </li></u...
First stage : trace video recorder rotation parameter <ul><li>Android provides a MediaRecorder object for video/audio reco...
MediaRecorder setOrientationHint flow Java MediaRecorder Jni android_media_MediaRecorder Framework MediaRecorder IPC Frame...
Check composition matrix(1) <ul><li>MP4 file standard defines a composition matrix, order { a, b, u, c, d, v, x, y, w } </...
Check composition matrix(2) <ul><li>90 degree : a = 0x00000000, b = 0x00010000, c = 0xFFFF0000,  d = 0x00000000 (Recorded ...
Second stage : trace video player rotation parameter(1) <ul><li>Video player create flow: </li></ul><ul><li>Trace the vide...
Second stage : trace video player rotation parameter(2) StagefrightPlayer 3gp file header composition matrix libstagefrigh...
Q & A
Upcoming SlideShare
Loading in...5
×

Video rotation correction

5,670

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,670
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
36
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Video rotation correction

  1. 1. Video rotation correction Author : Fred Hsu Date : 2011/08/31
  2. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 12. Q & A
  1. Gostou de algum slide específico?

    Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

×