re-encode M4A audio files with “faststart” flag

Hi There,
I am an Audio Editor on Fiverr. I edited few audio files for my client and he needed them in m4a format. After editing I received this message,
"Hello, Nauman,
Could you please fix this critical problem in our audio files? This needs to be done ASAP, please.
Our m4a files were coded wrongly.
And that is why they start playing slowly on our website. We need to change them a little and here’s how to do that: "
https://stackoverflow.com/questions/47102797/how-to-stream-m4a-files-correctly
We have checked and found out that our files are not using (faststart).

Can you please re-encode audio files with “faststart” flag"


This was the message from my client. To be honest, I am not getting him. Your help would be much appreciated.
Looking forward to your response.
Thanks

Nauman

My advice would be to avoid offering to supply work as .m4a, but rather to offer to supply work in a limited number of formats, such as “Microsoft WAV”, [16-bit integer, 24-bit integer, 32-bit integer, 32-bit float], [44100 Hz, 48000 Hz, 96000 Hz].

If you do accept a job that requires another format, then you need to know in advance, the full and exact format options, and you need to have the means to produce that format.

M4A format has many format options, including bit-rate, bit rate mode, number of channels, sample rate, complexity, which encoder, various additional flags. Unless you know the full specification of the required format, you will just be guessing and may have to re-encode many times before you get the exact format that the client requires.

Audacity’s default interface for .M4A has very few options, and does not have an option for the “isStreamable” flag. To set “advanced” options such as the “isStreamable” flag, using Audacity, you need to use the “external encoder” option. See: https://manual.audacityteam.org/man/exporting_to_an_external_program.html

You will also need to have a suitable command-line encoder installed. In this case I would expect that “ffmpeg-release-full.7z” version: 4.4 from here will do the job: https://www.gyan.dev/ffmpeg/builds/ (I’m on Linux, so I’ve not tested that version, but it looks to me like the right one). You will need to extract and install FFmpeg from that .7z file.

An example command line entry for .M4A with “isStreamable” enabled to use in Audacity’s “external encoder” options:

ffmpeg -i - -movflags +faststart "%f"

Breaking that down:

  • ffmpeg is the encoder to use - you may need to include the full path to the FFmpeg executable.
  • -i - sets the input file to “-”, which tells FFmpeg to use the audio stream that is being exported from Audacity.
  • -movflags +faststart sets the “isStreamable” flag. For recent FFmpeg builds this may need to be: -movflags faststart
  • “%f” sets the output filename to the name that you supply as “Name” in the Export dialog screen.

Note that the file name that you supply in the Export dialog screen should include the required file extension. For example: “myfile.m4a” rather that just “myfile”.

Unless you just want to use FFmpeg’s defaults, you will probably need to also include the target bit-rate, and possibly the number of channels in your external exporter command. For the full range of options, refer to the FFmpeg documentation: https://ffmpeg.org/ffmpeg.html

Alternatively, you could export from Audacity as WAV, and then use any 3rd party M4A encoder.
(I prefer to leave the M4A encoding to the client, so they can use whatever options they like - I just deal with the audio)

Hi Steve. Thanks so much.
It exported the first file while it shows an error on exporting more files i.e “Invalid Argument”. it says

ffmpeg -i - -movflags +faststart "D;/[File Location]/ [File Name]

ffmpeg version 4.4-essentials_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from ‘pipe:’:
Metadata:
title : Book 72 (23 Things) Part B - Key Insight 1
track : 2
Duration: N/A, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_f32le ([3][0][0][0] / 0x0003), 44100 Hz, mono, flt, 1411 kb/s
[NULL @ 000001b08c070dc0] Unable to find a suitable output format for ‘D:\Fiverr\Order 428 mharthid\English Books - Batch 3\23 Things They Don_t Tell You About Capitalism\m4a\Book 72 (23 Things) Part B - Key Insight 1’

D;/[File Location]/ [File Name]/ Invalid Argument

You have a semicolon instead of a colon.

If you are using Audacity’s command line exporter (“external encoder”), then do not enter the literal export path. Use:

"%f"

Audacity will substitute the path and file name that are selected in the Export dialog.


Hi Steve,
Thanks for your prompt Response.

I am using the export option “External Program” with code

ffmpeg -i - -movflags +faststart “%f”

However, still it shows an invalid argument
Capture.PNG

At the moment you are trying to export to your D: drive (an external drive? a memory stick? a CD?) with a very long file path (about 160 characters) and file name “m4a” with no file extension. I suspect that it is the file name “m4a” causing the problem.

Try exporting to your “Documents” folder as “test.m4a”
Screenshot_2021-10-14_10-19-14.png