首页 > 解决方案 > 在将 OGG 音频转换为 MP3 时,FFMPEG 在文件开头添加了额外的内容

问题描述

我使用以下内容ffmpeg -i <ogg-file> <mp3-file>将 ogg 音乐文件转换为 mp3。但是,我意识到某些 ogg 文件上生成的 mp3 文件稍长,并且在开头包含原始文件前半秒的重复。(听 MP3 时这很烦人)。

还有其他人遇到过类似的问题吗?

仅供参考,我使用的是 ffmpeg 版本 4.0.3,它libmp3lame用作 MP3 输出的编码器。


根据评论中的要求,这是@ffmpeg@ 的完整日志

$ ffmpeg -i track.ogg track.mp3
ffmpeg version 4.0.3 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, ogg, from 'track.ogg':
  Duration: 00:04:47.11, start: 0.000000, bitrate: 112 kb/s
    Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 112 kb/s
    Metadata:
      ARTIST          : artist
Stream mapping:
  Stream #0:0 -> #0:0 (vorbis (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to 'track.mp3':
  Metadata:
    TSSE            : Lavf58.12.100
    Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp
    Metadata:
      ARTIST          : artist
      encoder         : Lavc58.18.100 libmp3lame
[ogg @ 0x5645711ebdc0] Invalid picture type: -2555935.
[ogg @ 0x5645711ebdc0] Could not read mimetype from an attached picture.
[ogg @ 0x5645711ebdc0] Invalid picture type: -2555935.
[ogg @ 0x5645711ebdc0] Could not read mimetype from an attached picture.
size=    4497kB time=00:04:47.79 bitrate= 128.0kbits/s speed=50.8x    
video:0kB audio:4497kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.005494%

奇怪的是错误消息Invalid picture type,而 ogg 文件不包含任何封面照片。并查看长度的差异:

$ soxi -D track.ogg 
287.111837
$ soxi -D track.mp3 
287.817007

标签: audioffmpegogglamemp3

解决方案


推荐阅读