Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Raw audio sample from QAudioInput to .mp3 file
Qt 6.11 is out! See what's new in the release blog

Raw audio sample from QAudioInput to .mp3 file

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fpartl
    wrote on last edited by
    #1

    Hello, smart people,

    I need an advice. I am sampling audio using QAudioInput with codec "audio/pcm" for segmentation and computation (Hamming window, FFT, etc.). I am creating chunks of 256 segments (approximately 3 seconds of audio). Every these 3 second I need to write to separate mp3 file. I am pretty able to write these samples to raw binary file, witch can be easily played with Audacity but I really need to save it as mp3. I didn't find any mechanism in Qt (maybe I am just blind). I have to use "audio/pcm" codec because of the computations. Can you please advice me some magic QMultimedia class or something else that can convert QVector<short> to mp3 file... I am desperate. Thank you in advance.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      This should help you with the file format. From there you just write out the proper header for the sound bytes you have and write it to a file.

      https://en.wikipedia.org/wiki/MP3

      I don't work with sound much in Qt so there may be an easier way but I looked at the Qt Multimedia classes like QAudioBuffer/QAudioFormat/etc and none of them looked like they could convert raw bytes to an mp3. So that means you will have to write a small class that takes raw bytes and makes mp3 packets out of it.

      With that file format and description in the wiki page you should have plenty of info to do it. You may also want to search the web for a class that can do it that someone else may have done and open sourced already.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved