Can't run live stream using Vitamio

我怕爱的太早我们不能终老 提交于 2020-01-21 14:39:11

问题


I'm trying to use Vitamio to run RTSP video stream, I'm using Vitamio-sample after updating it to run the stream through VideoViewDemo activity:

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

}

But after running it, it only run for a very little time(which gives me only the first video frame [a fixed photo] ) and then the app crashes and give me app not responding message without printing any error messages in the log:

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)

And later in the log I got the following message:

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()

回答1:


After scanning a lot of near similar problems, I figured that it's may be because it demands to has ACCESS_NETWORK_STATE permission, although the log didn't tell me that but as it tells me it's not a qualified user to perform this process which means the user must be given the permission to be qualified for that, So, I added this permission:

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

So, to run an authorized RTSP live stream using Vitamio, you need to register all of the following permissions:

    <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" />



回答2:


I had a problem where I was unable to stream RTSP even I removed the Authuntication like Username and Password. So I can Access the link Directly. What Things Work for Me to Stream LIVE were:

1st Make Sure That You Have Registered the Permissions.

<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" />

2nd I gave the Streaming Link as:

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

Remember I removed the Username and Password for RTSP Links in My IP Camera Settings.

3rd: Important thing that worked for me was:

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.

Hope This might be helpful.



来源:https://stackoverflow.com/questions/31789244/cant-run-live-stream-using-vitamio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!