TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
31.56k stars 3.07k forks source link

Decoding error when starting some videos on 2x tempo #8953

Open amarzot opened 2 years ago

amarzot commented 2 years ago

Checklist

Affected version

0.23.3

Steps to reproduce the bug

  1. Start playing a video.
  2. Change the tempo to 2x.
  3. Close the video.
  4. Try to open the video again.

Expected behavior

The video should start playing at 2x tempo

Actual behavior

The player encounters a decoder error and doesn't play the video.

Screenshots/Screen recordings

No response

Logs

Exception

com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(298, null, null, video/avc, avc1.640020, 3829995, null, [1280, 720, 60.0], [-1, -1]), format_supported=YES
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:575)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:175)
    at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: com.google.android.exoplayer2.video.MediaCodecVideoDecoderException: Decoder failed: OMX.qcom.video.decoder.avc
    at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.createDecoderException(MediaCodecVideoRenderer.java:1512)
    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:813)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:998)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:499)
    ... 3 more
Caused by: java.lang.IllegalStateException
    at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
    at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2632)
    at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex(SynchronousMediaCodecAdapter.java:106)
    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1806)
    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:792)
    ... 5 more


Affected Android/Custom ROM version

Android 8.1.0

Affected device model

LG-H700

Additional information

This only effects some videos and usually all videos from their channel (encoding specific?). I can then close the stopped player open a different video (one from a different channel), which doesn't crash, change the tempo back to 1x, and then go back to the video which caused the crash and it will start playing.

A video which reproduces this behavior is linked in the logs.

amarzot commented 2 years ago

Actually after searching around, it looks like this is another #8016 bug. Guess I'll just do the workaround I described. Confirmation that it really is 8016 would be nice. Thanks!

opusforlife2 commented 1 year ago

The way to be sure is to try #8875 and see if it works.

amarzot commented 1 year ago

I get the following exception with the apk from that PR. Looks the same to me :/ . Looks from the wording of #8875 that it is not expected to solve all decoding errors. Let me know if you have any other ideas.

Exception

com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(298, null, null, video/avc, avc1.640020, 3829995, null, [1280, 720, 60.0], [-1, -1]), format_supported=YES
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:566)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:175)
    at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: com.google.android.exoplayer2.video.MediaCodecVideoDecoderException: Decoder failed: OMX.qcom.video.decoder.avc
    at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.createDecoderException(MediaCodecVideoRenderer.java:1590)
    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:813)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:989)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:490)
    ... 3 more
Caused by: java.lang.IllegalStateException
    at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
    at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2632)
    at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex(SynchronousMediaCodecAdapter.java:106)
    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1819)
    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:792)
    ... 5 more


opusforlife2 commented 1 year ago

Did you read the PR description and try the relevant toggle for offloading?

amarzot commented 1 year ago

Thanks so much for helping out!

...try the relevant toggle for offloading?

I'm not sure what offloading means in this context. That word isn't mentioned in the PR, but I'm assuming you mean fallback as the second bullet point on the PR talks about enabling the "decoder fallback feature" to help with #8016. I enabled that toggle, made sure that the "use old codec selection" toggle was off, and then quit the app. After opening the app back up and making sure the fallback feature was still enabled I was able to reproduce the bug. That's how the error in my comment was generated.

opusforlife2 commented 1 year ago

Oh! Media tunneling, the 3rd bullet. Sorry, I forgot its name. Try toggling that.

amarzot commented 1 year ago

Dang, I tried "disable media tunneling", both with fallback and without, but same error. Let me know if you want those error reports as well.

opusforlife2 commented 1 year ago

No, it's okay. Someone with more knowledge will have to see this, since I'm out of ideas.

CBSkarmory commented 1 year ago

This bug still exists in 0.25.0 and 0.25.1 (latest)

Another workaround I found:

After doing this, it can play the video at 2x speed, where it previously crashed. Resuming video playback of the same video also works fine.

Perhaps there is different behavior when playing (and selecting video format) through the usual interface vs playing video using Switch to Main

amarzot commented 4 months ago

Issue still here in 0.27.0, but I did find a workaround using the popout. After following the 4 repro steps from the initial comment, just click on the popup button under the video. It will start playing in the popup at the selected tempo.

Unfortunately you can't merge it back into the app without it crashing again (like you can with the background trick).