Android视频质量在使用Vitamio Library的电视盒上非常糟糕

时间:2013-10-26 10:55:48

标签: android video video-streaming android-videoview vitamio

通过为实时流媒体实施Vitamio库,努力为G-Box提供更好的质量。

代码中使用了.mp4视频的示例在线视频网址。但是当我们在下载后在媒体播放器中播放它工作正常并且当我通过在线流媒体尝试它时质量变得非常差。

以下是在视频上播放视频的代码。

 public class VideoViewDemo extends Activity {

/**
 * TODO: Set the path variable to a streaming video URL or a local media file
 * path.
 */
private String path = "";
private VideoView mVideoView;
private ProgressDialog progDailog;
ProgressDialog progressDialog=null;

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (!LibsChecker.checkVitamioLibs(this))
        return;
    setContentView(R.layout.videoview);
    mVideoView = (VideoView) findViewById(R.id.surface_view);
    path = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
    if (path == "") {

        // Tell the user to provide a media file URL/path.
        Toast.makeText(VideoViewDemo.this, "Please edit
                     VideoViewDemo                Activity, and set path" + 
                " variable to your media file URL/path", Toast.LENGTH_LONG).show();
        return;
    } else {
        /*
         * Alternatively,for streaming media you can use
         * mVideoView.setVideoURI(Uri.parse(URLstring));
         */
        mVideoView.setVideoPath(path);
        mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
        mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();

        progDailog = ProgressDialog.show(this, "Please wait ...", 
           "Retrieving data ...", true);
        progDailog.setCancelable(true);


        mVideoView.setOnPreparedListener(
                new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                // optional need Vitamio 4.0
                //mediaPlayer.setPlaybackSpeed(1.0f);
                  progDailog.dismiss();
            }
        });

        mVideoView.setOnBufferingUpdateListener(
                   new OnBufferingUpdateListener() {
            @Override
            public void onBufferingUpdate(MediaPlayer arg0, int arg1) {

            }
        });
        //mediaPlayer.setPlaybackSpeed(1.0f);
    }

}
@Override
protected void onPause() {
    mVideoView.pause();
    super.onPause();
}

@Override
protected void onResume() {
    mVideoView.resume();
    progDailog.show();
    super.onResume();

}
   }

您的即时回复将对我有很大帮助

2 个答案:

答案 0 :(得分:2)

毫无疑问,Vitamio是一个非常好的图书馆,涵盖了与视频流有关的所有错误。

很抱歉,但我对Vitamio支持团队非常失望。我在论坛上发布了这个问题但没有收到并反馈。 最后,我通过在提供的源上进行矿工更改找到了我的问题的解决方案。

enter code here@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    if (!LibsChecker.checkVitamioLibs(this))
        return;
    setContentView(R.layout.mediaplayer_2);
    mPreview = (SurfaceView) findViewById(R.id.surface);
    holder = mPreview.getHolder();
    holder.addCallback(this);
    //holder.setFormat(PixelFormat.RGBA_8888);
    holder.setFormat(PixelFormat.RGBX_8888);
    extras = getIntent().getExtras();
}

private void playVideo(Integer Media) {
    doCleanUp();
    Log.e(TAG, "Value Received: " + Media);
    try {

        switch (Media) {
        case LOCAL_VIDEO:
            /*
             * TODO: Set the path variable to a local media file path.
             */
            path = "";
 path = Environment.getExternalStorageDirectory() + "/big_buck_bunny.mp4";
            Log.e(TAG, "PATH = : " + path);
            if (path == "") {
                // Tell the user to provide a media file URL.
Toast.makeText(MediaPlayerDemo_Video.this, "Please edit MediaPlayerDemo_Video 
   Activity, " + "and set the path variable to your media file path." 
   + " Your media file must be stored on sdcard.", Toast.LENGTH_LONG).show();
                return;
            }
            break;
        case STREAM_VIDEO:
            /*
             * TODO: Set path variable to progressive streamable mp4 or
             * 3gpp format URL. Http protocol should be used.
             * Mediaplayer can only play "progressive streamable
         * contents" which basically means: 1. the movie atom has to
             * precede all the media data atoms. 2. The clip has to be
             * reasonably interleaved.
             * 
             */
            path = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
            if (path == "") {
                // Tell the user to provide a media file URL.
Toast.makeText(MediaPlayerDemo_Video.this, "Please edit MediaPlayerDemo_Video 
    Activity," + " and set the path variable to your media file URL.", 
   Toast.LENGTH_LONG).show();
                return;
            }

            break;

        }
        // Create a new media player and set the listeners

        mMediaPlayer = new MediaPlayer(this);
mMediaPlayer.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);            
        mMediaPlayer.setDataSource(path);
        mMediaPlayer.setDisplay(holder);
    mMediaPlayer.prepare();                         
        mMediaPlayer.setOnBufferingUpdateListener(this);
        mMediaPlayer.setOnCompletionListener(this);
        mMediaPlayer.setOnPreparedListener(this);
        mMediaPlayer.setOnVideoSizeChangedListener(this);
        mMediaPlayer.getMetadata();
        setVolumeControlStream  
 (AudioManager.STREAM_MUSIC);           
        //mMediaPlayer.setVideoQuality
 (io.vov.vitamio.MediaPlayer.VIDEOQUALITY_HIGH);


    } catch (Exception e) {
        Log.e(TAG, "error: " + e.getMessage(), e);
    }
}

示例源中有一个名为“MediaPlayerDemo_Video.java”的文件 替换以下行 holder.setFormat(PixelFormat.RGBA_8888);

以下

holder.setFormat(PixelFormat.RGBX_8888);

这将解决整个问题。

答案 1 :(得分:2)

我使用此库视频质量低视频和播放模糊视频。现在我在我的视频播放器类中使用了以下方法。加载视频网址后,您可以使用此方法。

public void init() {
    load = (ProgressBar) this.findViewById(R.id.load);
    empty = (TextView) this.findViewById(R.id.empty);

    mVideoView = (VideoView) this.findViewById(R.id.surface_view);
    mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);

    holder = mVideoView.getHolder();
    holder.setFormat(PixelFormat.RGBX_8888);

    mVideoView.setMediaController(new MediaController(this));
    mVideoView.setOnCompletionListener(this);
    mVideoView.setOnPreparedListener(this);
    mVideoView.setOnErrorListener(this);

    Uri videoUri = Uri.parse(url);

    mVideoView.setVideoURI(videoUri);
    mVideoView.requestFocus();

    loading();
}