使用H264 .MP4的Android 2.2 VideoView“抱歉,无法播放视频”

时间:2011-09-05 08:22:07

标签: android h.264 android-videoview

我有一个逐步播放视频流的活动,编码如下:

布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <VideoView android:id="@+id/myVideo"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:layout_gravity="center"/>
</LinearLayout>

活动

public class PlayVideo extends Activity {

    public ProgressDialog progressDialog;

    /** Called when the activity is first created. */
    @Override
    public void onCreate( Bundle savedInstanceState ) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.video );
        progressDialog = ProgressDialog.show( this, "", "Loading...", true );
        Intent i = getIntent();
        startVideo( i.getStringExtra( "videoUrl" ) );
    }

    public void startVideo( String videoUrl ) {
        final VideoView videoView = ( VideoView ) findViewById( R.id.myVideo );

        videoView.setMediaController( new MediaController( this ) );
        videoView.setVideoURI( Uri.parse( videoUrl ) );

        videoView.setOnPreparedListener( new OnPreparedListener() {
            public void onPrepared( MediaPlayer arg0 ) {
                progressDialog.dismiss();
                videoView.requestFocus();
                videoView.start();
            }
        } );
    }    
}

这在大多数设备上运行良好,但是我的客户端有两个设备,一个是运行2.2的三星Galaxy ace。而另一个是意识形态U8150(运行2.2),视频将无法在这两个设备上播放。当音频在后台播放并且三星只有相同的错误时,意识形态会弹出错误并显示“抱歉,此视频无法播放”,但插入ddms时,唯一可能表示错误的输出是:

09-05 15:11:03.461: ERROR/QCvdec(95): Omx Flush issued when vdec is not initialized yet.
09-05 15:11:03.461: ERROR/QCvdec(95): Unsupported profile, level, or widht, height
09-05 15:11:03.461: ERROR/QCvdec(95): Unsupported clip
09-05 15:11:03.461: ERROR/QCvdec(95): Omx Flush issued when vdec is not initialized yet.
09-05 15:11:03.461: ERROR/QCvdec(95): Empty this buffer in Invalid State
09-05 15:11:03.461: ERROR/QCvdec(95): Omx Flush issued when vdec is not initialized yet.

我使用此处描述的设置在H264 + AAC中对视频进行编码:http://developer.android.com/guide/appendix/media-formats.html并确保moov原子位于qt-fastart等的右侧。请参阅:http://www.sciencelearn.org.nz/content/download/7366/430467/version/14/file/08-future-of-radio-telescopes-sllg-ws.mp4

视频播放在2.3.3,摩托罗拉Xoom,Galaxy S,Galaxy Tab&amp; HTC Desire。任何想法?

1 个答案:

答案 0 :(得分:1)

参考android的默认视频编解码器支持,http://developer.android.com/guide/appendix/media-formats.html, H.263 MPEG-4(.mp4)是2.2设备的理想选择,,,

或者对于替代品,请参考问题: FFmpeg on Android

相关问题