0

미디어 레코더가있는 surfaceview을 사용하여 비디오를 녹화 중입니다. 녹음 중이지만 표시 각도가 90도 시프트되어 실제 실내 기록과 다릅니다. 즉, 내 앱으로 실내를 녹화하는 경우 디스플레이는 90 학위가 바뀌었고, 방 천장이 왼쪽에 있으므로 방이 나옵니다. 어느 누구도이 문제를 해결하여 직각 비디오로 녹화 할 수 있도록 도와줍니다. 여기 내 코드는표면 뷰 비디오 레코딩에서 각도를 변경하는 방법은 무엇입니까?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
<SurfaceView 
    android:id="@+id/videoview" 
    android:layout_height="480px" android:layout_width="248dp"/> 
<Button 
    android:id="@+id/mybutton" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="REC" 
    android:textSize="12dp"/> 
</RelativeLayout>` 
여기

`
내 매니페스트 파일

<application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".SurfaceAngleRecActivity" 
        android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

    </application> 
</manifest>` 


이다 '여기 여기 내 코딩
main.xml에 확인하시기 바랍니다 참조 용입니다 내 코드 :

SurfaceAngleRecActivity.java           
public class SurfaceAngleRecActivity extends Activity implements SurfaceHolder.Callback 
     { 
     MediaRecorder mediaRecorder; 
     SurfaceHolder surfaceHolder; 
     boolean recording; 
     Button record; 
     MediaPlayer mediaPlayer; 
    boolean pausing = false; 

     String PlayPath ="/sdcard/myvideo.mp4"; 
     /** Called when the activity is first created. */ 
     @Override 
     public void onCreate(Bundle savedInstanceState) 
     { 
      super.onCreate(savedInstanceState); 
      mediaRecorder = new MediaRecorder(); 
      initMediaRecorder(); 

      setContentView(R.layout.main); 
      recording = false; 


      SurfaceView myVideoView = (SurfaceView)findViewById(R.id.videoview); 
      surfaceHolder = myVideoView.getHolder(); 
      surfaceHolder.addCallback(this); 
      surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); 

      record=(Button)findViewById(R.id.mybutton); 

      record.setOnClickListener(new OnClickListener() { 

     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      if(!recording) 
       { 
        mediaRecorder.start(); 
        recording = true; 
        //Stop.setVisibility(View.VISIBLE); 
        //Record.setVisibility(View.INVISIBLE); 
        record.setText("STOP"); 
        //Play.setEnabled(false); 
        //Pause.setEnabled(false); 
       }else 
       { 
        mediaRecorder.stop(); 
        mediaRecorder.release(); 
        recording = false; 
        //Record.setVisibility(View.VISIBLE); 
        //Stop.setVisibility(View.INVISIBLE); 
        //Record.setText("Record"); 
        //Play.setEnabled(true); 
        //Pause.setEnabled(true); 
        // finish(); 
        } 
      } 
     }); 

     } 

     public void surfaceChanged(SurfaceHolder holder, int format, int width, 
      int height) { 
     // TODO Auto-generated method stub 

     } 
     public void surfaceCreated(SurfaceHolder holder) { 
      // TODO Auto-generated method stub 
      prepareMediaRecorder(); 
     } 
     public void surfaceDestroyed(SurfaceHolder holder) { 
      // TODO Auto-generated method stub 

     } 
     private void initMediaRecorder() 
      { 
       mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT); 
       mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); 
       //File file=new File(Environment.getExternalStorageDirectory(), PlayPath); 
       CamcorderProfile camcorderProfile_HQ =CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); 
       mediaRecorder.setProfile(camcorderProfile_HQ); 
       mediaRecorder.setOutputFile("/sdcard/myvideo.mp4"); 
       //mediaRecorder.setVideoSize(20, 20); 
       //mediaRecorder.setMaxDuration(60000); // Set max duration 60 sec. 
      //mediaRecorder.setMaxFileSize(5000000); // Set max file size 5M 
      } 

      private void prepareMediaRecorder() 
      { 
       mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface()); 
       try 
       { 
        mediaRecorder.prepare(); 
        //mediaRecorder.setVideoSize(150, 200); 
       } 
       catch (IllegalStateException e) 
       { 
        //TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 
       catch (IOException e) 
       { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 
      } 

     }` 

답변

0

행동의 방향을 매니페스트에서 가로 방향으로 변경하십시오.

<application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".SurfaceAngleRecActivity" android:screenOrientation="landscape" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>

0
private void initMediaRecorder() 
      { 
       mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT); 
       mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); 
       //File file=new File(Environment.getExternalStorageDirectory(), PlayPath); 
       CamcorderProfile camcorderProfile_HQ =CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); 
       mediaRecorder.setProfile(camcorderProfile_HQ); 
       mediaRecorder.setOutputFile("/sdcard/myvideo.mp4"); 
       **mediaRecorder.setOrientationHint(90);** 
      } 
+0

http://developer.android.com/reference/android/media/MediaRecorder.html#setOrientationHint(int) –

관련 문제