[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only first frame and Audio Plays in Android 23 with MPEG-4 - AVC #11352

Closed
x3x0z opened this issue Nov 25, 2023 · 1 comment
Closed

Only first frame and Audio Plays in Android 23 with MPEG-4 - AVC #11352

x3x0z opened this issue Nov 25, 2023 · 1 comment

Comments

@x3x0z
Copy link
x3x0z commented Nov 25, 2023

Bug

I am developing an Android application to play Live Streams TS.
I am using FFMPEG to decode the audio, this works fine on almost all Android versions.
But in Android 23, you only hear the Audio and see the first frame of the video at the moment it was called.

Format video:
image

Output Logcat: (Red error messages also appear on mpeg2 videos but these videos do play)
image

I have added setVideoFrameMetadataListener event
and if it is being called correctly as if the frames were updated, but this is not reflected in the PlayerView.

ExoPlayer Creation:

        renderers.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER)
        val trackSelectionFactory: ExoTrackSelection.Factory = AdaptiveTrackSelection.Factory()
        val trackSelector = DefaultTrackSelector(context, trackSelectionFactory)
        exoPlayer = ExoPlayer.Builder(context, renderers).setTrackSelector(trackSelector).setLoadControl(loadControl).build()
        currentContainerPlayer = containerPlayer
        currentTvHoldSec = tvHoldOk3Sec;

        if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {

        }

        exoPlayer!!.setTrackSelectionParameters(
            exoPlayer!!.getTrackSelectionParameters()
                .buildUpon()
                .setMaxVideoSizeSd()
                .setForceLowestBitrate(true)
                .setPreferredAudioLanguage("hu")
                .build()
        )
        playerView.player = exoPlayer
        playerView.setEnabledShutterView(false)
        exoPlayer!!.setVideoFrameMetadataListener(VideoFrameMetadataListener { presentationTimeUs, releaseTimeNs, format, mediaFormat ->
       //     Log.w(TAG, "New Frame: $presentationTimeUs -- || -- ${releaseTimeNs} ---- ")
            PlayerActivity.lastFrameTimeInMillis = System.currentTimeMillis()
            if (!isReady) isReady = true
        })
         
        
        
        //// METHOD ENCHARGED TO PLAY STREAM
        
        
        val extractorsFactory = DefaultExtractorsFactory()
            .setTsExtractorFlags(DefaultTsPayloadReaderFactory.FLAG_ALLOW_NON_IDR_KEYFRAMES)
            .setConstantBitrateSeekingAlwaysEnabled(true)
        val defaultFactory = DefaultHttpDataSource.Factory()
        val token = mPreferences.getString(KEY_PREF_TOKEN_STREAM, "noToken")
        defaultFactory.setDefaultRequestProperties(mapOf("Authorization" to "Bearer $token"))
        val dataSource: DataSource.Factory = defaultFactory
    //    val uri = Uri.parse(url.trim())
        var newUrl : String = url
       // val uri = getUriConvertedToLocal(newUrl)
        val uri = Uri.parse(newUrl)
        Log.w(TAG, "**************** NEW URI:::::::::::::: $uri")
        val drmSchemeUuid: UUID = C.WIDEVINE_UUID
        val type: Int = Util.inferContentType(uri)
        var mediaSource: MediaSource? = null
        val mediaItemBuilder: MediaItem.Builder = MediaItem.Builder(
        ).setUri(uri)

        //non drm streams will be played normally - change drm here

        //non drm streams will be played normally - change drm here
        if (true) {
            mediaItemBuilder.setDrmConfiguration(
                MediaItem.DrmConfiguration.Builder(drmSchemeUuid)
                    .setLicenseUri(drmLicenseUrl).build()
            )
        }

        when (type) {
            C.TYPE_DASH -> {
                Log.i(TAG, "onStart: type dash")
                mediaSource = DashMediaSource.Factory(dataSource)
                    .createMediaSource(mediaItemBuilder.build())
            }
            C.TYPE_SS -> Log.i(TAG, "onStart: type ss")
            C.TYPE_HLS -> {
                Log.i(TAG, "onStart: type hls")
                mediaSource = HlsMediaSource.Factory(dataSource)
                    .createMediaSource(mediaItemBuilder.build())
            }
            C.TYPE_OTHER -> {
                Log.i(TAG, "onStart: type other")
                mediaSource =
                    ProgressiveMediaSource.Factory(dataSource, extractorsFactory)
                        .createMediaSource(
                            mediaItemBuilder.build()
                    )
            }
            else -> {}
        }

        mediaSource?.let { source ->
            player.playWhenReady = playWhenReady
            player.setMediaSource(source, false)
            player.prepare()
        }

        val ratio = mPreferences.getInt("ASPECT_RATIO", 3)
        setRatio(playerView, player, ratio)```



@tonihei
Copy link
Collaborator
tonihei commented Dec 6, 2023

The com.google.android.exoplayer2 project is now deprecated. We are not accepting any new issues in this project. Please file your issue in the androidx.media3 GitHub project instead: https://github.com/androidx/media/issues

Your issue also sounds very device-specific, so when you file the request, please include a bugreport in case it provides any useful information.

@tonihei tonihei closed this as completed Dec 6, 2023
@google google locked and limited conversation to collaborators Feb 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants