天天看點

android 無法播放此視訊格式,Android MediaPlayer錯誤無法播放此視訊

我正在開發用于視訊錄制的自定義相機應用.錄制的視訊存儲在SD卡上.

該代碼适用于所有裝置,除了T-Mobile S3(SGH-T999

android v 4.1.2),我得到’無法播放此視訊’錯誤.我已經研究了很多這個問題,嘗試改變參數但仍然無法解決.

W/VideoView( 4490): Unable to open content: /storage/sdcard0/MyCameraApp/VID_20140807_130327.ogg

W/VideoView( 4490): java.io.IOException: setDataSourceFD failed.: status=0x80000000

W/VideoView( 4490): at android.media.MediaPlayer.setDataSource(Native Method)

W/VideoView( 4490): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1204)

W/VideoView( 4490): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1175)

W/VideoView( 4490): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1121)

W/VideoView( 4490): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:953)

W/VideoView( 4490): at android.widget.VideoView.openVideo(VideoView.java:249)

W/VideoView( 4490): at android.widget.VideoView.access$2000(VideoView.java:51)

W/VideoView( 4490): at android.widget.VideoView$6.surfaceCreated(VideoView.java:492)

W/VideoView( 4490): at android.view.SurfaceView.updateWindow(SurfaceView.java:609)

W/VideoView( 4490): at android.view.SurfaceView.access$000(SurfaceView.java:86)

W/VideoView( 4490): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:178)

W/VideoView( 4490): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:707)

W/VideoView( 4490): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1955)

W/VideoView( 4490): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1119)

W/VideoView( 4490): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4553)

W/VideoView( 4490): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)

W/VideoView( 4490): at android.view.Choreographer.doCallbacks(Choreographer.java:555)

W/VideoView( 4490): at android.view.Choreographer.doFrame(Choreographer.java:525)

W/VideoView( 4490): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)

W/VideoView( 4490): at android.os.Handler.handleCallback(Handler.java:615)

W/VideoView( 4490): at android.os.Handler.dispatchMessage(Handler.java:92)

W/VideoView( 4490): at android.os.Looper.loop(Looper.java:137)

W/VideoView( 4490): at android.app.ActivityThread.main(ActivityThread.java:4950)

W/VideoView( 4490): at java.lang.reflect.Method.invokeNative(Native Method)

W/VideoView( 4490): at java.lang.reflect.Method.invoke(Method.java:511)

W/VideoView( 4490): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)

W/VideoView( 4490): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)

W/VideoView( 4490): at dalvik.system.NativeStart.main(Native Method)

D/VideoView( 4490): Error: 1,0

V/MediaPlayerService( 187): Client(13) destructor pid = 4490

I/AudioSink( 187): +++ close

I/AudioSink( 187): --- close

V/AudioSink( 187): closeSession

V/MediaPlayerService( 187): disconnect(13) from pid 4490

代碼段.

CamcorderProfile camcorderProfile=CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);

camcorderProfile.videoFrameWidth = width;

camcorderProfile.videoFrameHeight = ht;

camcorderProfile.videoCodec = MediaRecorder.VideoEncoder.H264;

camcorderProfile.audioCodec = MediaRecorder.AudioEncoder.AMR_NB;

camcorderProfile.fileFormat = MediaRecorder.OutputFormat.MPEG_4;

mMediaRecorder.setProfile(camcorderProfile);

mMediaRecorder.setAudioEncoder(AudioEncoder.AMR_NB);

mMediaRecorder.setOutputFormat(OutputFormat.MPEG_4);

mMediaRecorder.setVideoEncoder(VideoEncoder.MPEG_4_SP);

mMediaRecorder.setVideoSize(width, ht);

提前緻謝.