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

发布于 12-02 17:23 字数 2806 浏览 2 评论 0原文

我有一个渐进播放流媒体视频的活动,编码如下:

布局

<?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。另一台是ideos U8150(运行2.2),视频无法在这两台设备上播放。 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.

我已使用此处描述的设置对 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、Motorola Xoom、Galaxy S、Galaxy Tab 和 2.3.3 上正常播放。 HTC 欲望。有什么想法吗?

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. And the other one is a ideos U8150 (running 2.2), videos will not play on these two devices. 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:

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

The videos play fine on 2.3.3, Motorola Xoom, Galaxy S, Galaxy Tab & HTC Desire. Any Ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱给你人给你2024-12-09 17:23:29

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

或者替代方案参考问题:
Android 上的 FFmpeg

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

Or for alternatives refer question :
FFmpeg on Android

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文