FFmpeg 元数据不复制

FFmpeg 元数据不复制

我正在尝试将大量.flac文件转换为.aiff以便与 iTunes 一起使用。需要注意的是,我是在 Windows 上使用 GIT Bash 执行此操作的。

我用来转换文件的命令如下:

for f in *.flac; do "c:/FFmpeg/bin/ffmpeg" -i "$f" -i cover.png -map_metadata 0 "D:\Music\Monstercat\Monstercat 001 - Launch Week (apple)\\${f%.flac}.aiff"; done

代码本身基本完成了预期的工作。它循环遍历所有文件,抓取封面图片,将文件转换为.aiff,然后将其导出到正确的文件夹中。

以下是某个转换周期的示例输出:

ffmpeg version N-83410-gb1e2192 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 46.100 / 55. 46.100
  libavcodec     57. 75.100 / 57. 75.100
  libavformat    57. 66.101 / 57. 66.101
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 72.100 /  6. 72.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, flac, from 'Stephen Walking - Monstercat 001 - Launch Week - 7 Still Walking.flac':
  Metadata:
    ENCODER         : Lavf56.15.102
    TITLE           : Still Walking
    ARTIST          : Stephen Walking
    ALBUM           : Monstercat 001 - Launch Week
    track           : 7
    GENRE           : Dubstep
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
    Stream #0:1: Video: png, rgb24(pc), 1024x1024 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
    Metadata:
      comment         : Cover (front)
Input #1, png_pipe, from 'cover.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgb24(pc), 1024x1024 [SAR 72:72 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
Output #0, aiff, to 'D:\Music\Monstercat\Monstercat 001 - Launch Week (apple)\Stephen Walking - Monstercat 001 - Launch Week - 7 Still Walking.aiff':
  Metadata:
    GENRE           : Dubstep
    TITLE           : Still Walking
    ARTIST          : Stephen Walking
    ALBUM           : Monstercat 001 - Launch Week
    track           : 7
    encoder         : Lavf57.66.101
    Stream #0:0: Video: png, rgb24, 1024x1024 [SAR 72:72 DAR 1:1], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.75.100 png
    Stream #0:1: Audio: pcm_s16be (NONE / 0x454E4F4E), 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc57.75.100 pcm_s16be
Stream mapping:
  Stream #1:0 -> #0:0 (png (native) -> png (native))
  Stream #0:0 -> #0:1 (flac (native) -> pcm_s16be (native))
Press [q] to stop, [?] for help
frame=    1 fps=1.0 q=-0.0 Lsize=   34668kB time=00:03:21.24 bitrate=1411.2kbits/s speed= 196x
video:1262kB audio:34668kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

如图所示,原始文件具有完整的元数据,如下所示以供比较...

Metadata:
    ENCODER         : Lavf56.15.102
    TITLE           : Still Walking
    ARTIST          : Stephen Walking
    ALBUM           : Monstercat 001 - Launch Week
    track           : 7
    GENRE           : Dubstep

但是,当我将目标文件导入 iTunes 时,没有保留任何元数据。需要注意的是,原始命令缺少该-map_metadata 0部分,因为添加该部分是为了查看它是否会强制写入元数据。还要注意的是,我曾尝试将元数据导出到文本文件,然后将其合并到目标文件中,结果相同。

以下是输出文件中的 FFprobe 输出:

ffprobe version N-83410-gb1e2192 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 46.100 / 55. 46.100
  libavcodec     57. 75.100 / 57. 75.100
  libavformat    57. 66.101 / 57. 66.101
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 72.100 /  6. 72.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, aiff, from 'Stephen Walking - Monstercat 001 - Launch Week - 7 Still Walking.aiff':
  Metadata:
    title           : Still Walking
  Duration: 00:03:21.25, start: 0.000000, bitrate: 1411 kb/s
    Stream #0:0: Audio: pcm_s16be, 44100 Hz, 2 channels, s16, 1411 kb/s

由于某种原因,只title导入了元数据标签,而忽略了其余标签。此外,当导入到 iTunes 时,会报告歌曲的标题,Stephen Walking - Monstercat 001 - Launch Week - 7 Still Walking.aiff而不是Still Walking

任何帮助都将不胜感激。我已经为此工作了几个小时,但仍然不知所措。

此外,如果有人想让我的 for 循环更高效,还可以获得加分。原始文件夹是D:\Music\Monstercat\Monstercat 001 - Launch Week,目标是D:\Music\Monstercat\Monstercat 001 - Launch Week (apple)

谢谢

答案1

您必须启用标签写入。

c:/FFmpeg/bin/ffmpeg" -i "$f" -i cover.png -map_metadata 0 -write_id3v2 1 "D:\Music\Monstercat\Monstercat 001 - Launch Week (apple)\\${f%.flac}.aiff

相关内容