通常,当我运行 时ffmpeg -i "$name.$oldext" "$name.ogg"
,其中oldext
是.opus
、.m4a
或中的任何一个.flac
,所有元数据都会被保留。但是,我刚刚发现,在初始文件是 的特定情况下,其中.opus
嵌入了封面图像,结果 上不存在任何元数据.ogg
。转换为.flac
也是一样。转换为.mp3
会保留嵌入的封面,但不保留其他元数据。
在这种情况下,我该怎么做才能保留元数据?或者,是否有一个简单的脚本可以批量将元数据从一个文件复制到另一个文件。多次一对一复制,而不是一对多复制(我已经可以做到这一点)。
命令的当前输出:
ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=
/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --dis
able-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth
--enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio
--enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --
enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enab
le-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-l
ibtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265
--enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libie
c61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=harden
ed --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-
shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enab
le-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --en
able-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enab
le-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-li
brtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libss
h --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --en
able-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --
enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-version3 --disable-do
c --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc
--disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwben
c
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[ogg @ 0x7e90a0] 1 bytes of comment header remain
[mjpeg @ 0x7eb020] Changeing bps to 8
Input #0, ogg, from '148 - Mewmore _ 'Zelda's Lullaby' (Remix) from The Legend of Zelda - Breath of the Wild.opus':
Duration: 00:02:50.87, start: 0.000000, bitrate: 153 kb/s
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
TITLE : 'Zelda's Lullaby' (Remix) from The Legend of Zelda - Breath of the Wild
ARTIST : Mewmore
album_artist : Mewmore
ALBUM : Mewmore Remixes
track : 148
GENRE : Zelda Remixes
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)
title : 00001 - Mewmore _ 'Zelda's Lullaby' (Remix) from The Legend of Zelda - Breath of the Wild.jpg
[swscaler @ 0x7f9c60] deprecated pixel format used, make sure you did set range correctly
[ogg @ 0x816980] 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 '148 - Mewmore _ 'Zelda's Lullaby' (Remix) from The Legend of Zelda - Breath of the Wild.ogg':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: theora (libtheora), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k fps, 90k tbn, 90k tbc
Metadata:
DESCRIPTION : Cover (front)
title : 00001 - Mewmore _ 'Zelda's Lullaby' (Remix) from The Legend of Zelda - Breath of the Wild.jpg
encoder : Lavc56.60.100 libtheora
Stream #0:1: Audio: vorbis (libvorbis), 48000 Hz, stereo, fltp
Metadata:
TITLE : 'Zelda's Lullaby' (Remix) from The Legend of Zelda - Breath of the Wild
ARTIST : Mewmore
ALBUMARTIST : Mewmore
ALBUM : Mewmore Remixes
TRACKNUMBER : 148
GENRE : Zelda Remixes
encoder : Lavc56.60.100 libvorbis
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg (native) -> theora (libtheora))
Stream #0:0 -> #0:1 (opus (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
[libvorbis @ 0x85cb60] Queue input is backward in time
Last message repeated 1 times
frame= 1 fps=0.0 q=-0.0 size= 8kB time=00:00:22.54 bitrate= 2.7kbits/s ^M[libvorbis @ 0x85cb60] Queue input is backward in time
frame= 1 fps=1.0 q=-0.0 size= 8kB time=00:00:45.99 bitrate= 1.3kbits/s ^M[libvorbis @ 0x85cb60] Queue input is backward in time
Last message repeated 4 times
frame= 1 fps=0.7 q=-0.0 size= 8kB time=00:01:09.31 bitrate= 0.9kbits/s ^M[libvorbis @ 0x85cb60] Queue input is backward in time
Last message repeated 3 times
frame= 1 fps=0.5 q=-0.0 size= 8kB time=00:01:32.72 bitrate= 0.7kbits/s ^M[libvorbis @ 0x85cb60] Queue input is backward in time
Last message repeated 2 times
frame= 1 fps=0.4 q=-0.0 size= 8kB time=00:01:56.22 bitrate= 0.5kbits/s ^M[libvorbis @ 0x85cb60] Queue input is backward in time
Last message repeated 3 times
frame= 1 fps=0.3 q=-0.0 size= 8kB time=00:02:19.43 bitrate= 0.4kbits/s ^M[libvorbis @ 0x85cb60] Queue input is backward in time
Last message repeated 1 times
frame= 1 fps=0.3 q=-0.0 size= 8kB time=00:02:42.63 bitrate= 0.4kbits/s ^Mframe= 1 fps=0.3 q=-0.0 Lsize= 2385kB time=00:02:50.84 bitrate= 114.4kbits/s
video:5kB audio:2351kB subtitle:0kB other streams:0kB global headers:7kB muxing overhead: 1.256185%
将命令改为ffmpeg -i "$name.$oldext" -map-metadata 0 "$name.ogg"
没有什么区别。
附注:我刚刚注意到 - 根据默认缩略图,结果是一个视频文件(原始文件是音频)。尝试在仅播放音乐的播放器中收听失败。如果我通过路由,.flac
结果.ogg
就是音频。
答案1
在查看了 SE 和 ffmpeg 文档几个小时后,我终于找到了一个简单的解决方案:使用-map_metadata 0:s:a:0
,将元数据从第一个输入文件(0:
)、第一个音频流(s:a:0
)(元数据所在的位置)复制到所有输出文件(全局元数据)。