# How to solve issue where the CAF receiver gets initialized with the wrong audio segment format with HLS streams?

**URL:** <https://community.bitmovin.com/t/how-to-solve-issue-where-the-caf-receiver-gets-initialized-with-the-wrong-audio-segment-format-with-hls-streams/1760>\
**Category:** Support\
**Tags:** web\
**Created:** [March 3, 2023, 7:21pm UTC](https://community.bitmovin.com/t/how-to-solve-issue-where-the-caf-receiver-gets-initialized-with-the-wrong-audio-segment-format-with-hls-streams/1760 "2023-03-03T19:21:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludovic.michaud](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/ludovic.michaud/32/811_2.png) [@ludovic.michaud](https://community.bitmovin.com/u/ludovic.michaud)\
**Post date:** [March 3, 2023, 7:21pm UTC](https://community.bitmovin.com/t/how-to-solve-issue-where-the-caf-receiver-gets-initialized-with-the-wrong-audio-segment-format-with-hls-streams/1760/1 "2023-03-03T19:21:23Z")

</div>

In some cases, the CAFv3 receiver (powered by Shaka Player), fails with the following error, when trying to play a HLS stream with TS segments:

```auto
Neither ID3 nor ADTS header was found at 0

```

This might be because Shaka Player gets initialized with the wrong audio segment format (`MPEG2_TS`), instead of `TS`.

One solution to this is to intercept the Load request and force the [HlsSegmentFormat](https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages#.HlsSegmentFormat) to `TS`.

(source and details : [Google Issue Tracker](https://issuetracker.google.com/issues/70031250#comment21))

The Bitmovin CAFv3 receiver is available [open source on Github](https://github.com/bitmovin/bitmovin-player-caf-receiver), so it is possible to apply this fix directly by replacing the [`init()`](https://github.com/bitmovin/bitmovin-player-caf-receiver/blob/main/src/index.ts#L16-L21) function with the following :

```javascript
 public init() {
    // cast.framework.CastReceiverContext.getInstance().setLoggerLevel(cast.framework.LoggerLevel.DEBUG);

    this.attachEvents();
// intercept the LOAD request
this.player.setMessageInterceptor(cast.framework.messages.MessageType.LOAD, loadRequestData => {
            loadRequestData.media.hlsSegmentFormat = cast.framework.messages.HlsSegmentFormat.TS;
            return loadRequestData;
});
    this.context.start();
  }

```

Once this is done, you can follow the [build instructions](https://github.com/bitmovin/bitmovin-player-caf-receiver#getting-started) and [publish your custom receiver through the chromecast developer console](https://developers.google.com/cast/codelabs/cast-receiver#0).

After a few minutes, your receiver should be ready to use.

Example :

```javascript
var conf = {
  key: '<YOUR PLAYER KEY HERE>',
  remotecontrol: {
    type: 'googlecast',
// replace the ID of the Bitmovin default receiver application with the one you just created
    receiverApplicationId: 'FFE417E5',
    receiverVersion: 'v3',
    messageNamespace: 'urn:x-cast:com.bitmovin.player.caf',
  },
};

```

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/daniel/32/121_2.png) [@daniel](https://community.bitmovin.com/u/daniel)\
**Post date:** [March 14, 2023, 1:18pm UTC](https://community.bitmovin.com/t/how-to-solve-issue-where-the-caf-receiver-gets-initialized-with-the-wrong-audio-segment-format-with-hls-streams/1760/2 "2023-03-14T13:18:56Z")

</div>

Very useful, thanks for sharing Ludo!

---

<div class="post-metadata">

**Author:** ![ludovic.michaud](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/ludovic.michaud/32/811_2.png) [@ludovic.michaud](https://community.bitmovin.com/u/ludovic.michaud)\
**Post date:** [March 14, 2023, 9:05pm UTC](https://community.bitmovin.com/t/how-to-solve-issue-where-the-caf-receiver-gets-initialized-with-the-wrong-audio-segment-format-with-hls-streams/1760/3 "2023-03-14T21:05:47Z")

</div>

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.
