react-native-track-player icon indicating copy to clipboard operation
react-native-track-player copied to clipboard

m3u8 stream can not buffer properly

Open s123121 opened this issue 2 years ago • 1 comments

Describe the Bug Some m3u8 playlist can not be buffer while playing. This lead to undesired behavior: player stop playing after a while (because no buffering) -> buffering -> play -> buffering -> paused. OTOH, the "good" m3u8 playlist buffer while playing so it never stop mid-playing

Steps To Reproduce

https://github.com/s123121/react-native-track-player/tree/test/playlist-paused

I add 2 files in the tracklist. The first one is a"bad" stream, the second one is a "good" stream

Environment Info:

System:
    OS: macOS 12.0
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.47 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
    Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8512546
    Xcode: 13.4/13F17a - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.68.1 => 0.68.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

How I can Help I can see in Event.PlaybackProgressUpdated logging that the "bad" stream 's buffered value always remains 0, and the"good" stream have the value working as intended

s123121 avatar May 27 '22 04:05 s123121

Any solution on this one ?

petkovv avatar Jun 24 '22 10:06 petkovv

Try changing this line: https://github.com/s123121/react-native-track-player/blob/test/playlist-paused/example/src/services/SetupService.ts#L10

to

await TrackPlayer.setupPlayer({
  waitForBuffer: true
});

or wait for this pr to be merged: https://github.com/doublesymmetry/react-native-track-player/pull/1695

puckey avatar Sep 01 '22 18:09 puckey

I did change it to waitForBuffer: true but the problem still persist. Here is the log:

The bad stream:

 LOG  Event.PlaybackTrackChanged {"nextTrack": 0, "position": 0}
 LOG  Event.PlaybackProgressUpdated {"buffered": 0, "duration": 10.077, "position": 0, "track": 0}
 LOG  Event.PlaybackProgressUpdated {"buffered": 0, "duration": 10.077, "position": 10.030988888888889, "track": 0}
 LOG  Event.PlaybackProgressUpdated {"buffered": 0, "duration": 10.078, "position": 10.030988889, "track": 0}
 LOG  Event.PlaybackProgressUpdated {"buffered": 0, "duration": 10.078, "position": 10.030988889, "track": 0}
 LOG  Event.PlaybackProgressUpdated {"buffered": 0, "duration": 10.078, "position": 12.001759652, "track": 0}
 LOG  Event.PlaybackProgressUpdated {"buffered": 0, "duration": 10.078, "position": 14.001184319, "track": 0}

The good stream:

LOG  Event.PlaybackProgressUpdated {"buffered": 30.016, "duration": 0, "position": 6.001772554, "track": 1}
LOG  Event.PlaybackProgressUpdated {"buffered": 30.016, "duration": 0, "position": 8.001330254, "track": 1}
LOG  Event.PlaybackProgressUpdated {"buffered": 40, "duration": 0, "position": 10.001585924, "track": 1}
LOG  Event.PlaybackProgressUpdated {"buffered": 40, "duration": 0, "position": 12.001019838, "track": 1}
LOG  Event.PlaybackProgressUpdated {"buffered": 40, "duration": 0, "position": 14.001680134, "track": 1}
LOG  Event.PlaybackProgressUpdated {"buffered": 40, "duration": 0, "position": 16.001780355, "track": 1}
LOG  Event.PlaybackProgressUpdated {"buffered": 40, "duration": 0, "position": 18.000966867, "track": 1}
LOG  Event.PlaybackProgressUpdated {"buffered": 40, "duration": 0, "position": 20.001772471, "track": 1}
LOG  Event.PlaybackProgressUpdated {"buffered": 50.004, "duration": 0, "position": 22.0014888, "track": 1}

Both is m3u8 and livestream

s123121 avatar Sep 02 '22 07:09 s123121

Okay just to reiterate, the following stream keeps playing, buffering, playing: https://vnno-pt-1-tf-playlist-live-zmp3.zadn.vn/hpOx2UjqVEQ/zhls/live/standard-audio/855a669d5ad8b386eac9/standard-audio.m3u8

Results of a curl:

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:12708563
#EXT-X-TARGETDURATION:5
#EXTINF:5.016,
//vnno-pt-1-tf-chunk-zmp3.zadn.vn/106facf9739a9ac4c38b
#EXTINF:5.015,
//vnno-pt-1-tf-chunk-zmp3.zadn.vn/edff7a69a50a4c54151b
#EXTINF:5.016,
//vnno-pt-1-tf-chunk-zmp3.zadn.vn/45843013ef70062e5f61
#EXTINF:5.015,
//vnno-pt-1-tf-chunk-zmp3.zadn.vn/52e50272dd11344f6d00
#EXTINF:5.016,
//vnno-pt-1-tf-chunk-zmp3.zadn.vn/75017b96a4f54dab14e4

While in general m3u8 streams are working as illustrated by the following url: http://113.163.216.23:1935/live/radio1.sdp_audio/playlist.m3u8

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=96180,CODECS="mp4a.40.2"
chunklist_w1155429664.m3u8

puckey avatar Sep 02 '22 07:09 puckey

I just also experienced this issue listening to the stream on QuickTime player version 10.5.. It did take something like 2 minutes before the audio stopped and buffering started.. What kind of time are you talking about?

puckey avatar Sep 02 '22 07:09 puckey

So from my experience the first stream just seems pretty choppy - probably due to a slow server?

puckey avatar Sep 02 '22 07:09 puckey

Probably, there are some codec intervention to prevent others from using the stream. I will close this issue for now until I find other streams with similar problem

s123121 avatar Sep 02 '22 14:09 s123121

@s123121 Thanks – please do get in touch if you are able to pin something down to RNTP being the cause of the issue.

puckey avatar Sep 02 '22 14:09 puckey