If it is all m4a, then the problem is a bit more complex: m4a contains timecodes, which may or may not start at zero. The concat demuxer is notorious for not considering this. In broadcast we allways convert to raw PCM (or something else that has not timestamps), then concat, then create the final output format.
Along the lines of
ffmpeg -i file1,m4a -c:a pcm_s16le -f s16le file1.pcm ;
ffmpeg -i file2,m4a -c:a pcm_s16le -f s16le file2.pcm ;
cat file2.pcm >> file1.pcm ; 
ffmpeg -f s16le -i file1.pcm -c:a aac -b:a whatever -ac whatever output.m4a


I just found out the error was due to the Stream #0, which is the cover art, and covers the actual audio track.
After removing the
cover artworks in all files, I was able to concatenate them. And the speed is quite fast : speed=1.92e+03x.

Concatenation of files is sometimes not very intuitive - this is due to the fact, that many formats contain timestamps, that may or may not start at zero, be continuous etc., depending on the creation and editing history of that file.

This is one of the reasons, why in the broadcast world formats rule, that can just be concatenated: MPEGTS (with the need to have an eye on continuity counters) or RAW (raw PCM resp. raw h.264).

If reencoding is an option I recommend you convert your original files to raw PCM, along the lines of

ffmpeg -i file1.m4a -c:a pcm_s16le -ac 2 -ar 48000 -f s16le file1.pcm
ffmpeg -i file2.m4a -c:a pcm_s16le -ac 2 -ar 48000 -f s16le file2.pcm

This will create 2 raw PCM files, with 2 channels (Stereo, -ac 2) each and a sample rate of 48KHz (-ar 48000)

You can now concatenate those files, e.g. via cat file2.pcm >> file1.pcm - this creates a new raw representation of the file with no timestamps, just the plain audio samples.

To reencode the result into AAC, you go along the lines of

ffmpeg -f s16le -ac 2 -ar 48000 -i file1.pcm -c:a aac -b:a 192K -ac 2 output.m4a

Let's break this down:

  • First I tell ffmpeg to open a file of format raw PCM (signed 16bit low endian -f s16le) containing 2 audio channels (-ac 2) of 48KHz sample rate (-ar 48000) and stored in file1.pcm (as usual with ffmpeg, the order of the parameters is important)
  • then to reencode with AAC (-c:a) and a bandwidth of 192Kbit/s (-ba:a) again in stereo (-ac 2)



深入挖掘 M4A 和常见问题解答
问: .MP4 和 .M4A 有什么区别?
答: .MP4 与 .M4A:.m4a 简而言之,只能包含 MPEG 4 音频,是用于表示音频文件的文件扩展名。但是 .mp4 可能包含也可能不包含 MPEG 4 音频,并且可以用于 MPEG 4 视频文件。.m4a 文件扩展名用于包含有损 AAC 或其自身无损 ALAC 格式音频数据的 MP4 容器。标准中的 m4a 文件用于 iTunes DRM 不受保护的内容,而 .mp4 或 .m4v 文件用于受 iTunes DRM 复制保护的内容。

问: M4A 音频文件和 AAC 音频文件之间是否有区别,或者它们完全相同但文件扩展名不同?
A: AAC是一种音频编码方案,而M4A只是一种文件扩展名。AAC 编码的音频可以具有 AAC、MP4 和 M4A 扩展名。

问:我的 iTunes 库中的一些音乐文件是 M4A 与 M4P。这是为什么?
答:这些文件中包含数字版权管理以限制用户共享文件的能力。DRM 总是在 M4P 文件上出售,而 M4A 文件没有限制,并且没有 DRM。Apple M4P 文件以 128 比特率出售,这远低于速度为 256 kbps 的 M4A 文件所需的比特率。


 2020-10-19阅读 2740
安装FFmpeg flac

eric@ray:~$ sudo apt install FFmpeg flac
安装lame faac

eric@ray:~$ sudo apt install lame faac

1、首先用ffmpeg命令或者flac 命令将它转换成mav格式,再用lame将wav转换成mp4格式

eric@ray:~/Music$ ffmpeg -i Gracie-Theme.ape Gracie-Theme.wav


eric@ray:~/Music$ flac -d Gracie-Theme.flac Gracie-Theme.wav
2、再使用lame命令 压缩成MP3


eric@ray:~/Music$ lame -v Gracie-Theme.wav

##或者使用faac编码得到m4a(mp4)、mp3格式文件:100表示质量最高 100% 

eric@ray:~/Music$ faac -w -q 100 Gracie-Theme.wav -o Gracie-Theme.mp4


eric@ray:~/Music$ ffmpeg -i Gracie-Theme.wav -strict experimental -c:a aac -b:a 320k Gracie-Theme.m4a

#还可以使用ffmpeg将解压和压缩为一条命令:-map_metadata 表示保留歌曲元数据,即名称、演唱者等

eric@ray:~/Music$ ffmpeg -i Gracie-Theme.flac -ab 320k -map_metadata 0 Gracie-Theme.m4a


for FILE in *.ape;
ffmpeg -i "$FILE" temp.wav;
lame -b 320 temp.wav "${FILE%.*}.mp3";
rm temp.wav



eric@ray:~/Music$mp3splt -c song.cue -o @n.@t song.mp3







eric@ray:~/Music$ffmpeg -i first.mp3 -i second.mp3 -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f mp3 third.mp3


eric@ray:~/Music$ffmpeg -i d1.mp3 -i d2.mp3 -filter_complex '[0:0] [1:0] concat=n=2:v=0:a=1 [a]' -map [a] j5.mp3


eric@ray:~/Music$ffmpeg -i 片头.wav -i 内容.WAV -i 片尾.wav -filter_complex '[0:0] [1:0] [2:0] concat=n=3:v=0:a=1 [a]' -map [a] 合成.wav

FFmpeg and AAC Encoding Guide https://trac.ffmpeg.org/wiki/Encode/AAC 


1 多个mp3文件合并成一个mp3文件

ffmpeg64.exe -i "concat:123.mp3|124.mp3" -acodec copy output.mp3
           -acodec copy output.mp3 重新编码并复制到新文件中
ffmpeg64.exe -i 124.mp3 -i 123.mp3 -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f mp3 remix.mp3
           -filter_complex ffmpeg滤镜功能,非常强大,详细请查看文档
           duration 确定最终输出文件的长度
The transition time, in seconds, for volume renormalization when an input stream ends. The default value is 2 seconds.
            -f mp3  输出文件格式
2 音频文件截取指定时间部分
ffmpeg64.exe -i 124.mp3 -vn -acodec copy -ss 00:00:00 -t 00:01:32 output.mp3
          -acodec copy output.mp3 重新编码并复制到新文件中
           -ss 开始截取的时间点
           -t 截取音频时间长度
3 音频文件格式转换
ffmpeg64.exe -i null.ape -ar 44100 -ac 2 -ab 16k -vol 50 -f mp3 null.mp3
           -acodec aac(音频编码用AAC) 
          -ar 设置音频采样频率
          -ac  设置音频通道数
          -ab 设定声音比特率
           -vol <百分比> 设定音量
阅读量: 515