使用 ffmpeg 将封面艺术嵌入 mp3 不适用于某些图像

Using ffmpeg to embed cover art into mp3 does not work with some images

我正在使用此处描述的代码 http://www.ffmpeg.org/ffmpeg-all.html#mp3 将封面艺术嵌入到 mp3 中:

ffmpeg -i input.mp3 -i cover.jpg -c copy -map 0 -map 1 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3

这适用于大多数图像,例如 youtube 缩略图(有效示例:https://i.ytimg.com/vi/ubkWrjeCNGI/hqdefault.jpg), however when I try to embed any cover art from soundcloud such as https://i1.sndcdn.com/artworks-000174313329-x742lv-t500x500.jpg 我收到以下错误

[image2 @ 0x7fb009008600] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options

https://i1.sndcdn.com/artworks-000174313329-x742lv-t500x500.jpg: could not find codec parameters

[mp3 @ 0x7fb009029a00] dimensions not set

Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

我已将这两个参数都增加到 MAX_INT64 但无济于事。更奇怪的是,如果我先将图像下载到我的桌​​面,然后从那里在 ffmpeg 中引用它,它就可以工作了!

有什么想法吗?谢谢!

SoundCloud 服务器使用分块传输编码向您发送图像,但出于某种原因 ffmpeg 无法读取图像到最后。

您可以将输入格式改写为 jpeg_pipe

ffmpeg -i test.mp3 -f jpeg_pipe -i https://...