使用 ffmpeg 剪切 mp3 文件时保留专辑封面

使用 ffmpeg 剪切 mp3 文件时保留专辑封面

我尝试使用 ffmpeg 剪切 mp3 文件但也保留其专辑封面。

我发现,如果剪辑从 00:00:00 开始,它会保留专辑封面,如果不是,它就不会保留。

我收到一条错误消息:

[mp3 @ 03f30060] 部分附加图片未发送数据包。

以下是命令行参数。

ffmpeg  -y -i "C:\mp3\The Official UK Top 40
 Singles Chart 20130728\02 One Direction - Best Song Ever.mp3"  -vcodec copy  -a
codec libmp3lame  -ss 00:00:50.546 -t 8.66 -map_metadata 0  -write_id3v2 1 -id3v
2_version 3  "C:\mp3\The Official UK Top 40 Singles Chart 20130728\02 One Direct
ion - Best Song Ever_cut.mp3"

ffmpeg version N-60321-g4d7d9a5 Copyright (c) 2000-2014 the FFmpeg developers
  built on Feb  2 2014 22:01:03 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 63.100 / 52. 63.100
  libavcodec     55. 49.101 / 55. 49.101
  libavformat    55. 29.101 / 55. 29.101
  libavdevice    55.  7.100 / 55.  7.100
  libavfilter     4.  1.102 /  4.  1.102
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mp3, from 'C:\mp3\The Official UK Top 40 Singles Chart 20130728\02 One
 Direction - Best Song Ever.mp3':
  Metadata:
    album_artist    : Various Artists
    encoded_by      : Tag&Rename 3.6.6
    title           : Best Song Ever
    artist          : One Direction
    track           : 02
    album           : The Official Uk Top 40 Singles Chart 28-07-2013
    TRSN            : http://www.oldskoolscouse.co.uk/
    genre           : Pop
    TCMP            : 1
    date            : 2013
  Duration: 00:03:22.53, start: 0.025056, bitrate: 325 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
    Stream #0:1: Video: mjpeg, yuvj444p(pc), 600x600 [SAR 72:72 DAR 1:1], 90k tb
r, 90k tbn, 90k tbc
    Metadata:
      title           :
      comment         : Cover (front)
Output #0, mp3, to 'C:\mp3\The Official UK Top 40 Singles Chart 20130728\02 One
Direction - Best Song Ever_cut.mp3':
  Metadata:
    TPE2            : Various Artists
    TENC            : Tag&Rename 3.6.6
    TIT2            : Best Song Ever
    TPE1            : One Direction
    TRCK            : 02
    TALB            : The Official Uk Top 40 Singles Chart 28-07-2013
    TRSN            : http://www.oldskoolscouse.co.uk/
    TCON            : Pop
    TCMP            : 1
    TYER            : 2013
    TSSE            : Lavf55.29.101
    Stream #0:0: Video: mjpeg, yuvj444p, 600x600 [SAR 72:72 DAR 1:1], q=2-31, 90
k tbn, 90k tbc
    Metadata:
      title           :
      comment         : Cover (front)
    Stream #0:1: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (mp3 -> libmp3lame)
Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=-1.0 size=       0kB time=00:00:02.92 bitrate=   0.8kbits/
frame=    0 fps=0.0 q=-1.0 size=       0kB time=00:00:08.54 bitrate=   0.3kbits/
frame=    0 fps=0.0 q=-1.0 size=       0kB time=00:00:08.54 bitrate=   0.3kbits/
[mp3 @ 03f30060] No packets were sent for some of the attached pictures.
frame=    0 fps=0.0 q=-1.0 Lsize=     136kB time=00:00:08.67 bitrate= 128.8kbits
/s
video:0kB audio:136kB subtitle:0 data:0 global headers:0kB muxing overhead 0.358
529%

答案1

尝试放在-ss -t之前-i mp3

-ss用作输出选项(在 之后-i)时,ffmpeg 会丢弃输入,直到时间戳到达位置。封面流通常持续时间很短,这意味着它将被丢弃。有关详细信息,请参阅-ss中的选项说明man ffmpeg

相关内容