简体   繁体   English

带有H264 .MP4的Android 2.2 VideoView“对不起,无法播放视频”

[英]Android 2.2 VideoView “Sorry, Video cannot be played” with H264 .MP4

I have an Activity that plays progressively streaming videos and is coded as follows: 我有一个“活动”,它会逐渐播放流式视频,其编码如下:

Layout 布局

<?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>

Activity 活动

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();
            }
        } );
    }    
}

This works fine on most devices, however my client has two devices, one is a samsung galaxy ace running 2.2. 在大多数设备上都可以正常工作,但是我的客户端有两个设备,一个是运行2.2的三星银河王牌。 And the other one is a ideos U8150 (running 2.2), videos will not play on these two devices. 另外一个是ideos U8150(运行2.2),视频将无法在这两个设备上播放。 The ideos has an error that pops up and says "Sorry, this video cannot be played" while the audio plays in the background and the samsung just has the same error, however when plugged into ddms the only output that may indicate an error is: ideos会弹出一个错误,提示“抱歉,无法播放此视频”,而音频在后台播放,并且三星也有相同的错误,但是当插入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.

I have encoded the videos in H264+AAC using the settings described here: http://developer.android.com/guide/appendix/media-formats.html and made sure the moov atoms are in the righ place with qt-fastart etc. See: http://www.sciencelearn.org.nz/content/download/7366/430467/version/14/file/08-future-of-radio-telescopes-sllg-ws.mp4 我已使用此处描述的设置将视频编码为H264 + AAC: http//developer.android.com/guide/appendix/media-formats.html ,并确保使用qt-fastart等将moov原子置于正确的位置请参阅: http : //www.sciencelearn.org.nz/content/download/7366/430467/version/14/file/08-future-of-radio-telescopes-sllg-ws.mp4

The videos play fine on 2.3.3, Motorola Xoom, Galaxy S, Galaxy Tab & HTC Desire. 这些视频可以在2.3.3,摩托罗拉Xoom,Galaxy S,Galaxy Tab和HTC Desire上正常播放。 Any Ideas? 有任何想法吗?

Refer the default video codec support for android, http://developer.android.com/guide/appendix/media-formats.html , H.263 MPEG-4 (.mp4), is a good choice for 2.2 devices,,, 请参阅Android的默认视频编解码器支持, http://developer.android.com/guide/appendix/media-formats.html,H.263 MPEG-4(.mp4),对于2.2设备来说是一个不错的选择,

Or for alternatives refer question : FFmpeg on Android 或替代方法,请参阅问题: Android上的FFmpeg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM