Android 2.2 VideoView "Sorry, Video cannot be played"与 H264 .MP4

标签 android h.264 android-videoview

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

布局

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

这在大多数设备上都能正常工作,但是我的客户端有两台设备,一台是运行 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并使用 qt-fastart 等确保 moov 原子位于正确的位置。参见: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 和 HTC Desire 上播放良好。有什么想法吗?

最佳答案

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

或者对于替代品,请引用问题: FFmpeg on Android

关于Android 2.2 VideoView "Sorry, Video cannot be played"与 H264 .MP4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7305503/

相关文章:

android - opengl es,glActiveTexture时出错

android - react native 矢量图标显示为问号

c - GStreamer 1.0 在 C 中将原始编码为 H.264

ffmpeg - 使用ffmpeg从mp4文件中解复用音频(AMR_WB)和视频(H264)

Android 透明 WebView 在 VideoView 之上

java - 从Java服务器发送图像到android客户端

java - 设置 CountDownTimer 来运行 onDestroy() 的正确方法是什么?

video - 手动编码为 MPEG-TS

java - 无法在videoview android中播放来自url的视频

android - TrafficStats.getTotalRxBytes 不统计视频观看流量