Split audio file

Describe the problem/error/question

Hi there, in a workflow I need to send audio files to OpenAI Whisper to transcribe them. But sometimes, the files I receive are larger than the 25 mB limit. Do you know what would be the simplest way to split an audio file in smaller files in n8n?

Information on your n8n setup

  • n8n version: 1.67.1
  • Database (default: SQLite): Postgres

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

In what format is your audio file to be split?

Hi @mredodos, the file extension is mpga and the Mime type is “audio/mpeg”

So i think you have 2 way 1 is with ffmpeg library, but you need to install it on the server/container and activate and use via execute command or you can try with cloud convert api

Thanks I will look at those two solutions. Ideally, I’d like to have no additional cost so I will go first with the library solution.

OK so I found a solution with ffmpeg library thanks to you @mredodos!

If someone finds this topic here’s how I did it:

  • Add ffmpeg to n8n: I deploy it using Docker, so in the Dockerfile I added “RUN apk add --update ffmpeg”
  • In my workflow I write the binary file on the disk using the “Read/Write Files from Disk” node
  • Then I add an “Execute Command” node and execute the following command: ffmpeg -i my_input_file.mp3 -f segment -segment_time 2400 -c copy split_audio_file_%03d.mp3 (Here I cut the file in 40 minutes segments and name the outputs “split_audio_file_000.mp3”, “split_audio_file_001.mp3”, etc.)
  • Then I can get the binary files by reading the disk and looking for files named “split_audio_file_???.mp3”
6 Likes

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