Skip to content

fix(audio): ensure full WhatsApp compatibility for audio conversion #1425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2025

Conversation

edisonmartinsmkt
Copy link
Contributor

@edisonmartinsmkt edisonmartinsmkt commented May 7, 2025

This update standardizes audio conversion to the ogg format using libopus, with a 48kHz sampling rate, 128kbps bitrate, and mono channel.

It also removes unnecessary metadata and extended tags (such as ID3, BEXT, chapters, etc.) that previously caused the file to be flagged as invalid or unplayable by WhatsApp.

The resulting audio is fully compatible with WhatsApp Web, iOS and Android, regardless of the integration source (Chatwoot, N8N, Postman, etc.).

Summary by Sourcery

Improve WhatsApp audio compatibility by standardizing audio conversion parameters and removing unnecessary metadata

Bug Fixes:

  • Resolve audio file compatibility issues across WhatsApp platforms

Enhancements:

  • Optimize audio conversion settings for maximum WhatsApp compatibility

Copy link
Contributor

sourcery-ai bot commented May 7, 2025

Reviewer's Guide

This PR updates the audio conversion in BaileysStartupService by fine-tuning FFmpeg settings for Ogg Opus encoding. It explicitly sets the audio bitrate to '128k', frequency to 48000Hz, and introduces new output options to strip non-essential metadata and tags, while optimizing encoding for VoIP applications with bitexact output to ensure WhatsApp compatibility.

File-Level Changes

Change Details Files
Configured specific audio encoding parameters for Ogg Opus conversion.
  • Set audio bitrate to '128k'.
  • Set audio sampling frequency to 48000Hz.
src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Added FFmpeg output options to remove various metadata and tags from the audio output.
  • Disabled writing of Xing VBR header using '-write_xing 0'.
  • Disabled ID3v2 tags using '-id3v2_version 0'.
  • Removed all stream metadata using '-map_metadata -1'.
  • Removed chapters using '-map_chapters -1'.
  • Disabled writing of BEXT (Broadcast Wave Format) chunk using '-write_bext 0'.
src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Added FFmpeg output options to optimize Ogg Opus encoding for Voice over IP (VoIP).
  • Set Ogg Vorbis compression level to 10 using '-compression_level 10'.
  • Indicated 'voip' application type to the encoder using '-application voip'.
  • Ensured bitexact output using '-fflags +bitexact' and '-flags +bitexact'.
src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@nestordavalos
Copy link
Contributor

muy buen trabajo por favor ejecutar npm run lint

neocol83 added a commit to neocol83/evolution-api that referenced this pull request May 7, 2025
@edisonmartinsmkt
Copy link
Contributor Author

muy buen trabajo por favor ejecutar npm run lint

Hola Nestor!

¡Hecho! 😉

@DavidsonGomes DavidsonGomes merged commit d2f1985 into EvolutionAPI:develop May 10, 2025
1 check passed
Belkior added a commit to Belkior/evolution-api that referenced this pull request May 10, 2025
fix(audio): ensure full WhatsApp compatibility for audio conversion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants