google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.7k stars 6.02k forks source link

Exoplayer can't play the video after compress #10004

Closed hafiz013 closed 2 years ago

hafiz013 commented 2 years ago

We can only process bug reports that are actionable. Unclear bug reports or reports with insufficient information may not get attention.

Before filing a bug:

When reporting a bug:

Describe how the issue can be reproduced, ideally using the ExoPlayer demo app or a small sample app that you’re able to share as source code on GitHub. To increase the chance of your issue getting attention, please also include:

-After uploading file video to server and it works and can play by ios. However, exoplayer can't run it because of following below error -"implementation 'com.google.android.exoplayer:exoplayer:2.13.3' //2.16.1 implementation 'com.google.android.exoplayer:exoplayer-core:2.13.3' implementation 'com.google.android.exoplayer:exoplayer-dash:2.13.3' implementation 'com.google.android.exoplayer:exoplayer-ui:2.13.3'"

Third party library to compress : implementation 'com.github.ankitbatra11:VideoCompressor:1.0.3' but work uploading file to server and can play by ios.

Error code:

/ExoPlayerImplInternal: Disable failed. java.lang.IllegalStateException at android.media.MediaCodec.native_flush(Native Method) at android.media.MediaCodec.flush(MediaCodec.java:2297) 
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.flush(SynchronousMediaCodecAdapter.java:142) 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushCodec(MediaCodecRenderer.java:887) 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushOrReleaseCodec(MediaCodecRenderer.java:880) 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onDisabled(MediaCodecRenderer.java:741) 
at com.google.android.exoplayer2.audio.MediaCodecAudioRenderer.onDisabled(MediaCodecAudioRenderer.java:530) 
at com.google.android.exoplayer2.BaseRenderer.disable(BaseRenderer.java:175) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.disableRenderer(ExoPlayerImplInternal.java:1608) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1350) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1314) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:571) 
at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:260) 
at android.os.HandlerThread.run(HandlerThread.java:67) MediaCodec: Codec reported err 0xe, actionCode 0, while in state 6 
ExoPlayerImplInternal: Playback error com.google.android.exoplayer2.ExoPlaybackException: MediaCodecAudioRenderer error, index=1, format=Format(2, null, null, audio/mp4a-latm, mp4a.40.0, -1, en, [-1, -1, -1.0], [1, 48000]), format_supported=YES 
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:555) 
at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:260) 
at android.os.HandlerThread.run(HandlerThread.java:67) 
Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecDecoderException: Decoder failed: c2.android.aac.decoder 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.createDecoderException(MediaCodecRenderer.java:955) 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:839) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:948) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478) 
at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:260)  
at android.os.HandlerThread.run(HandlerThread.java:67)  Caused by: java.lang.IllegalStateException 
at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method) 
at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:3451) 
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex(SynchronousMediaCodecAdapter.java:82) 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1779) 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:824) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:948) 
 at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478)  
at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:260)  
at android.os.HandlerThread.run(HandlerThread.java:67) 

sample code compress video:

`val compressVideoRequest = CompressVideoRequest.Builder() .setSourceVideo(AbsoluteFilePathSourceVideo(source)) .setCompressedVideoAbsoluteFilePath(dest) .setCompressQuality(CompressQuality.LOW) .setCompressListener(object:CompressListener.DoNothingCompressListener(){ override fun onProgress(percent: Float) { super.onProgress(percent) } }) .build()

val resultCompress = VideoController.getInstance().convertVideo(compressVideoRequest)

if(resultCompress){
    var compressUri:Uri? = null
    var name:String? = null
    var length:Long? = null

    val videoFile: File = File(dest)
    compressUri = FileProvider.getUriForFile(mContext, "test.com", videoFile)
    name = videoFile.name
    length = videoFile.length().div(1024) // Size in KB

    var albumFile = AlbumFile()

    albumFile.setUri(compressUri)
    albumFile.bucketName = name ?: ""
    albumFile.mediaType = AlbumFile.TYPE_VIDEO
    albumFile.mimeType = "video/mp4"
    if (length != null) {
        albumFile.size = length
    }

    objVideo.resume(albumFile)
}`

Please help me.

christosts commented 2 years ago

Hi! Please provide complete information as requested in the issue template. The issue template can be found here. For such problems we definitely need a link to the content to test and a bugreport obtained from the device after the error occurs.

If you're unable to share bug reports or test content publicly, please send them to dev.exoplayer@gmail.com using a subject in the format "Issue #1234" ("#1234" is replaced with your issue number). Please also update this issue to indicate you've done this.

google-oss-bot commented 2 years ago

Hey @hafiz013. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@hafiz013 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.