Playback media can't open sound file

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:

{
    "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:

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

The Asterisk CLI shows:

[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:

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…

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.

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.

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