TeamNewPipe / NewPipe

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

AudioTrack init failed #10802

Open dezlov opened 9 months ago

dezlov commented 9 months ago

Checklist

Affected version

0.26.1

Steps to reproduce the bug

  1. Open any video.
  2. Press play.

Expected behavior

Video starts playing.

Actual behavior

Error occurs.

Screenshots/Screen recordings

No response

Logs

Exception

com.google.android.exoplayer2.ExoPlaybackException: MediaCodecAudioRenderer error, index=1, format=Format(140, null, null, audio/mp4a-latm, mp4a.40.2, 130535, und, [-1, -1, -1.0], [2, 44100]), format_supported=YES
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:578)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:223)
    at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.audio.AudioSink$InitializationException: AudioTrack init failed 0 Config(44100, 12, 60320) Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100])
    at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.buildAudioTrack(DefaultAudioSink.java:2136)
    at com.google.android.exoplayer2.audio.DefaultAudioSink.buildAudioTrack(DefaultAudioSink.java:1073)
    at com.google.android.exoplayer2.audio.DefaultAudioSink.buildAudioTrackWithRetry(DefaultAudioSink.java:1051)
    at com.google.android.exoplayer2.audio.DefaultAudioSink.initializeAudioTrack(DefaultAudioSink.java:843)
    at com.google.android.exoplayer2.audio.DefaultAudioSink.handleBuffer(DefaultAudioSink.java:929)
    at com.google.android.exoplayer2.audio.MediaCodecAudioRenderer.processOutputBuffer(MediaCodecAudioRenderer.java:709)
    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1889)
    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:782)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1007)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:502)
    ... 3 more
    Suppressed: com.google.android.exoplayer2.audio.AudioSink$InitializationException: AudioTrack init failed 0 Config(44100, 12, 60320) Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100])
        ... 13 more
    Caused by: java.lang.UnsupportedOperationException: Cannot create AudioTrack
        at android.media.AudioTrack$Builder.build(AudioTrack.java:1294)
        at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration$$ExternalSyntheticApiModelOutline6.m(R8$$SyntheticClass:0)
        at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.createAudioTrackV29(DefaultAudioSink.java:2185)
        at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.createAudioTrack(DefaultAudioSink.java:2163)
        at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.buildAudioTrack(DefaultAudioSink.java:2128)
        ... 12 more
Caused by: java.lang.UnsupportedOperationException: Cannot create AudioTrack
    at android.media.AudioTrack$Builder.build(AudioTrack.java:1294)
    at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration$$ExternalSyntheticApiModelOutline6.m(R8$$SyntheticClass:0)
    at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.createAudioTrackV29(DefaultAudioSink.java:2185)
    at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.createAudioTrack(DefaultAudioSink.java:2163)
    at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.buildAudioTrack(DefaultAudioSink.java:2128)
    ... 12 more


Affected Android/Custom ROM version

Android 11

Affected device model

Ugoos AM8

Additional information

Other video apps work fine. YouTube plays fine in a web browser.

dezlov commented 9 months ago

If I configure NewPipe to play video and audio in an external player (VLC), then static videos play fine at 720p and lower, but no audio in 1080p videos. It also can't play "live" videos in this configuration, it says VLC is not found and offers to install it. Tried reinstalling VLC from Google Play and F-Droid, but it made no difference.

opusforlife2 commented 9 months ago

Try restarting?

dezlov commented 9 months ago

Try restarting?

Yes. Tried restarting the box and reinstalling NewPipe from different sources.

opusforlife2 commented 9 months ago

And a lower resolution/codec combo?

dezlov commented 9 months ago

And a lower resolution/codec combo?

I tried changing the video/audio settings, from defaults to the following:

I get the same error.

Any other settings worth tinkering with?

opusforlife2 commented 9 months ago

Ugoos AM8

Never heard of this device before, so you should also test on a different device. Might be an OS/device bug.

dezlov commented 9 months ago

Ugoos AM8

Never heard of this device before, so you should also test on a different device. Might be an OS/device bug.

Ugoos has been around for a decade or two, developing Android TV boxes. Ugoos AM8 is one of the latest boxes that was launched in 2023 with Android 11.0 and Amlogic S928X-J, which outperforms most Android boxes in existence today.

The official list of supported codecs/formats is quite extensive:

− AV1 MP-10@L6.1 up to 8Kx4K@60fps − VP9 Profile-2@6.1 up to 8Kx4K@60fps − H.265 HEVC MP-10@L6.1 up to 8Kx4K@60fps − AVS3 Phase 1 up to 8Kx4K@60fps − AVS2-P2 Profile up to 8Kx4K@60fps − H.264 AVC HP@L5.1 up to 4Kx2K@30fps − MPEG-4 ASP@L5 up to 1080P@60fps (ISO-14496) − WMV/VC-1 SP/MP/AP up to 1080P@60fps − AVS-P16(AVS+) /AVS-P2 JiZhun Profile up to 1080P@60fps − MPEG-2 MP/HL up to 1080P@60fps (ISO-13818) − MPEG-1 MP/HL up to 1080P@60fps (ISO-11172) − Multiple language and multiple format sub-title video support − MJPEG and JPEG unlimited pixel resolution decoding (ISO/IEC-10918) − Supports JPEG thumbnail, scaling, rotation and transition effects

I also have a couple of old boxes MINIX U22 (Android 9.0) where NewPipe is working fine.

All other apps work fine on Ugoos AM8, including video playback of various formats and in 4K, even on YouTube. But NewPipe is not playing anything. Is it possible that NewPipe is not using the Android API correctly?

If you believe it is a device/OS issue, can you give me any more details, so I could report this issue to Ugoos?

opusforlife2 commented 9 months ago

Well, the easiest way to rule this out would be to test another device first, with the exact same settings as you currently have.

dezlov commented 9 months ago

Well, the easiest way to rule this out would be to test another device first, with the exact same settings as you currently have.

I don't have another such box at hand, but I will try to get the manufacturer to try it.

However, the fact that all other video/audio apps work without issues suggests that it might be an issue with NewPipe rather than the device. Is it something that you can investigate further?

Can you help decipher the error log to understand the media format that NewPipe is trying to play?

opusforlife2 commented 9 months ago

I don't have another such box at hand

That's not what I meant. I mean try it on your phone and some other device that's not the same OS and manufacturer, so that we can rule them out as problems.

Never heard of this device before, so you should also test on a different device. Might be an OS/device bug.

You can't check if it's a device/OS bug if you're testing on the same OS and maker.

dezlov commented 9 months ago

I mean try it on your phone and some other device that's not the same OS and manufacturer, so that we can rule them out as problems.

NewPipe does work fine on my phone and on another brand of Android boxes I have, but I don't see how this rules out anything. There can still be a problem with either NewPipe or Ugoos AM8, or both.

You can't check if it's a device/OS bug if you're testing on the same OS and maker.

Well, if it would work on one Ugoos AM8 but not another Ugoos AM8, then it could indicate a manufacturing or software defect in a particular box rather than a more general incompatibility between NewPipe and Ugoos AM8.

I'm guessing it's probably the latter, i.e. a general incompatibility between NewPipe and Ugoos AM8, because all other apps work fine on this device. I would imagine the manufacturer will say that since all other apps work fine, then it's probably a software defect in NewPipe.

Can you help decipher the error log to understand the media format that NewPipe is trying to play and any other interesting details that might help the manufacturer investigate this issue?

opusforlife2 commented 9 months ago

but I don't see how this rules out anything

It helps us know that there's nothing wrong with your network or other settings/config/setup. Better to conduct a simple test whose answer you probably know, than to not and later feel silly if the test could have helped pinpoint the problem.

Now that we know the problem is between Newpipe and that particular device, could you try Just Player from F-Droid? It's also based on Exoplayer like Newpipe, and will let us know if the problem lies there. (If it also doesn't work but you don't get a direct crash report, maybe also install Scoop or use adb logcat to obtain the crash log).

dezlov commented 9 months ago

I tried installing Just Player from F-Droid, but I'm not sure if it is the right app. It was last updated more than 10 years ago, in 2013. When installing, it says that the app might misbehave as it was developed for a much older version of Android. It is also advertised as a music player, rather than a video player. Is that the right app?

I also found a similarly named app Just (Video) Player in Google Play Store, with source code available in GitHub. I installed this one too.

Simply installing either of these two apps didn't change anything regarding the issue in NewPipe. It still couldn't to play any video with the default configuration.

Do I need to somehow instruct NewPipe to use a different video player API for native playback?

I can configure NewPipe to use an external player, e.g. VLC or Just (Video) Player, but as mentioned earlier it results in degraded functionality, i.e. no audio in 1080p, can't play live streams.

opusforlife2 commented 9 months ago

I also found a similarly named app

Yes that's the one. This is also available on F-Droid. I didn't know about that abandoned app. Sorry for the confusion. xD

The idea here is to test any video file you happen to have in Just (Video) Player as a standalone. This app has nothing to do with Newpipe. There is no interaction or dependency between them.

But you must find a video whose audio track codec is m4a/aac, matching your crash report. If you don't have any such video available, then you could use yt-dlp to download the exact video you've linked in your crash report, with the exact stream format your crash report shows (which is 140). If this file plays just fine in Just Player, then we can be more certain that the problem is in Newpipe.

Here's the shell command you need, in case you've never used yt-dlp before: yt-dlp -f 140 https://www.youtube.com/watch?v=LXb3EKWsInQ

You could also use yt-dlg if you're more comfortable with GUIs.

dezlov commented 8 months ago

I followed your instructions.

The audio file played without issues in all 3 players:

The command used to download the audio track:

$ ./yt-dlp.sh -f 140 https://www.youtube.com/watch?v=LXb3EKWsInQ
...
[info] LXb3EKWsInQ: Downloading 1 format(s): 140
[download] Destination: COSTA RICA IN 4K 60fps HDR (ULTRA HD) [LXb3EKWsInQ].m4a
[download] 100% of    4.84MiB in 00:00:00 at 8.54MiB/s
[FixupM4a] Correcting container of "COSTA RICA IN 4K 60fps HDR (ULTRA HD) [LXb3EKWsInQ].m4a"

The specification of format "140", for reference:

$ ./yt-dlp.sh -f - https://www.youtube.com/watch?v=LXb3EKWsInQ
...
[info] Available formats for LXb3EKWsInQ:
ID  EXT   RESOLUTION FPS HDR CH │   FILESIZE    TBR PROTO │ VCODEC           VBR ACODEC      ABR ASR MORE INFO
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
...
599 m4a   audio only          2 │    1.15MiB    31k https │ audio only           mp4a.40.5   31k 22k ultralow, m4a_dash
600 webm  audio only          2 │    1.28MiB    34k https │ audio only           opus        34k 48k ultralow, webm_dash
139 m4a   audio only          2 │    1.83MiB    49k https │ audio only           mp4a.40.5   49k 22k low, m4a_dash
249 webm  audio only          2 │    1.88MiB    50k https │ audio only           opus        50k 48k low, webm_dash
250 webm  audio only          2 │    2.51MiB    67k https │ audio only           opus        67k 48k low, webm_dash
140 m4a   audio only          2 │    4.84MiB   129k https │ audio only           mp4a.40.2  129k 44k medium, m4a_dash
251 webm  audio only          2 │    4.96MiB   133k https │ audio only           opus       133k 48k medium, webm_dash
...

MediaInfo output:

General
Complete name                            : E:\COSTA RICA IN 4K 60fps HDR (ULTRA HD) [LXb3EKWsInQ].m4a
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/mp41)
File size                                : 4.84 MiB
Duration                                 : 5 min 13 s
Overall bit rate mode                    : Constant
Overall bit rate                         : 129 kb/s
Writing application                      : Lavf58.45.100

Audio
ID                                       : 1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 5 min 13 s
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 4.79 MiB (99%)
Title                                    : ISO Media file produced by Google Inc.
Default                                  : Yes
Alternate group                          : 1
opusforlife2 commented 8 months ago

Awesome! Thanks for being thorough. This makes it certain that the bug is in Newpipe somewhere. Let's see what the devs say.

Spica2000 commented 8 months ago

I have the same problem on Ugoos X4 Cube, Android 11. Ugoos is one of the best TV boxes, please fix Newpipe. Thank you!

dezlov commented 8 months ago

Any thoughts on how to fix this?

opusforlife2 commented 4 months ago

I can't believe I didn't ask you to try the three Exoplayer settings toggles. Maybe those might work.

github-actions[bot] commented 4 months ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

dezlov commented 2 months ago

I missed the notifications, so the ticket got closed. Can it be reopened?

I have two Ugoos boxes AM8 and AM8 Pro. NewPipe won't play any videos with the same error as described earlier.

None of the suggested steps and options fix it.

opusforlife2 commented 1 month ago

@dezlov Did you try the 3 toggles separately, or combos of them as well?

dezlov commented 1 month ago

Did you try the 3 toggles separately, or combos of them as well?

Yes I did, but it doesn't help.

Toggles found in Settings » Video and Audio » ExoPlayer settings.

opusforlife2 commented 1 month ago

Cheers. I'm officially out of ideas again. Back to hoping a dev is able to figure this out.