带有图片的mp3上的ffmpeg amix过滤器

时间:2018-11-09 19:12:31

标签: ffmpeg

我使用ffmpeg用amix过滤器连接2个mp3文件(请参阅完整日志)。

它对于没有任何元数据的mp3文件可以很好地工作,但是对于元数据中带有封面图像的mp3文件却失败,结果文件长度小于1秒。

如何用同一命令修复它?

这里是完整日志:

localhost:Music user$ ffmpeg -i input.mp3 -i /opt/docker/tag_long.mp3 -filter_complex amix=inputs=2:duration=shortest,volume=2 -codec:a libmp3lame -q:a 5  out.mp3 -report
ffmpeg started on 2018-11-11 at 13:19:50
Report written to "ffmpeg-20181111-131950.log"
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-videotoolbox
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[mp3 @ 0x7fe506000000] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'input.mp3':
  Metadata:
    artist          : Paul
    album           : Underground Vol. 17
    title           : Crazy
    track           : 11/20
    date            : 2017
  Duration: 00:04:46.23, start: 0.000000, bitrate: 324 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
    Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 500x500 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
    Metadata:
      comment         : Cover (front)
[mp3 @ 0x7fe50601aa00] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from '/opt/docker/tag_long.mp3':
  Metadata:
    genre           : Blues
    id3v2_priv.XMP  : <?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?>\x0a<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160302, 2017/03/02-16:59:38        ">\x0a <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\x0a  <rdf
  Duration: 00:06:35.27, start: 0.000000, bitrate: 128 kb/s
    Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
File 'out.mp3' already exists. Overwrite ? [y/N] Y
Stream mapping:
  Stream #0:0 (mp3float) -> amix:input0 (graph 0)
  Stream #1:0 (mp3float) -> amix:input1 (graph 0)
  volume (graph 0) -> Stream #0:0 (libmp3lame)
  Stream #0:1 -> #0:1 (mjpeg (native) -> png (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7fe506045000] deprecated pixel format used, make sure you did set range correctly
[mp3 @ 0x7fe507810000] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
Output #0, mp3, to 'out.mp3':
  Metadata:
    TPE1            : Paul
    TALB            : Underground Vol. 17
    TIT2            : Crazy
    TRCK            : 11/20
    TDRC            : 2017
    TSSE            : Lavf58.20.100
    Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp (default)
    Metadata:
      encoder         : Lavc58.35.100 libmp3lame
    Stream #0:1: Video: png, rgb24(progressive), 500x500 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 90k fps, 90k tbn, 90k tbc
    Metadata:
      comment         : Cover (front)
      encoder         : Lavc58.35.100 png
frame=    1 fps=0.0 q=-0.0 Lsize=     496kB time=00:00:00.26 bitrate=15501.4kbits/s speed=0.336x    
video:495kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.084876%

2 个答案:

答案 0 :(得分:1)

您遇到的错误已得到修复。 FFmpeg的开发非常活跃,这就是为什么您应该始终尝试使用最新的ffmpeg版本的示例,尤其是在遇到问题时。

avfilter/af_amix: switch to activate已在2017年8月26日修复了混合悬挂问题。因此,请使用比该版本更新的版本,例如3.4版本或更高版本,或者最好是git master分支的最新版本。

有关到Linux,macOS和Windows的最新ffmpeg的静态构建的链接,请参见FFmpeg Download页。或者,请参见FFmpeg Wiki以获得编译指南。

答案 1 :(得分:0)

好的,通过添加-vn选项进行修复