如何在FFMPEG中编码特定的元数据版本?

时间:2017-11-01 20:22:08

标签: encoding ffmpeg online-radio

我批量转换为更短的歌曲"广告" SHOUTcast的歌曲,并被服务器识别为广告。歌曲必须为标题和艺术家元数据标签":Advert"。当我使用以下命令时:

ffmpeg -i "$i" -c copy -vn -map_metadata -1 -metadata title=":Advert" -metadata artist=":Advert" -t 120 "adverts/ADVERT_$i"

我希望它只输出":Advert"作为标题和艺术家元数据的歌曲,但是当我将其导入收音机播放软件(使用ID3 1.x标记)时,元数据没有被复制,因此丢失。来自ffmpeg的输出:

ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.37)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --disable-lzma --enable-vda
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[mp3 @ 0x7feba6800000] Skipping 0 bytes of junk at 230934.
[mjpeg @ 0x7feba7000600] Changing bps to 8
Input #0, mp3, from 'Joakim Karud - Vibe With Me.mp3':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6mp41
    encoder         : Lavf56.40.101
    artist          : Joakim Karud
    title           : Vibe With Me
  Duration: 00:02:53.06, start: 0.025056, bitrate: 138 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
    Metadata:
      encoder         : Lavc56.60
    Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 90k tbr, 90k tbn, 90k tbc
    Metadata:
      comment         : Cover (front)
Output #0, mp3, to 'adverts/ADVERT_Joakim Karud - Vibe With Me.mp3':
  Metadata:
    TIT2            : :Advert
    TPE1            : :Advert
    TSSE            : Lavf57.25.100
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=    1876kB time=00:02:00.00 bitrate= 128.1kbits/s speed=1.44e+03x
video:0kB audio:1876kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.024837%

我相信这种情况正在发生,因为标签名称不同(例如标题应为title,但在输出时为TIT2。请有人指定我如何确保元数据在ID3 1.x格式,以便无线电播放软件可读。非常感谢。

1 个答案:

答案 0 :(得分:0)

默认情况下,FFmpeg仅写入ID3v2.5标记。必须指定ID3v1进行写入。

使用

ffmpeg -i "$i" -c copy -vn -write_id3v1 true -map_metadata -1 -metadata title=":Advert" -metadata artist=":Advert" -t 120 "adverts/ADVERT_$i"