Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or try DVDFab and copy, convert or make Blu-rays and DVDs! :)

# Create mp3 duplicates of all mp4-files in a folder using ffmpeg

1. Hey guys,

I have a bunch of lectures in mp4 that I own and want to create mp3 versions of these same lectures in as high quality as possibly using ffmpeg. I have hundreds of files and am therefore looking for a bulk-solution. I installed ffmpeg using this tutorial but cannot get the various available scripts online on bulk-extraction/conversion to work, neither with .bat files nor simple entry.

For example, when I try the following, I get "f was unexpected at this time":

mkdir outputs
for f in *.mp4; do ffmpeg -i "$f" -c:a libmp3lame "outputs/${f%.mp4}.mp3"; done

I'm quite new to ffmpeg so am not fully sure on how to amend codes for .bat solutions and simply entering the script in cmd.
Could someone kindly point me towards an ffmpeg-solution that I can use to "convert" all mp4 files in a directory into mp3 files in the highest possibly quality?
2. for %%a in (*.mp4) do ffmpeg -i "%%~a" -b:a 320k "output\%%~na.mp3"
3. Windows Batch has a different syntax than shells of other operating systems. Calling "for /?" (possibly with redirection into a text file for convenient reading) will explain both parameters for the "for" loop itself and the syntax of variables in the command line interpreter "cmd" (interactively as well as for *.bat or *.cmd files). The percent signs may have to be doubled in batch files, compared to an interactive call.
__

Side note:

There are more powerful command line interpreters for Windows too. One of the most famous is 4NT, the successor of 4DOS, by JP Software. The full version is commercial; there is still the "Take Command Console, Light Edition (TCC/LE) " which is free for personal use.
4. For converting with ffmpeg, try AnotherGUI. I just copy ffmpeg.exe to the AnotherGUI folder.
A preset for converting to MP3 at the maximum bitrate might look something like this.

-i "<FullSourceFileName>" -y -threads 1 -vn -c:a libmp3lame -b:a 320k -compression_level 2 "<OutputPath><OutputFileName>.mp3"

"-compression_level" equates to LAME's -q option for CBR encoding. The default is 3. -compression_level 2 is slower but still fast enough. -compression_level 1 (or 0 is maximum quality) will be very slow and probably not worth it.
If you have problems add -report to the command line so ffmpeg will write a log file.

-report -i "<FullSourceFileName>" -y -threads 1 -vn -c:a libmp3lame -b:a 320k -compression_level 2 "<OutputPath><OutputFileName>.mp3"

AnotherGUI has a "watched folders" option. When it's configured, it'll automatically convert anything in the "watched folders" without having to load the files into the GUI. There's instructions here for downloading the additional files required for the "watched folder" functionality. It's pretty easy.

Ignore the processing errors in the screenshot. I set up a "watched folder" to demonstrate, but it mainly contained images and video files without audio.
5. Also quite useful for multithreaded conversion with ffmpeg (and maybe mencoder): TEncoder
6. for %%a in (*.mp4) do ffmpeg -i "%%~a" -b:a 320k "output\%%~na.mp3"
What is the meaning of "%%~a" here ? Shouldn't it be just "%%a" ? (Or "%a" from an interactive command line call.)

Otherwise : 320kbps might be a waste of space, encoding with a variable bitrate (using a preset) makes more sense, especially for lectures which have a lot of silence (as opposed to music content). A target average bitrate of ~200kbps should be perfectly transparent for that kind of material. I don't know the exact ffmpeg command to set a variable bitrate, should be easy to find, perhaps the default setting does just that.
Hell, even FLAC might get a lower bitrate than 320K, for a totally lossless conversion ! (For instance a clean recording of classical piano can compress lower than that in FLAC, even lower with more efficient lossless encoders like APE.) Try to test a few. Of course, if the files are intended to be played on a standalone device which only reads MP3 (which would be the only sound justification for re-encoding in the first place), this is moot, but it will still give you an idea of how compressible the source is, and how overkill it might be to set the maximum possible bitrate in MP3.

Side question for anyone who knows : what specific MP3 encoder is used by ffmpeg ? Is it an internal one (as for FAAC), or a third-party one (as for x264), or are there several available ? Apparently LAME is available, from the command shown in the first post. What bitrate parameters are obtained with this default command ?

As for the command line itself, this website is an excellent resource :
https://ss64.com/nt/for.html

Another suggestion : Foobar2000 has very good conversion capabilities, for MP3 the default LAME "V2" setting should be optimal, it's easy to set and forget (but it may not be convenient for hundreds of files in nested subfolders). The LAME executable has to be installed separately.

EDIT : Also, this thread should rather be in "Audio conversion".
7. Originally Posted by abolibibelot
Side question for anyone who knows : what specific MP3 encoder is used by ffmpeg ? Is it an internal one (as for FAAC), or a third-party one (as for x264), or are there several available ? Apparently LAME is available, from the command shown in the first post. What bitrate parameters are obtained with this default command ?
As far as I know, ffmpeg has no "native" MP3 encoder, so it has to use LAME.
If you don't specify a bitrate or VBR preset etc, you get -q:a 4, which is the same as LAME's -V 4 VBR preset.
8. If you don't specify a bitrate or VBR preset etc, you get -q:a 4, which is the same as LAME's -V 4 VBR preset.
Alright, so according to Foobar2000, V4 results in an average bitrate of approximately 165kbps, which is already decent for talk-only audio, although V2 (~190kbps) or V1 (~225kbps) would be a tad better. Space saving for V2 vs. 320kbps is approximately 40%, which might be quite a lot for hundreds of lecture recordings. Even the very best VBR setting, V0, results in an average bitrate of 245kbps (probably less for talk-only if the recording is clean), which amounts to a ~25% space saving.
9. I agree. 320kbp is overkill, but DennisO did say "highest possibly quality", so I just went with that when I replied.
10. Thanks guys for your replies and sorry if the thread is misplaced.

Originally Posted by hello_hello
I agree. 320kbp is overkill, but DennisO did say "highest possibly quality", so I just went with that when I replied.
I used the following and it worked but if there's a more convenient way, I'm open to suggestions. But please note that a lot of what has been written is like a foreign language to me.

for %%a in (*.mp4) do ffmpeg -i "%%~a" -b:a 320k "output\%%~na.mp3"

Finally, if I go with the above command, how can I amend it to avoid the overkill? The lectures are talk-only and to be clear, with "highest possible quality", I meant that I didn't want to lose any quality in the process. But if I can save around 25-40% in size with almost unnoticable loss of quality, that would be very convenient

Thanks again
11. I used the following and it worked but if there's a more convenient way, I'm open to suggestions. But please note that a lot of what has been written is like a foreign language to me.
Check the link I gave above (and links provided inside that page) for some clear explanations about the general layout of that command line. I'm using this kind of commands at a very basic level so I can understand how tricky it all appears at first !
– “FOR ... DO” is quite self-explanatory, it's a basic shell command which parses a directory for files meeting specific criteria, and for each of them performs (DO) a secondary command (in this case ffmpeg). If you open a command prompt and type : FOR /? >"E:\FOR_help.txt", it will create a file containing the integrated help for the FOR command (this is what “LigH.de” said above : “possibly with redirection into a text file for convenient reading”). Some features are quite advanced and you may not need them for quite a while, but others are readily useful, for instance, you can scan all subdirectories in a single command with the “/R” switch (and you can specify the path to the main directory after /R).
– “%%a” is a variable, the letter can be anything you want, lower-case or upper-case, as long as it stays consistent for the whole command line (i.e. the same letter with the same case must be used for the actual command) ; I generally use “%%F” for “file”, it could be “%%I” for “input”, it doesn't change anything. When you run the command from a command prompt, only one “percent” sign is required, when running it from a .bat script (just a regular text file containing the command line and renamed as .bat, which can be launched by a double-click or right-click > open) two “percent” signs are required, although I'm not sure why exactly. If you add “echo” between “do” and “ffmpeg” it will just display each individual command without actually running it, this can help to understand how variables work. See this link : https://ss64.com/nt/syntax-args.html
– “in (*.mp4)” defines the criteria for the files which must be used as input, in this case any file with a .mp4 extension. The * character is a wildcard, which matches any number of characters of any kind. See this link : https://ss64.com/nt/syntax-wildcards.html.
– “ffmpeg -i "%%a"” calls the ffmpeg.exe executable, loads the input file named after the “-i” switch (each FOR iteration loads a different file until all of them have been processed). The “~” character should not be required here. Quotation marks are required whenever there is a space in the name or path (but it doesn't hurt to always use them).
– “output\%%~na.mp3” defines the output path (which you can name anything you want, for instance “MP3” instead of “output”, or you can remove that part before the percent signs which will place the .mp3 in the same directory as the .mp4 and you can sort them manually afterwards, or you can define the whole path to place all the converted files in a place other than the source directory) and name (which you can also customize) ; “%%~na” means “only the name part of that file”, without the path and the extension. See the “syntax-args” link above. If you use “%%a.mp3”, a “12345.mp4” file will be transcoded as “12345.mp4.mp3”, because “%%a” refers to the complete name, including the extension. With ffmpeg, unless specified otherwise, the extension of the output defines the format used for the conversion, so just because the output ends with .mp3 it knows that the input file should be converted to the MP3 format. Same as above, quotation marks are required if there is at least one space somewhere in the name or path.
– “-b:a 320k” specific ffmpeg switch to set the audio bitrate. Using “-q:a 2” instead should set it to encode in VBR mode 2. (You can use MediaInfo afterwards to check the average bitrate of the converted files, it will be slightly different from one file to another but should be in the 175-215kbps ballpark with this setting ; a lower number – i.e “-q:a 1” or “-q:a 0” – will result in a slightly higher average bitrate but this should be already undistinquishable from the source ; according to “hello_hello” above, not specifying any quality/bitrate setting will set the encoder to “-q:a 4”, which is slightly inferior and could leave audible artifacts – although most people don't even notice any difference in quality between a source CD track and a CBR 128kbps MP3 transcoding.) I don't know if the “-codec:a libmp3lame” part is required here or if it produces the same output without, so long as the output file has a .mp3 extension. See here : https://trac.ffmpeg.org/wiki/Encode/MP3

Note: Using -b:a 320k is generally considered wasteful because:
-q:a 0 – -q:a 3 will normally produce transparent results.
MP3 is lossy anyway, so if you really want the highest quality use a lossless format such as FLAC.
Why do you need to convert to MP3 by the way ?
12. Originally Posted by DennisO
Finally, if I go with the above command, how can I amend it to avoid the overkill? The lectures are talk-only and to be clear, with "highest possible quality", I meant that I didn't want to lose any quality in the process. But if I can save around 25-40% in size with almost unnoticable loss of quality, that would be very convenient
Then use
Code:
-q:a 0
FFmpeg is somehow limited in terms of libmp3lame control (bellow show it's capabilities) - if you wish to use ffmpeg and have higher control over lame then perhaps you should consider piping from ffmpeg to lame.

Code:
Encoder libmp3lame [libmp3lame MP3 (MPEG audio layer 3)]:
General capabilities: delay small
Supported sample rates: 44100 48000 32000 22050 24000 16000 11025 12000 8000
Supported sample formats: s32p fltp s16p
Supported channel layouts: mono stereo
libmp3lame encoder AVOptions:
-reservoir         <boolean>    E...A.... use bit reservoir (default true)
-joint_stereo      <boolean>    E...A.... use joint stereo (default true)
-abr               <boolean>    E...A.... use ABR (default false)
13. FFmpeg is somehow limited in terms of libmp3lame control (bellow show it's capabilities) - if you wish to use ffmpeg and have higher control over lame then perhaps you should consider piping from ffmpeg to lame.
If the basic command already reads “like a foreign language” to the O.P., perhaps you should explain what piping is and provide an example of how it's done...
What particular extra controls would be useful in such a case ?
14. Originally Posted by abolibibelot
What particular extra controls would be useful in such a case ?
Depends on lame version used, replaygain control, freeformat support etc
15. Originally Posted by DennisO

I used the following and it worked but if there's a more convenient way, I'm open to suggestions. But please note that a lot of what has been written is like a foreign language to me.

for %%a in (*.mp4) do ffmpeg -i "%%~a" -b:a 320k "output\%%~na.mp3"

Finally, if I go with the above command, how can I amend it to avoid the overkill? The lectures are talk-only and to be clear, with "highest possible quality", I meant that I didn't want to lose any quality in the process. But if I can save around 25-40% in size with almost unnoticable loss of quality, that would be very convenient

Thanks again
I would've thought the mp3 encoder has to be specified (ie -codec:a libmp3lame), but maybe when the output extension is MP3 it's not necessary. I guess it's not required, given the command line works. That aside......

I use LAME's -V 2 variable bitrate preset for music, but for speech a lower quality preset should be fine. -V 4 is the default, so if you don't specify any options you get a variable bitrate MP3 using the -V 4 preset.
ffmpeg works the same way as LAME, only it uses -qscale or -q to specify a VBR preset instead of -V.
Anyway... you'd replace "-b:a 320k" in your command line with "-q:a 4". Or you could just remove "-b:a 320k" from the command line completely, and as "-q:a 4" is the default, the result should be the same.

This page provides some easy to understand info on the variable bitrate presets, and explains how LAME's basic command line options translate to ffmpeg.
https://trac.ffmpeg.org/wiki/Encode/MP3
16. Originally Posted by pandy
[/CODE][libmp3lame MP3 (MPEG audio layer 3)]:
General capabilities: delay small
Supported sample rates: 44100 48000 32000 22050 24000 16000 11025 12000 8000
Supported sample formats: s32p fltp s16p
Supported channel layouts: mono stereo
libmp3lame encoder AVOptions:
-reservoir <boolean> E...A.... use bit reservoir (default true)
-joint_stereo <boolean> E...A.... use joint stereo (default true)
-abr <boolean> E...A.... use ABR (default false)

[/CODE]
Your list is missing the bitrate and compression_level options.
http://ffmpeg.org/ffmpeg-codecs.html#libmp3lame-1
17. Originally Posted by hello_hello
Your list is missing the bitrate and compression_level options.
http://ffmpeg.org/ffmpeg-codecs.html#libmp3lame-1
This is ffmpeg list ( ffmpeg -h encoder=libmp3lame ) and it cover private encoder features not covered by general one.
18. Originally Posted by abolibibelot
I used the following and it worked but if there's a more convenient way, I'm open to suggestions. But please note that a lot of what has been written is like a foreign language to me.
Check the link I gave above (and links provided inside that page) for some clear explanations about the general layout of that command line. I'm using this kind of commands at a very basic level so I can understand how tricky it all appears at first !
– “FOR ... DO” is quite self-explanatory, it's a basic shell command which parses a directory for files meeting specific criteria, and for each of them performs (DO) a secondary command (in this case ffmpeg). If you open a command prompt and type : FOR /? >"E:\FOR_help.txt", it will create a file containing the integrated help for the FOR command (this is what “LigH.de” said above : “possibly with redirection into a text file for convenient reading”). Some features are quite advanced and you may not need them for quite a while, but others are readily useful, for instance, you can scan all subdirectories in a single command with the “/R” switch (and you can specify the path to the main directory after /R).
– “%%a” is a variable, the letter can be anything you want, lower-case or upper-case, as long as it stays consistent for the whole command line (i.e. the same letter with the same case must be used for the actual command) ; I generally use “%%F” for “file”, it could be “%%I” for “input”, it doesn't change anything. When you run the command from a command prompt, only one “percent” sign is required, when running it from a .bat script (just a regular text file containing the command line and renamed as .bat, which can be launched by a double-click or right-click > open) two “percent” signs are required, although I'm not sure why exactly. If you add “echo” between “do” and “ffmpeg” it will just display each individual command without actually running it, this can help to understand how variables work. See this link : https://ss64.com/nt/syntax-args.html
– “in (*.mp4)” defines the criteria for the files which must be used as input, in this case any file with a .mp4 extension. The * character is a wildcard, which matches any number of characters of any kind. See this link : https://ss64.com/nt/syntax-wildcards.html.
– “ffmpeg -i "%%a"” calls the ffmpeg.exe executable, loads the input file named after the “-i” switch (each FOR iteration loads a different file until all of them have been processed). The “~” character should not be required here. Quotation marks are required whenever there is a space in the name or path (but it doesn't hurt to always use them).
– “output\%%~na.mp3” defines the output path (which you can name anything you want, for instance “MP3” instead of “output”, or you can remove that part before the percent signs which will place the .mp3 in the same directory as the .mp4 and you can sort them manually afterwards, or you can define the whole path to place all the converted files in a place other than the source directory) and name (which you can also customize) ; “%%~na” means “only the name part of that file”, without the path and the extension. See the “syntax-args” link above. If you use “%%a.mp3”, a “12345.mp4” file will be transcoded as “12345.mp4.mp3”, because “%%a” refers to the complete name, including the extension. With ffmpeg, unless specified otherwise, the extension of the output defines the format used for the conversion, so just because the output ends with .mp3 it knows that the input file should be converted to the MP3 format. Same as above, quotation marks are required if there is at least one space somewhere in the name or path.
– “-b:a 320k” specific ffmpeg switch to set the audio bitrate. Using “-q:a 2” instead should set it to encode in VBR mode 2. (You can use MediaInfo afterwards to check the average bitrate of the converted files, it will be slightly different from one file to another but should be in the 175-215kbps ballpark with this setting ; a lower number – i.e “-q:a 1” or “-q:a 0” – will result in a slightly higher average bitrate but this should be already undistinquishable from the source ; according to “hello_hello” above, not specifying any quality/bitrate setting will set the encoder to “-q:a 4”, which is slightly inferior and could leave audible artifacts – although most people don't even notice any difference in quality between a source CD track and a CBR 128kbps MP3 transcoding.) I don't know if the “-codec:a libmp3lame” part is required here or if it produces the same output without, so long as the output file has a .mp3 extension. See here : https://trac.ffmpeg.org/wiki/Encode/MP3

Note: Using -b:a 320k is generally considered wasteful because:
-q:a 0 – -q:a 3 will normally produce transparent results.
MP3 is lossy anyway, so if you really want the highest quality use a lossless format such as FLAC.
Why do you need to convert to MP3 by the way ?
Thank you so much for your elaborate explanation. The only thing that remains unclear is the following and what it achieves:
“-i” switch
This sounds really lame (no pun intended) but what is the activity of working within CMD/with .bat-files formally called? I'm wondering what I should search for to find lectures/courses to learn the very basics of this and how to work with CMD/Terminal to perform general commands (not ffmpeg or audio/video).

The reason I want to extract the audios is because I don't really watch these lectures but rather listen to them while doing other things and I don't mind the space-save on my phone. Also, full disclosure: I still use an iPod sometimes. Finally, these lectures aren't copyrighted so I might want to share them at some point and I know some of those interested won't mind mp3 files since the lectures are talk-only.
19. Originally Posted by pandy
Originally Posted by DennisO
Finally, if I go with the above command, how can I amend it to avoid the overkill? The lectures are talk-only and to be clear, with "highest possible quality", I meant that I didn't want to lose any quality in the process. But if I can save around 25-40% in size with almost unnoticable loss of quality, that would be very convenient
Then use
Code:
-q:a 0
Thank you!
20. Originally Posted by hello_hello
Originally Posted by DennisO

I used the following and it worked but if there's a more convenient way, I'm open to suggestions. But please note that a lot of what has been written is like a foreign language to me.

for %%a in (*.mp4) do ffmpeg -i "%%~a" -b:a 320k "output\%%~na.mp3"

Finally, if I go with the above command, how can I amend it to avoid the overkill? The lectures are talk-only and to be clear, with "highest possible quality", I meant that I didn't want to lose any quality in the process. But if I can save around 25-40% in size with almost unnoticable loss of quality, that would be very convenient

Thanks again
Anyway... you'd replace "-b:a 320k" in your command line with "-q:a 4". Or you could just remove "-b:a 320k" from the command line completely, and as "-q:a 4" is the default, the result should be the same.

This page provides some easy to understand info on the variable bitrate presets, and explains how LAME's basic command line options translate to ffmpeg.
https://trac.ffmpeg.org/wiki/Encode/MP3
Thank you!
21. The "-i" option in an ffmpeg command line means: The following file name describes an input.

Options after a "-i inputfile.ext" option pair may be valid only for handling this input file, or in general to specify the output format, depending on their meaning. Some options may have to be put in front of the first input file option to specify non-standard handling of an input file. The ffmpeg CLI syntax is complex, and sometimes a meaning of an option depends on the order of CLI options, the position of this option in the whole string.

In certain situations you may specify several input file options, the output may then be a combination of their contents. The name of the output file is usually given as the last file name without a matching preceding option.
22. This sounds really lame (no pun intended) but what is the activity of working within CMD/with .bat-files formally called? I'm wondering what I should search for to find lectures/courses to learn the very basics of this and how to work with CMD/Terminal to perform general commands (not ffmpeg or audio/video).
I'm not sure if I understand what you mean here... There are two ways of running Windows shell commands : either through a command prompt, by typing the command (or pasting it), or with .bat files, which can be more convenient when the same command is used regularly. There are slight differences in the command syntax : as I mentioned, two percent signs are required to designate variables in a .bat script (%%F instead of %F).
The ss64.com website I mentioned provides clear enough explanations of each basic function. As for a basic startup guide, a simple Web search will most likely return some good resources.

By the way, someone may have an explanation for this weirdness : on Windows 7, I have a Robocopy.bat script on the desktop, with a Robocopy command :
Code:
chcp 1252
set source="E:\Path\of\the\source directory"
set destin="F:\Path\of\the\destination directory"
robocopy %source% %destin% /E /B /DCOPY:T /TIMFIX /FFT /DST /XJ /R:0 /W:1
If I try running it by double-click it doesn't work, I only see each line of the command being displayed over and over in an infinite loop and nothing happens. Same thing if I put the command as a single line. So I have to open a command prompt, drag and drop the .bat file, and run it from there – and then it works as intended. (I've been using it like this for months.) What's going on here ?

The reason I want to extract the audios is because I don't really watch these lectures but rather listen to them while doing other things and I don't mind the space-save on my phone. Also, full disclosure: I still use an iPod sometimes. Finally, these lectures aren't copyrighted so I might want to share them at some point and I know some of those interested won't mind mp3 files since the lectures are talk-only.
But even an old iPod can read M4A / AAC audio, right ? (M4A is just MP4 audio, i.e. an AAC stream with in a MP4 container, it's the format used for iTunes audio files, so even an old iPod should read that flawlessly.) If so, it would be much faster and more efficient to just extract the audio as M4A. This will preserve 100% of the audio quality (no transcoding) while generating smaller files than converting to decent quality MP3 (since the native AAC streams from those MP4 files most likely have an average bitrate around 125kbps, which is usually enough to achieve near transparency with the AAC format).
With ffmpeg :
Code:
FOR /R %F in (*.mp4) DO ffmpeg -i "%F" -vn -c:a copy "%~nF.m4a"
With mp4box :
Code:
FOR /R %F in (*.mp4) DO mp4box -add "%F#audio" -new "%~nF.m4a"
Those tools use a different syntax, “-add” is the equivalent of “-i”, “-vn” means “no video stream”, which is also the function of “#audio”, “-c:a copy” means that the audio has to be copied as-is with no transcoding.
MeGUI contains the mp4box.exe executable in the “tools” directory so you can decompress the MeGUI archive if you haven't it already (it might come in handy later on, and integrates a bunch of conversion tools, which are automatically updated, and which you can similarly use on their own), then indicate the path to that file in the command line (that way it is not necessary to edit environment variables, as explained in the StackExchange thread you linked to in your first post – it is a convenience for command line tools which are used often, but not a necessity) ; and you can also specify the path to the MP4 files in the script (by default the script will process the directory where the .bat file is currently located, if you specify the path you can place the .bat file anywhere and it will still process the right directory ; again, if the command is launched as a .bat file, use two percent signs for variable, i.e. %%F instead of %F).
Code:
FOR /R "E:\Path\to\the\MP4 lectures" %F in (*.mp4) DO "C:\...\MeGUI\tools\mp4box\mp4box.exe" -add "%F#audio" -new "%~nF.m4a"
I just tested both methods, they produce files with approximately the same size, but there are some differences in MediaInfo :

[ffmpeg]
Code:
Général
Nom complet                              : H:\2018_11_1108_25 - Arte - La preuve par trois - Faut-il se méfier d'internet - ffmpeg.m4a
Format                                   : MPEG-4
Profil du format                         : Apple audio with iTunes info
Identifiant du codec                     : M4A  (isom/iso2)
Taille du fichier                        : 23,6 Mio
Durée                                    : 26 min 0s
Type de débit global                     : Constant
Débit global moyen                       : 127 kb/s
Application utilisée                     : Lavf58.19.102

Audio
ID                                       : 1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Identifiant du codec                     : mp4a-40-2
Durée                                    : 26 min 0s
Type de débit                            : Constant
Débit                                    : 125 kb/s
Canaux                                   : 2 canaux
Channel layout                           : L R
Echantillonnage                          : 48,0 kHz
Images par seconde                       : 46,875 Im/s (1024 SPF)
Mode de compression                      : Avec perte
Taille du flux                           : 23,3 Mio (99%)
Default                                  : Oui
AlternateGroup/String                    : 1
[mp4box]
Code:
Général
Nom complet                              : H:\2018_11_1108_25 - Arte - La preuve par trois - Faut-il se méfier d'internet - mp4box.m4a
Format                                   : MPEG-4
Profil du format                         : Apple audio with iTunes info
Identifiant du codec                     : M4A  (isom/M4A /mp42)
Taille du fichier                        : 23,6 Mio
Durée                                    : 26 min 0s
Type de débit global                     : Variable
Débit global moyen                       : 127 kb/s
Date d'encodage                          : UTC 2018-11-22 12:56:28
Date de marquage                         : UTC 2018-11-22 12:56:28

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Identifiant du codec                     : mp4a-40-2
Durée                                    : 26 min 0s
Type de débit                            : Variable
Débit                                    : 125 kb/s
Débit maximum                            : 128 kb/s
Canaux                                   : 2 canaux
Channel layout                           : L R
Echantillonnage                          : 48,0 kHz
Images par seconde                       : 46,875 Im/s (1024 SPF)
Mode de compression                      : Avec perte
Taille du flux                           : 23,3 Mio (99%)
Date d'encodage                          : UTC 2018-11-09 06:13:16
Date de marquage                         : UTC 2018-11-22 12:56:29
Does anyone know why the bitrate is reported as “variable” for the mp4box file (which is most likely correct), but “constant” for the ffmpeg one ?
Side question, is there a tool like Bitrate Viewer which can analyze the bitrate at each point of a file and generate a visual profile, but for audio files/streams ?
23. I would call it "batch processing" (which is the reason for the *.bat file name extension).

The reason for the "variable bitrate" flag in a header for a constant bitrate content is simple: MediaInfo cannot know if the bitrate is really constant because it will not scan every audio frame. It only knows that the audio stream is in a format which supports VBR (e.g. MP3 can have varying nominal bitrates per frame; and AAC can have timestamps at every frame). So it might be variable. There are also media formats which certainly support only CBR (so a reading application can only trust the one bitrate field in the header). There is no reason for concerns here.

Regarding your robocopy batch file ... It is named "robocopy.bat", therefore your robocopy.bat calls itself in the 4th line, instead of a robocopy.exe elsewhere. Windows searches for executables in the "current directory" first. Linux does not. So I would recommend to use the full qualified name of your robocopy.exe in the 4th line, or give your batch a different filename.

Apple iDevices might play M4A only if they contain an "atom" stating that they have been created by iTunes and not by any other AAC encoder ...
24. The reason for the "variable bitrate" flag in a header for a constant bitrate content is simple: MediaInfo cannot know if the bitrate is really constant because it will not scan every audio frame. It only knows that the audio stream is in a format which supports VBR (e.g. MP3 can have varying nominal bitrates per frame; and AAC can have timestamps at every frame). So it might be variable. There are also media formats which certainly support only CBR (so a reading application can only trust the one bitrate field in the header). There is no reason for concerns here.
But AAC streams are always VBR, right ? So it's the ffmpeg-generated file which apparently has an incorrect “constant bitrate” flag.

Regarding your robocopy batch file ... It is named "robocopy.bat", therefore your robocopy.bat calls itself in the 4th line, instead of a robocopy.exe elsewhere. Windows searches for executables in the "current directory" first. Linux does not. So I would recommend to use the full qualified name of your robocopy.exe in the 4th line, or give your batch a different filename.
Right, good catch... and spot-on explanation... just changing “robocopy” to “robocopy.exe” did the trick, thanks.

Apple iDevices might play M4A only if they contain an "atom" stating that they have been created by iTunes and not by any other AAC encoder ...
Then “DennisO” should test first with the target devices, but if that's the case, perhaps there's a way to add a valid iTunes “atom” without having to convert the files with iTunes itself ?
25. Originally Posted by abolibibelot
Side question, is there a tool like Bitrate Viewer which can analyze the bitrate at each point of a file and generate a visual profile, but for audio files/streams ?
Code:
@set filename=%~1
@echo type,pkt_pts_time,pkt_duration_time,pkt_pos,pkt_size,channels,channel_layout, > "%~n1.csv"
@ffprobe -select_streams a? -i "%filename%" -show_entries "frame=channels,channel_layout,pkt_pts_time,pkt_duration_time,pkt_size,pkt_pos" -of csv >> "%~n1.csv"
You can easily calculate bitrate - pkt size * 8

The AAC-comment is appreciated. I do believe my iPod can play aac-files.

But, would you guys say that .aac is as accessible today as .mp3? Are they as convenient for users? Or are there more devices that are able to play mp3-files than there are that can play aac-files?

Because I don't want to have to repeat the exercise of extracting audio from hundreds of lectures if I do decide to share the lectures.
27. MP3 support is a little better, although that probably applies mainly to cheaper dedicated devices such as MP3 players. For anything you'd normally install software on, even a smart-phone, there's usually third party players supporting formats the device's default player doesn't. AAC support is less common for cheaper devices mainly because it has to be licensed, whereas MP3 is now patent free.
28. That said, MP3 should be considered as an antiquated format... It has been around for longer than the time span separating “That's Alright Mama” from “Anarchy In The U.K.” !
(“The King is gone but he's not forgotten, is this the story of Johnny Rotten ?”)

Surprisingly, it remains the most widely used format for sharing music and audio content in general, although better (lossy) formats have been designed for quite some time, and although the increase in storage capacity and Internet bandwidth have made lossless formats a viable option. Yet switching from one format to another should be less difficult than switching between entirely different technologies like vinyle disc => compact disc, VHS => DVD, compact disc => music on computer... But MP3 has somehow become synonymous with “music on a computer” for the majority of people who are just customers and don't know or care about how it's done, while the incentive of a superior quality is not that clear, since most people don't hear any difference between a poorly encoded MP3 file and the source CD. In fact, quality is very rarely a significant factor when it comes to sorting out competing technologies or changing people's habits on a large scale.

AAC support is less common for cheaper devices mainly because it has to be licensed, whereas MP3 is now patent free.
Interesting... since when is MP3 patent free ?
But then why is OGG Vorbis so rarely implemented in standalone / portable players, although it has always been patent free ? (And is technically superior to MP3.)
29. Originally Posted by abolibibelot
Surprisingly, it remains the most widely used format for sharing music and audio content in general, although better (lossy) formats have been designed for quite some time
Better, perhaps, but most of them (unless they trying intentionally avoid potential legal issues) are based on same foundation - usually all of them are based on MDCT - differences are related to few other things (different approach to using information from transformation domain and usually more refine psychoacoustic and usually extended functionality also).

Originally Posted by abolibibelot
Interesting... since when is MP3 patent free ?
But then why is OGG Vorbis so rarely implemented in standalone / portable players, although it has always been patent free ? (And is technically superior to MP3.)
Since
https://en.wikipedia.org/wiki/MP3#Licensing,_ownership_and_legislation
MP3 technology became patent-free in the United States on 16 April 2017, when U.S. Patent 6,009,399, held[75] and administered by Technicolor,[76] expired.
OGG Vorbis is rarely implemented due of two main reasons: first being one of the youngest on market (2000 - 2003) and secondly it didn't prove to be significantly important for consumer market (marginal usage).
30. Originally Posted by abolibibelot
Interesting... since when is MP3 patent free ?
But then why is OGG Vorbis so rarely implemented in standalone / portable players, although it has always been patent free ? (And is technically superior to MP3.)
There were quite a few mp3 related patents and they've slowly been expiring. According to Wikipedia they'd all expired by mid-2017.
https://en.wikipedia.org/wiki/MP3#Licensing,_ownership_and_legislation

I think mp3's advantage was mostly that it arrived first. mp3 file sharing was pretty big by the late 90's but I don't think Vorbis was a thing until around 2000 or maybe a few years later. I'm sure Apple would've liked to only support their preferred format when the ipod was released, but by then mp3 was so wide spread even the ipod probably would've been a failure without mp3 support.

I don't know why Vorbis support didn't take off in a huge way. Maybe for players to support Vorbis it'd require a chipset able to decode it and for that to happen chipset manufactures would need some incentive, and Vorbis wouldn't have had the money behind it that mp3 did, and/or the public demand for support compared to mp3. I'm just theorising....

Even today I prefer mp3 or aac because you can't adjust the volume of Vorbis losslessly as you can for mp3/aac, and I don't know if it's even possible to edit Vorbis as you can for mp3/aac with a program such as MP3DirectCut.

While I was checking Wikipedia I stumbled across a list of the most well known players and their supported formats. MP3 is obviously mandatory, but I was surprised WMA support is still so common. Even WMA-DRM support is at roughly the same level as AAC and Vorbis. Maybe it's just me, but I thought WMA had pretty much gone the way of the dodo.
https://en.wikipedia.org/wiki/Comparison_of_portable_media_players#Audio_formats

Statistics