FFmpeg 删除专辑封面

FFmpeg 删除专辑封面

每次我将歌曲编码为有损格式时,输出文件都会保留标签(标题、艺术家、专辑等...),但会删除专辑封面。

我尝试编码为任何有损格式,包括 AAC、OGG 和 OPUS。它们都会丢失专辑封面……MP3 除外。

我发现我无法将歌曲编码为 M4A 和 OGG 格式,除非我添加-vn标记,这样专辑封面就会被删除。因此,除了 M4A 和 OGG,我尝试了其他任何容器,包括 .aac、.oga、.mka。但它们也都删除了专辑封面。

我尝试过的:

ffmpeg -y -i "/storage/sdcard1/Music/01 Adam Foroush.m4a" -c:a libopus -b:a 128k -af aresample=48000:resampler=soxr:precision=33:cheby=1:dither_method=shibata -vbr on -compression_level 10 -frame_duration 60 -application audio "/storage/emulated/0/FFMPEG/01 Adam Foroush.opus"

opus-tools当我使用(编码为 OPUS)和(编码为 OGG)时,事情变得更加奇怪vorbis-tools。与 FFmpeg 不同,它们都为我提供了保留专辑封面的输出文件。但我不喜欢使用它们,因为它们的输入解码支持都很差。

关于 FFmpeg,我知道我可以将我的歌曲编码为 OPUS、OGG 或 AAC,然后在下一步中嵌入专辑封面,但这不是一个好的解决方案。

有人吗?可以帮忙吗?

答案1

我也遇到过这个问题,答案很简单,直接通过就行-c:v copy了。FFMpeg 默认尝试将任何视频编码为 h264 格式,但音频容器不支持这种格式,所以我们应该复制 .jpg 封面而不进行编码。并且请不要将有损格式转换为其他有损格式,请使用无损作为源

答案2

FFmpeg 4.4 版自动支持使用 Theora 视频编解码器将专辑封面嵌入到 Ogg 容器中(参见“Ogg 编解码器“在 Wikipedia 上查看受支持的编解码器列表,尽管 FFmpeg 可能并不支持所有这些编解码器)。

下面是将带有包含专辑封面的视频轨道的 MP3 文件转换为带有 Opus 编码音频和 Theora 编码视频的 Ogg 文件的示例:

$ ffprobe -hide_banner '01 - State of Grace.mp3' 
[mp3 @ 0x5594cbafe320] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '01 - State of Grace.mp3':
  Metadata:
    lyrics-eng      :  
    copyright       : š 2012 Big Machine Records, LLC.
    title           : State of Grace
    album_artist    : Taylor Swift
    album           : Red (Deluxe Version)
    date            : 2012
    track           : 01/22
    genre           : Country
    composer        : Taylor Swift
    disc            : 1/1
    comment         : Taylor Swift
  Duration: 00:04:55.81, start: 0.000000, bitrate: 321 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
  Stream #0:1: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 600x600 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc (attached pic)
    Metadata:
      title           : Cover
      comment         : Cover (front)
$ ffmpeg -hide_banner -i '01 - State of Grace.mp3' -c:a libopus -b:a 128000 -c:v libtheora -q:v 10 '01 - State of Grace.ogg'
[mp3 @ 0x55ebe6d3cc40] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '01 - State of Grace.mp3':
  Metadata:
    lyrics-eng      :  
    copyright       : š 2012 Big Machine Records, LLC.
    title           : State of Grace
    album_artist    : Taylor Swift
    album           : Red (Deluxe Version)
    date            : 2012
    track           : 01/22
    genre           : Country
    composer        : Taylor Swift
    disc            : 1/1
    comment         : Taylor Swift
  Duration: 00:04:55.81, start: 0.000000, bitrate: 321 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
  Stream #0:1: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 600x600 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc (attached pic)
    Metadata:
      title           : Cover
      comment         : Cover (front)
Stream mapping:
  Stream #0:1 -> #0:0 (mjpeg (native) -> theora (libtheora))
  Stream #0:0 -> #0:1 (mp3 (mp3float) -> opus (libopus))
Press [q] to stop, [?] for help
[swscaler @ 0x55ebe6db69e0] deprecated pixel format used, make sure you did set range correctly
[ogg @ 0x55ebe6d44c80] 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, ogg, to '01 - State of Grace.ogg':
  Metadata:
    lyrics-eng      :  
    copyright       : š 2012 Big Machine Records, LLC.
    title           : State of Grace
    album_artist    : Taylor Swift
    album           : Red (Deluxe Version)
    date            : 2012
    track           : 01/22
    genre           : Country
    composer        : Taylor Swift
    disc            : 1/1
    comment         : Taylor Swift
    encoder         : Lavf58.76.100
  Stream #0:0: Video: theora, yuv444p(tv, bt470bg/unknown/unknown, progressive), 600x600 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 90k fps, 90k tbn (attached pic)
    Metadata:
      title           : Cover
      DESCRIPTION     : Cover (front)
      encoder         : Lavc58.134.100 libtheora
      lyrics-eng      :  
      copyright       : š 2012 Big Machine Records, LLC.
      ALBUMARTIST     : Taylor Swift
      album           : Red (Deluxe Version)
      date            : 2012
      TRACKNUMBER     : 01/22
      genre           : Country
      composer        : Taylor Swift
      DISCNUMBER      : 1/1
  Stream #0:1: Audio: opus, 48000 Hz, stereo, flt, 128 kb/s
    Metadata:
      encoder         : Lavc58.134.100 libopus
      lyrics-eng      :  
      copyright       : š 2012 Big Machine Records, LLC.
      title           : State of Grace
      ALBUMARTIST     : Taylor Swift
      album           : Red (Deluxe Version)
      date            : 2012
      TRACKNUMBER     : 01/22
      genre           : Country
      composer        : Taylor Swift
      DISCNUMBER      : 1/1
      DESCRIPTION     : Taylor Swift
[mp3float @ 0x55ebe6d96360] Header missing time=00:04:31.63 bitrate=   0.1kbits/s speed=59.8x    64x    
Error while decoding stream #0:0: Invalid data found when processing input
frame=    1 fps=0.2 q=-0.0 Lsize=    4929kB time=00:04:55.79 bitrate= 136.5kbits/s speed=59.8x    
video:58kB audio:4830kB subtitle:0kB other streams:0kB global headers:3kB muxing overhead: 0.845459%
$ mpv '01 - State of Grace.ogg'
 (+) Video --vid=1 'Cover' (theora 600x600)
 (+) Audio --aid=1 'State of Grace' (opus 2ch 48000Hz)
AO: [alsa] 48000Hz stereo 2ch float
VO: [gpu] 600x600 yuv444p
(Paused) AV: -00:00:00 / 00:04:55 (0%)

Exiting... (Quit)
$ 

我在这里写了关于如何做到这一点的更详细的答案:https://stackoverflow.com/a/70166081/17549713

相关内容