简体   繁体   English

我想合并 ubuntu 上的 mp3 文件

[英]I want to merge mp3 files on ubuntu

I want to merge mp3 files into one file using this command:我想使用以下命令将 mp3 文件合并到一个文件中:

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

But i get this error:但我得到这个错误:

[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

I tried to use cat and mp3wrap but it only duplicates the first file我尝试使用 cat 和 mp3wrap 但它只复制第一个文件

I would like to mention that the mp3 files are a recorded ones using pyaudio我想提一下,mp3 文件是使用 pyaudio 录制的文件

Edit: i used this command:编辑:我使用了这个命令:

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

and it seems to be working but it only duplicates the first file not merging the它似乎正在工作,但它只复制第一个文件而不合并

files.文件。

Command:命令:

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

The output: output:

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%

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

Output: Output:

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

You inputs are not actually MP3.您的输入实际上不是 MP3。 These are actually WAV files named as MP3.这些实际上是名为 MP3 的 WAV 文件。 So you can't use -c copy .所以你不能使用-c copy You can't copy pcm_s16le ("WAV") into MP3, so that's why you got the Invalid audio stream error.您无法将 pcm_s16le ("WAV") 复制到 MP3 中,这就是为什么您收到Invalid audio stream错误的原因。

The concat protocol is almost useless. concat 协议几乎没用。 Use the concat demuxer or the concat filter .使用concat demuxerconcat filter It doesn't matter which one you use in this case, so use whichever is more convenient for you.在这种情况下使用哪一个并不重要,因此请使用对您更方便的那个。

concat demuxer连接分路器

  1. Make input.txt containing:使input.txt包含:

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

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

concat filter连接过滤器

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM