我想在ubuntu上合并mp3文件



我想使用以下命令将mp3文件合并为一个文件:

ffmpeg -i "concat:file_1.mp3|file_2.mp3|file_3.mp3|file_4.mp3" -c copy test.mp3

但我得到了这个错误:

[mp3 @ 0x5629416b4880] Invalid audio stream. Exactly one MP3 audio stream is required.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Last message repeated 1 times

我尝试使用cat和mp3wrap,但它只复制了第一个文件

我想提到的是,mp3文件是使用pyaudio 录制的

编辑:我使用了这个命令:

ffmpeg -y -i "concat:file_1.mp3|file_2.mp3|file_3.mp3|file_4.mp3" test.mp3

它似乎在工作,但它只复制了第一个文件,而没有合并

文件。

命令:

ffmpeg -y -i "concat:39492fr_man_1.mp3|39492fr_man_2.mp3|39492fr_man_3.mp3|39492fr_man_4.mp3" 39492_fr_man.mp3

输出:

ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from 'concat:39492fr_man_1.mp3|39492fr_man_2.mp3|39492fr_man_3.mp3|39492fr_man_4.mp3':
Duration: 00:04:40.06, bitrate: 2460 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to '39492_fr_man.mp3':
Metadata:
TSSE            : Lavf58.29.100
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, mono, s16p
Metadata:
encoder         : Lavc58.54.100 libmp3lame
size=    2188kB time=00:04:40.05 bitrate=  64.0kbits/s speed= 134x
video:0kB audio:2188kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.010131%

命令:ffmpeg -i 39492fr_man_1.mp3 -i 39492fr_man_2.mp3 -i 39492fr_man_3.mp3 -i 39492fr_man_4.mp3

输出:

Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from '39492fr_man_1.mp3':
Duration: 00:04:40.06, bitrate: 705 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
Guessed Channel Layout for Input Stream #1.0 : mono
Input #1, wav, from '39492fr_man_2.mp3':
Duration: 00:04:40.54, bitrate: 705 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
Guessed Channel Layout for Input Stream #2.0 : mono
Input #2, wav, from '39492fr_man_3.mp3':
Duration: 00:04:39.50, bitrate: 705 kb/s
Stream #2:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
Guessed Channel Layout for Input Stream #3.0 : mono
Input #3, wav, from '39492fr_man_4.mp3':
Duration: 00:02:16.42, bitrate: 705 kb/s
Stream #3:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
At least one output file must be specified

您的输入实际上不是MP3。这些实际上是名为MP3的WAV文件。所以你不能使用-c copy。您无法将pcm_s16le("WAV"(复制到MP3中,因此会出现Invalid audio stream错误。

concat协议几乎毫无用处。使用concat解复用器或concat筛选器。在这种情况下,你使用哪一个并不重要,所以使用对你来说更方便的。

concat解复用器

  1. 使input.txt包含:

    file '39492fr_man_1.mp3'
    file '39492fr_man_2.mp3'
    file '39492fr_man_3.mp3'
    file '39492fr_man_4.mp3'
    
  2. 连接:

    ffmpeg -f concat -i input.txt output.mp3
    

凹面过滤器

ffmpeg -i 39492fr_man_1.mp3 -i 39492fr_man_2.mp3 -i 39492fr_man_3.mp3 -i 39492fr_man_4.mp3 -filter_comples "[0:a][1:a][2:a][3:a]concat=n=4:a=1:v=0" output.mp3

相关内容

  • 没有找到相关文章

最新更新