无法使用Vitamio

时间:2015-08-03 13:56:57

标签: android android-videoview rtsp vitamio

我尝试使用Vitamio来运行RTSP视频流,我在更新它之后使用Vitamio示例来运行通过VideoViewDemo活动的流:

public class VideoViewDemo extends Activity {

    /**
     * TODO: Set the path variable to a streaming video URL or a local media file
     * path.
     */
    private String path = "rtsp://user:password@<stream-ip>:554";
    private VideoView mVideoView;
    private EditText mEditText;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        if (!LibsChecker.checkVitamioLibs(this))
            return;
        setContentView(R.layout.videoview);
        mEditText = (EditText) findViewById(R.id.url);
        mVideoView = (VideoView) findViewById(R.id.surface_view);
        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.setMediaController(new MediaController(this));
            mVideoView.requestFocus();
            //mVideoView.setVideoURI(Uri.parse(path));

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

    }

    public void startPlay(View view) {
        String url = mEditText.getText().toString();
        path = url;
        if (!TextUtils.isEmpty(url)) {
            mVideoView.setVideoPath(url);
        }
    }

    public void openVideo(View View) {
      mVideoView.setVideoPath(path);
    }

}

但是在运行它之后,它只运行了一段时间(这只给了我第一个视频帧[一张固定的照片])然后应用程序崩溃并给我应用程序无响应消息无需在日志中打印任何错误消息:

08-03 15:45:37.224: I/Vitamio[4.2.1][Player](27585): META AUDIO: 1. und, META SUBTITLE: 
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): WOW: BRILLIANT C COUNT 4
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): OPEN STREAM AUDIO BEGIN
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): Copyright (c) YIXIA (http://yixia.com).
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): Application package name: io.vov.vitamio.demo
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): 2, 48000, 0
08-03 15:45:37.234: V/AudioPolicyManagerBase(273): getOutput() device 2, stream 3, samplingRate 0, format 0, channelMask 3, flags 0
08-03 15:45:37.234: V/AudioPolicyManagerBase(273): getOutputsForDevice device 0002 -> 0002
08-03 15:45:37.234: V/AudioPolicyManagerBase(273): getOutput() returns output 2
08-03 15:45:37.234: V/AudioPolicyManagerBase(273): getOutput() device 2, stream 3, samplingRate 0, format 0, channelMask 3, flags 0

08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): OPEN STREAM AUDIO END
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): Copyright (c) YIXIA (http://yixia.com).
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): Application package name: io.vov.vitamio.demo
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): WOW: BRILLIANT C COUNT 4
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): OPEN STREAM VIDEO BEGIN
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): OPEN STREAM VIDEO END
08-03 15:45:37.244: D/Vitamio[Player](27585): onVideoSizeChanged: (704x576)
08-03 15:45:37.244: V/audio_hw_primary(273): start_output_stream: enter: usecase(0: deep-buffer-playback) devices(0x2)
08-03 15:45:37.244: V/audio_hw_primary(273): select_devices: ENTER
08-03 15:45:37.244: V/audio_hw_primary(273): select_devices: usecase(normal)
08-03 15:45:37.244: V/audio_hw_primary(273): select_devices: usecase(PCM_PLAYBACK)
08-03 15:45:37.244: V/msm8974_platform(273): platform_get_output_snd_device: enter: output devices(0x2)
08-03 15:45:37.244: V/msm8974_platform(273): get_OUTPUT_snd_device: for Normal Playback
08-03 15:45:37.244: V/msm8974_platform(273): platform_get_output_snd_device: exit: snd_device(speaker)
08-03 15:45:37.244: D/audio_hw_primary(273): select_devices: out_snd_device(2: speaker)
08-03 15:45:37.244: D/audio_hw_primary(273): select_devices: in_snd_device(0: dummy)
08-03 15:45:37.244: V/audio_hw_primary(273): enable_snd_device: snd_device(2: speaker)
08-03 15:45:37.244: D/ACDB-LOADER(273): ACDB -> send_audio_cal, acdb_id = 15, path =  0
08-03 15:45:37.244: D/ACDB-LOADER(273): ACDB -> send_adm_topology
08-03 15:45:37.244: D/ACDB-LOADER(273): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): THREAD PREPARE DETTACHED, ret = 0
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): THREAD PREPARE END

08-03 15:45:37.254: I/Vitamio[4.2.1][Player](27585): CC: SwsScale c
08-03 15:45:37.254: V/audio_hw_primary(273): start_output_stream: Opening PCM device card_id(0) device_id(0)
08-03 15:45:37.254: D/Vitamio[Player](27585): VIDEO: 704x576x1.222222, Surface: 704x576, LP: 1080x883, Window: 1080x1920x0.562500
08-03 15:45:37.264: E/Vitamio[4.2.1][Player](27585): [h264 @ 0x783fac40] Missing reference picture, default is 0
08-03 15:45:37.264: E/Vitamio[4.2.1][Player](27585): [h264 @ 0x783fac40] decode_slice_header error


08-03 15:45:37.304: I/Vitamio[Player](27585): Info (701, 0)
08-03 15:45:37.304: D/Vitamio[Player](27585): onInfo: (701, 0)
08-03 15:45:37.354: W/dalvikvm(27585): Invalid indirect reference 0x4309aa58 in decodeIndirectRef
08-03 15:45:37.354: I/dalvikvm(27585): "Thread-26042" prio=5 tid=19 RUNNABLE
08-03 15:45:37.354: I/dalvikvm(27585):   | group="main" sCount=0 dsCount=0 obj=0x4306fca0 self=0x7b3ab4a8
08-03 15:45:37.354: I/dalvikvm(27585):   | sysTid=28521 nice=0 sched=0/0 cgrp=apps handle=2016853936
08-03 15:45:37.354: I/dalvikvm(27585):   | state=R schedstat=( 32461510 66037500 298 ) utm=2 stm=1 core=3
08-03 15:45:37.354: I/dalvikvm(27585):   at dalvik.system.NativeStart.run(Native Method)
08-03 15:45:37.354: E/dalvikvm(27585): VM aborting
08-03 15:45:37.354: A/libc(27585): Fatal signal 6 (SIGABRT) at 0x00006bc1 (code=-6), thread 28521 (ov.vitamio.demo)

稍后在日志中我收到以下消息:

08-03 15:45:37.744: W/ActivityManager(852):   Force finishing activity io.vov.vitamio.demo/.VideoViewDemo
08-03 15:45:37.754: W/ContextImpl(852): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1469 com.android.server.am.ActivityStack.startPausingLocked:1002 com.android.server.am.ActivityStack.finishActivityLocked:3147 com.android.server.am.ActivityStack.finishTopRunningActivityLocked:2994 com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked:3093 
08-03 15:45:37.764: W/ApplicationPackageManager(852): getCSCPackageItemText()

2 个答案:

答案 0 :(得分:2)

在扫描了很多near similar problems之后,我发现这可能是因为它要求获得ACCESS_NETWORK_STATE权限,虽然日志没有告诉我,但它告诉我它是不是合格的用户来执行此过程,这意味着必须授予用户相应的权限,因此,我添加了此权限:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

因此,要使用Vitamio运行授权的RTSP直播,您需要注册以下所有权限:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

答案 1 :(得分:1)

我遇到了一个问题,我无法流式传输RTSP,即使我删除了用户名和密码等自动身份验证。所以我可以直接访问链接。 流向LIVE工作的事情是:

确保您已注册权限。

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

第二,我把流媒体链接作为:

rtsp://192.xxx.x.xx/h264 OR rtsp://192.111.1.1/h264 ( example )

请记住,我在“我的IP摄像机设置”中删除了RTSP链接的用户名和密码。

第三:对我有用的重要事情是:

Open build.gradle of your app
change targedsdkversion to 22
Open build.gradle of your Vitamio:module
change targedsdkversion to 22
It may sound weird but it worked for me like a charm.

希望这可能会有所帮助。