Flac doesn’t work on iOS #62

Closed
opened 2026-04-24 23:05:12 +02:00 by adam · 6 comments
Owner

Originally created by @higbee4 on GitHub (Jan 16, 2022).

Steps to reproduce

  1. Stream a flac file using iOS safari or the iOS app. It never starts playing. It does work on Android.

Audiobookshelf Version:

  • Android App?
  • iOS App?

iOS Version: 15.2.1

Originally created by @higbee4 on GitHub (Jan 16, 2022). ### Steps to reproduce 1. Stream a flac file using iOS safari or the iOS app. It never starts playing. It does work on Android. Audiobookshelf Version: - [ ] Android App? - [X] iOS App? iOS Version: 15.2.1
adam added the bug label 2026-04-24 23:05:12 +02:00
adam closed this issue 2026-04-24 23:05:13 +02:00
Author
Owner

@advplyr commented on GitHub (Jan 18, 2022):

I am wondering if this is a bug they introduced in 15.2
https://developer.apple.com/forums/thread/695917

If anyone can test this on an earlier iOS version that would be helpful.

Notable: FLAC is the only audio format that uses fMP4 (specs)

2.25. The container format for xHE-AAC, Apple Lossless, and FLAC audio MUST be fMP4.

@advplyr commented on GitHub (Jan 18, 2022): I am wondering if this is a bug they introduced in 15.2 https://developer.apple.com/forums/thread/695917 If anyone can test this on an earlier iOS version that would be helpful. **Notable**: FLAC is the only audio format that uses fMP4 ([specs](https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices)) > 2.25. The container format for xHE-AAC, Apple Lossless, and FLAC audio MUST be fMP4.
Author
Owner

@higbee4 commented on GitHub (Feb 6, 2022):

I think I found the problem. The server transcodes the .flac files to aac. However, it also changes the segment to use fMP4. Since the file has been transcoded to aac it doesn't need fMP4.
I tested with the following change, and it worked for me. (Force aac transcode, but keep mpegts segment type).

get hlsSegmentType() {
    var hasFlac = this.tracks.find(t => t.ext.toLowerCase() === '.flac')
    if (hasFlac) this.transcodeOptions.forceAAC = true
    return 'mpegts'
}

I tried to get it to work without transcoding and with fMP4 which I think would be preferable. But I haven't been able to figure out how to get that to work yet.

@higbee4 commented on GitHub (Feb 6, 2022): I think I found the problem. The server transcodes the .flac files to aac. However, it also changes the segment to use fMP4. Since the file has been transcoded to aac it doesn't need fMP4. I tested with the following change, and it worked for me. (Force aac transcode, but keep mpegts segment type). ``` get hlsSegmentType() { var hasFlac = this.tracks.find(t => t.ext.toLowerCase() === '.flac') if (hasFlac) this.transcodeOptions.forceAAC = true return 'mpegts' } ``` I tried to get it to work without transcoding and with fMP4 which I think would be preferable. But I haven't been able to figure out how to get that to work yet.
Author
Owner

@advplyr commented on GitHub (Feb 6, 2022):

Thanks for digging into that, that makes sense. Were you able to replicate the crash with the flac transcodes?

@advplyr commented on GitHub (Feb 6, 2022): Thanks for digging into that, that makes sense. Were you able to replicate the crash with the flac transcodes?
Author
Owner

@higbee4 commented on GitHub (Feb 6, 2022):

I'm not sure which crash you are referring to.

Before I tried changing the transcode on the server, I noticed the app was always returning 0 for getCurrentTime(). I think audioPlayer.currentItem was nil. Anyway, because that always returned 0, playback would stop with the error Audio current time has not increased - cancel interval and pause player.

@higbee4 commented on GitHub (Feb 6, 2022): I'm not sure which crash you are referring to. Before I tried changing the transcode on the server, I noticed the app was always returning 0 for getCurrentTime(). I think `audioPlayer.currentItem` was nil. Anyway, because that always returned 0, playback would stop with the error `Audio current time has not increased - cancel interval and pause player`.
Author
Owner

@advplyr commented on GitHub (Feb 6, 2022):

I'm not sure why I said crash, I meant to say replicate the issue. The temp fix I guess will be to just transcode with mpegts segment type.

@advplyr commented on GitHub (Feb 6, 2022): I'm not sure why I said crash, I meant to say replicate the issue. The temp fix I guess will be to just transcode with mpegts segment type.
Author
Owner

@advplyr commented on GitHub (Feb 7, 2022):

Just pushed a server update v1.6.65 that will use mpegts for FLAC files and AAC transcode.

Tested on iphone X and was working.

@advplyr commented on GitHub (Feb 7, 2022): Just pushed a server update `v1.6.65` that will use mpegts for FLAC files and AAC transcode. Tested on iphone X and was working.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf-app#62