# Playback media can't open sound file

**URL:** <https://community.asterisk.org/t/playback-media-cant-open-sound-file/104965>\
**Category:** Asterisk APIs\
**Created:** [October 17, 2024, 6:56pm UTC](https://community.asterisk.org/t/playback-media-cant-open-sound-file/104965 "2024-10-17T18:56:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Overseer](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/overseer/32/8439_2.png) [@Overseer](https://community.asterisk.org/u/Overseer)\
**Post date:** [October 17, 2024, 6:56pm UTC](https://community.asterisk.org/t/playback-media-cant-open-sound-file/104965/1 "2024-10-17T18:56:02Z")

</div>

So far I have:

1. Created a bridge
2. Created a channel
3. Added the channel to the bridge
4. Instructed the channel to dial
5. Answered the phone upon ring
6. Created a playback resource to play into the channel

And all of that is working great, EXCEPT, I don’t hear any audio on the phone. After I call the /play method I see these websocket messages:

```auto
{
    "application": "asteriskcontroller",
    "asterisk_id": "54:b2:03:10:1f:3a",
    "playback": {
        "id": "pr0",
        "language": "en",
        "media_uri": "sound:/var/lib/asterisk/sounds/en/andnowstandby.wav",
        "state": "playing",
        "target_uri": "bridge:br0"
    },
    "timestamp": "2024-10-17T14:44:31.960-0400",
    "type": "PlaybackStarted"
}

{
    "application": "asteriskcontroller",
    "asterisk_id": "54:b2:03:10:1f:3a",
    "playback": {
        "id": "pr0",
        "language": "en",
        "media_uri": "sound:/var/lib/asterisk/sounds/en/andnowstandby.wav",
        "state": "failed",
        "target_uri": "bridge:br0"
    },
    "timestamp": "2024-10-17T14:44:31.961-0400",
    "type": "PlaybackFinished"
}

```

So clearly the “failed” state indicates something went wrong, but what? I confirmed the file (/var/lib/asterisk/sounds/en/andnowstandby.wav) exists on the PBX. And my response to the /play function call is:

```auto
{
    "id": "pr0",
    "language": "en",
    "media_uri": "sound:/var/lib/asterisk/sounds/en/andnowstandby.wav",
    "state": "queued",
    "target_uri": "bridge:br0"
}

```

The Asterisk CLI shows:

```auto
[2024-10-17 15:03:24] WARNING[2367032]: file.c:825 ast_openstream_full: File /var/lib/asterisk/sounds/en/andnowstandby.wav does not exist in any format
[2024-10-17 15:03:24] WARNING[2367032]: file.c:1322 ast_streamfile: Unable to open /var/lib/asterisk/sounds/en/andnowstandby.wav (format (slin)): No such file or directory
[2024-10-17 15:03:24] WARNING[2367032]: res_stasis_playback.c:280 playback_final_update: 1729191804.7: Playback failed for sound:/var/lib/asterisk/sounds/en/andnowstandby.wav

```

so “no such file or directory” is the error, yet the file definitely exists:

```auto
root@pbx:/var/lib/asterisk/sounds/en $ ll /var/lib/asterisk/sounds/en/andnowstandby.wav
-rw-rw-r-- 1 asterisk asterisk 71042 Jan 26 2018 /var/lib/asterisk/sounds/en/andnowstandby.wav

```

What is going wrong? I’m wondering about codec/file format (given the slin message) but not sure. The file ownership is asterisk:asterisk with 664 permissions, so I don’t think it’s a rights issue. Is the absolute file path the issue? Grasping at straws here…

---

<div class="post-metadata">

**Author:** ![Overseer](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/overseer/32/8439_2.png) [@Overseer](https://community.asterisk.org/u/Overseer)\
**Post date:** [October 17, 2024, 9:04pm UTC](https://community.asterisk.org/t/playback-media-cant-open-sound-file/104965/2 "2024-10-17T21:04:32Z")

</div>

For anyone else encountering the same…the solution is:

**Do not include a file extension on the local file name**. Asterisk will try appending various extensions - I assume to find the one that best matches the codec in use.

---

<div class="post-metadata">

**Author:** ![ldo](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@ldo](https://community.asterisk.org/u/ldo)\
**Post date:** [October 17, 2024, 9:31pm UTC](https://community.asterisk.org/t/playback-media-cant-open-sound-file/104965/3 "2024-10-17T21:31:46Z")

</div>

I figured that was the answer. The same thing applies to the AGI `STREAM FILE` command.

If you want to play back other formats, you could use FFmpeg to do the conversion. Instead of creating temporary files, you could feed the converted audio to Asterisk in real time, via a named pipe. Specify the output format as GSM, and create the pipe name with a `.gsm` extension; but leave off the extension when passing the pipe file name to Asterisk.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [November 16, 2024, 9:32pm UTC](https://community.asterisk.org/t/playback-media-cant-open-sound-file/104965/4 "2024-11-16T21:32:11Z")

</div>

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