Yves
Yves

Reputation: 73

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

I am using the code described here http://www.ffmpeg.org/ffmpeg-all.html#mp3 to embed cover art into an 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

This works with most images such as youtube thumbnails (example that works: 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 I get the following errors

[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

I have increased both of these parameters to MAX_INT64 to no avail. Whats even weirder is that if I download the image to my desktop first and then reference it in ffmpeg from there it works!

Any ideas? Thank you!

Upvotes: 1

Views: 3687

Answers (1)

aergistal
aergistal

Reputation: 31209

The SoundCloud server sends you the image using chunked transfer encoding and for some reason ffmpeg fails to read the image to the end.

You can override the input format to jpeg_pipe.

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

Upvotes: 3

Related Questions