CarGuo / GSYVideoPlayer

视频播放器(IJKplayer、ExoPlayer、MediaPlayer),HTTPS,16k page size,支持弹幕,外挂字幕,支持滤镜、水印、gif截图,片头广告、中间广告,多个同时播放,支持基本的拖动,声音、亮度调节,支持边播边缓存,支持视频自带rotation的旋转(90,270之类),重力旋转与手动旋转的同步支持,支持列表播放 ,列表全屏动画,视频加载速度,列表小窗口支持拖动,动画效果,调整比例,多分辨率切换,支持切换播放器,进度条小窗口预览,列表切换详情页面无缝播放,rtsp、concat、mpeg。
https://juejin.cn/user/817692379985752/posts
Apache License 2.0
20.06k stars 4.18k forks source link

Rtsp 播放 报错 E Option ijkapplication not found. #3894

Closed ifnk closed 9 months ago

ifnk commented 9 months ago

(!!!!请务必务必按照issue模板,修改 后提交问题!!!!,不按模板提Isuue删除处理)

(ps 首页问题集锦和demo请先了解一下!)

⚠️提问前建议先看看: https://mp.weixin.qq.com/s/HjSdmAsHuvixCH_EWdvk3Q

问题描述:

⚠️vlc 可以播放 流地址 ,但是我 用 gsyVideoPlayer 播放 报错 Option ijkapplication not found.

出现问题的视频流

我用的局域网的海康摄像头 rtsp://admin:admin123456@192.168.1.69:554/Streaming/Channels/101

问题机型/系统:

安卓 studio 的 安卓虚拟机 pixel 3a api 34 exensions level 7 x86 64

GSY依赖版本

implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-java:v8.5.0-release-jitpack'

//是否需要ExoPlayer模式
implementation 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer-exo2:v8.5.0-release-jitpack'

//是否需要AliPlayer模式
implementation 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer-aliplay:v8.5.0-release-jitpack'

//根据你的需求ijk模式的so
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-ex_so:v8.1.9-release-jitpack'

Demo中的复现步骤

我是自己新开的 empty activity

问题代码:(如果有)

MainActivity.kt

package com.example.testandroidapp

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.example.testandroidapp.ui.theme.TestandroidappTheme
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            TestandroidappTheme {
//                PlayerView(Modifier.fillMaxSize())
                GSYVideoPlayerView(Modifier.fillMaxSize(),"rtsp://admin:admin123456@192.168.1.69:554/Streaming/Channels/101")
            }
        }
    }
}
@Composable
fun GSYVideoPlayerView(modifier: Modifier = Modifier, videoUrl: String) {
    AndroidView(
        modifier = modifier,
        factory = { context ->
            StandardGSYVideoPlayer(context).apply {
                setUp(videoUrl, true, "测试视频")
                startPlayLogic()
            }
        },
        update = { player ->
            player.setUp(videoUrl, true, "测试视频")
            player.startPlayLogic()
        }
    )
}

build.gradle : app

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.example.testandroidapp'
    compileSdk 34

    defaultConfig {
        applicationId "com.example.testandroidapp"
        minSdk 34
        targetSdk 34
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.4.3'
    }
    packaging {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
    implementation 'androidx.activity:activity-compose:1.8.1'
    implementation platform('androidx.compose:compose-bom:2023.03.00')
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-graphics'
    implementation 'androidx.compose.ui:ui-tooling-preview'
    implementation 'androidx.compose.material3:material3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation platform('androidx.compose:compose-bom:2023.03.00')
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
    debugImplementation 'androidx.compose.ui:ui-tooling'
    debugImplementation 'androidx.compose.ui:ui-test-manifest'

    implementation 'com.github.NodeMedia:NodeMediaClient-Android:3.1.16'

    implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-java:v8.5.0-release-jitpack'

    //是否需要ExoPlayer模式
    implementation 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer-exo2:v8.5.0-release-jitpack'

    //是否需要AliPlayer模式
    implementation 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer-aliplay:v8.5.0-release-jitpack'

    //根据你的需求ijk模式的so
    implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-ex_so:v8.1.9-release-jitpack'

}

settings.gradle

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        maven { url "https://maven.aliyun.com/repository/public" }
    }
}

rootProject.name = "testandroidapp"
include ':app'

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.1.4' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Testandroidapp"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.Testandroidapp">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

问题log(如果有)

2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  line='RTP-Info: url=rtsp://192.168.1.69:554/Streaming/Channels/101/trackID=1;seq=52504;rtptime=2989259960'
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=44 [D]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=61 [a]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=74 [t]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=65 [e]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=3a [:]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=20 [ ]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=20 [ ]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=54 [T]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=68 [h]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=75 [u]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=2c [,]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=20 [ ]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=4e [N]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=6f [o]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=76 [v]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=20 [ ]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=32 [2]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=33 [3]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=20 [ ]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=32 [2]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=30 [0]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=32 [2]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=33 [3]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=20 [ ]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=30 [0]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=30 [0]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=3a [:]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=32 [2]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=32 [2]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=3a [:]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=32 [2]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=38 [8]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=20 [ ]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=47 [G]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=4d [M]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=54 [T]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=0d []
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=0a [
                                                                                                    ]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  line='Date:  Thu, Nov 23 2023 00:22:28 GMT'
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=0d []
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  ret=1 c=0a [
                                                                                                    ]
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           V  line=''
2023-11-23 00:22:26.364 12745-12981 IJKMEDIA                com.example.testandroidapp           E  Option ijkapplication not found.

看起来 rtsp流是能解析的, 但是 就是报错 Option ijkapplication not found. 导致无法播放 ,我按照 文档 已经配置了

    implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-ex_so:v8.5.0-release-jitpack'
CarGuo commented 9 months ago

Option ijkapplication not found. 不是错误,可以配置下文档的 tcp 看看

ifnk commented 9 months ago

Option ijkapplication not found. 不是错误,可以配置下文档的 tcp 看看

哇, 可以 了, 现在能播了, 谢谢作者 这是我的 mainActivity代码

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.example.myapplication.ui.theme.MyApplicationTheme
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.shuyu.gsyvideoplayer.model.VideoOptionModel
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
import tv.danmaku.ijk.media.player.IjkMediaPlayer

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MyApplicationTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    GSYVideoPlayerView(
                        Modifier.fillMaxSize(),
                        "rtsp://admin:admin123456@192.168.1.69:554/Streaming/Channels/101"
                    )
                }
            }
        }
    }
}

@Composable
fun GSYVideoPlayerView(modifier: Modifier = Modifier, videoUrl: String) {
    AndroidView(
        modifier = modifier,
        factory = { context ->
            val videoOptionModel =
                VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp")
            val list: MutableList<VideoOptionModel> = ArrayList()
            list.add(videoOptionModel)
            GSYVideoManager.instance().optionModelList = list;

            StandardGSYVideoPlayer(context).apply {
                setUp(videoUrl, true, "测试视频")
                startPlayLogic()
            }
        },
        update = { player ->
            player.setUp(videoUrl, true, "测试视频")
            player.startPlayLogic()
        }
    )
}

是加了这几行 就可以 了

            val videoOptionModel =
                VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp")
            val list: MutableList<VideoOptionModel> = ArrayList()
            list.add(videoOptionModel)
            GSYVideoManager.instance().optionModelList = list;

参考文档是这个 https://github.com/CarGuo/GSYVideoPlayer/blob/master/doc/QUESTION.md 第17 条