我的目的是在仅包含音频的 ogg 文件中添加封面艺术,而不将其创建为视频。
\n输出:ffrobe audio.ogg
\nInput #0, ogg, from 'audio.ogg':\n Duration: 00:03:26.60, start: 0.000000, bitrate: 385 kb/s\n Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 320 kb/s\n Metadata:\n encoder : Lavc59.12.100 libvorbis\n album : CMG Cl\xc3\xa1ssicos Pop Rock Nacionais\n artist : Lob\xc3\xa3o\n date : 1988\n genre : Cl\xc3\xa1ssico Pop Rock Nacional\n TKEY : E m\n title : Cuidado!\n
Run Code Online (Sandbox Code Playgroud)\n我使用下面的命令,但封面艺术在输出文件中生成为视频:
\nffmpeg -i "audio.ogg" -i "Cover.jpg" -map 0:a -map 1:v -c:a libvorbis -b:a 320k -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -disposition:v attached_pic "audio_video.ogg" \n
Run Code Online (Sandbox Code Playgroud)\n生成文件时,屏幕上会出现几行消息 Non-monotonic DTS:
\n[ogg @ 000001ced2dafa00] Non-monotonous DTS in output stream 0:0; previous: 8802752, current: 8802432; changing to 8802752. This may result in incorrect timestamps in the output file.\n[ogg @ 000001ced2dafa00] Non-monotonous DTS in output stream 0:0; previous: 8802752, current: 8802560; changing to 8802752. This may result in incorrect timestamps in the output file.\n[ogg @ 000001ced2dafa00] Non-monotonous DTS in output stream 0:0; previous: 8802752, current: 8802688; changing to 8802752. This may result in incorrect timestamps in the output file.\n[libvorbis @ 000001ced2db0a40] Queue input is backward in time\n Last message repeated 14 times\n[libvorbis @ 000001ced2db0a40] Queue input is backward in timetrate= 0.3kbits/s speed=25.3x\n Last message repeated 1 times\nframe= 1 fps=0.1 q=-0.0 Lsize= 9570kB time=00:03:26.59 bitrate= 379.5kbits/s speed=25.4x\nvideo:15kB audio:9494kB subtitle:0kB other streams:0kB global headers:7kB muxing overhead: 0.638836%\n
Run Code Online (Sandbox Code Playgroud)\n最后,生成文件,但图稿在文件中显示为视频流。
\n输出:ffrobe audio_video.ogg
\nInput #0, ogg, from 'audio_video.ogg':\n Duration: 00:03:26.60, start: 0.000000, bitrate: 379 kb/s\n Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 320 kb/s\n Metadata:\n artist : Lob\xc3\xa3o\n album : CMG Cl\xc3\xa1ssicos Pop Rock Nacionais\n genre : Cl\xc3\xa1ssico Pop Rock Nacional\n title : Cuidado!\n TKEY : E m\n date : 1988\n encoder : Lavc59.21.100 libvorbis\n Stream #0:1: Video: theora, yuv420p, 1018x1023 [SAR 1:1 DAR 1018:1023], 25 tbr, 25 tbn\n Metadata:\n title : Album cover\n comment : Cover (front)\n encoder : Lavc59.21.100 libtheora\n
Run Code Online (Sandbox Code Playgroud)\n如何在不生成视频流且没有非单调 DTS 消息行的情况下添加图像?
\n@mashuptwice我使用了链接中建议的命令,但它不起作用。见下文:
\nffmpeg -i "audio.ogg" -map 0 -c:a copy -c copy -metadata:s:a METADATA_BLOCK_PICTURE="$(base64 --wrap 0 Cover.jpg)" "audio_cover.ogg"\n
Run Code Online (Sandbox Code Playgroud)\n输出:带有 METADATA_BLOCK 的命令 ffmpeg
\nInput #0, ogg, from 'audio.ogg':\n Duration: 00:03:26.60, start: 0.000000, bitrate: 385 kb/s\n Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 320 kb/s\n Metadata:\n encoder : Lavc59.21.100 libvorbis\n album : CMG Cl\xc3\xa1ssicos Pop Rock Nacionais\n genre : Cl\xc3\xa1ssico Pop Rock Nacional\n title : Cuidado!\n TKEY : E m\n date : 1988\n artist : Lob\xc3\xa3o\nOutput #0, ogg, to 'audio_cover.ogg':\n Metadata:\n encoder : Lavf59.17.102\n Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 320 kb/s\n Metadata:\n encoder : Lavc59.21.100 libvorbis\n album : CMG Cl\xc3\xa1ssicos Pop Rock Nacionais\n genre : Cl\xc3\xa1ssico Pop Rock Nacional\n title : Cuidado!\n TKEY : E m\n date : 1988\n artist : Lob\xc3\xa3o\n METADATA_BLOCK_PICTURE: $(base64 --wrap 0 Cover.jpg)\nStream mapping:\n Stream #0:0 -> #0:0 (copy)\nPress [q] to stop, [?] for help\nsize= 9735kB time=00:03:26.59 bitrate= 386.0kbits/s speed=1.37e+03x\nvideo:0kB audio:9677kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 0.597793%\n
Run Code Online (Sandbox Code Playgroud)\n艺术作品已添加到元数据中?!!!,但播放歌曲时它没有显示在任何播放器中?!...我是 Windows 用户。我这么说是因为我不知道其他系统的玩家是否可以按照添加图像的方式播放图像,好吗?
\n我也用过它,一个在MKV文件中附加封面艺术的命令,但OGG似乎不接受这个命令,见下文:
\n将 ffmpeg 与 -attach 命令一起使用:
\nffmpeg -i "audio.ogg" -attach "cover.jpeg" -map 0 -c:a copy -c copy -metadata:s:t mimetype="image/jpeg" -metadata:s:t:0 filename="cover.jpeg" "audio_cover.ogg"\n
Run Code Online (Sandbox Code Playgroud)\n输出:错误
\nInput #0, ogg, from 'audio.ogg':\n Duration: 00:03:26.60, start: 0.000000, bitrate: 385 kb/s\n Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 320 kb/s\n Metadata:\n encoder : Lavc59.21.100 libvorbis\n album : CMG Cl\xc3\xa1ssicos Pop Rock Nacionais\n genre : Cl\xc3\xa1ssico Pop Rock Nacional\n title : Cuidado!\n TKEY : E m\n date : 1988\n artist : Lob\xc3\xa3o\n[ogg @ 00000164388afe40] Unsupported codec id in stream 1\nCould not write header for output file #0 (incorrect codec parameters ?): Invalid argument\nError initializing output stream 0:1 --\nStream mapping:\n Stream #0:0 -> #0:0 (copy)\n File cover.jpeg -> Stream #0:1\n
Run Code Online (Sandbox Code Playgroud)\nogg 文件不支持附加图像。它尝试将封面艺术附加到 0:1 流,但显示编解码器错误,在 MKV 文件中不会发生这种情况?
\n小智 5
尝试使用的-metadata:s:a METADATA_BLOCK_PICTURE=...
是正确的,但细节是错误的。
Base64 编码的图像数据必须根据https://xiph.org/flac/format.html#metadata_block_picture以标头为前缀
这是此类标头的示例:
$> echo -en "\0\0\0\x03\0\0\0\x0aimage/jpeg\0\0\0\x08test.jpg\0\0\0\x08\0\0\0\x0e\0\0\0\x20\0\0\0\0\0\0\x05\xad" \
> vorbis.head
$> hexdump -C vorbis.head
00000000 00 00 00 03 00 00 00 0a 69 6d 61 67 65 2f 6a 70 |........image/jp|
00000010 65 67 00 00 00 08 74 65 73 74 2e 6a 70 67 00 00 |eg....test.jpg..|
00000020 00 08 00 00 00 0e 00 00 00 20 00 00 00 00 00 00 |......... ......|
00000030 05 ad |..|
00000032
Run Code Online (Sandbox Code Playgroud)
您必须根据封面图像调整标题,尤其是宽度、高度、bpp 和原始大小,此处为 8x14@32、1453 字节(0x8、0xe、0x20、0x05ad)。
所有相关值均为 4 字节(32 位)小端字节序,即宽度为 320 时,将“\0\0\0\x08”替换为“\0\0\x01\x40”。
您可以添加带有评论的封面艺术,例如:
ffmpeg -i inpug.flac.ogg -acodec copy -map 0:a -metadata:s:a METADATA_BLOCK_PICTURE="$(cat vorbis.head cover.jpg | base64 --wrap 0)" output.flag.ogg
Run Code Online (Sandbox Code Playgroud)
这只$(cat ....)
适用于 Linux 或其他 Unixy 系统,在 Windows 上则不起作用。
归档时间: |
|
查看次数: |
2449 次 |
最近记录: |