我有一个活动,播放渐进式流媒体视频,编码如下:
布局<?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。另一个是video 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上播放良好;HTC欲望。什么好主意吗?
参考android的默认视频编解码器,http://developer.android.com/guide/appendix/media-formats.html,H.263 MPEG-4 (.mp4),是2.2设备的好选择…
或替代选项请参考问题:Android上的FFmpeg