[FFmpeg-user] Converting mp3 with included cover art into mp4 with cover art as video fails

Rimvydas naktinis at gmail.com
Wed Oct 21 13:44:58 EEST 2020


I have an mp3 file with two streams:
Stream #0:0: Audio: mp3
Stream #0:1: Video: mjpeg

I'm trying to produce an mp4 file with two streams as well:
Stream #0:0: Audio: aac
Stream #0:1: Video: h264

Running "ffmpeg -i in.mp3 out.mp4" fails with:
[mp4 @ 0x55c1527c66c0] Could not find tag for codec h264 in stream #0,
codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?):
Invalid argument
Error initializing output stream 0:1 --

However, if I extract the image in a separate step and then mux it back, it
works as expected. This works:
ffmpeg -i in.mp3 cover.jpg
ffmpeg -y -i in.mp3 -i cover.jpg -map 0:a:0 -map 1:0 out.mp4

Also, converting to a webm container works as expected too:
ffmpeg -i in.mp3 out.webm

How come when creating an mp4 a "Video: mjpeg" stream works from ".jpg"
input, but not from ".mp3" input? How come this issue appears only when
converting to "mp4", but not to "webm". This looks like a bug, but I hope
there's a simple explanation and I'm missing something.

ffmpeg version 4.3.1-4ubuntu1
x264 version: core 160 r3011 cde9a93

Input's ffprobe stream info:
  Duration: 00:21:32.59, start: 0.011995, bitrate: 130 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
      encoder         : Lavf
    Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc,
bt470bg/unknown/unknown), 2228x2228 [SAR 300:300 DAR 1:1], 90k tbr, 90k
tbn, 90k tbc (attached pic)
      title           : Cover.jpg
      comment         : Cover (front)

Extracted cover's ffprobe stream info:
  Duration: 00:00:00.04, start: 0.000000, bitrate: 20836 kb/s
    Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc,
bt470bg/unknown/unknown), 2228x2228 [SAR 300:300 DAR 1:1], 25 tbr, 25 tbn,
25 tbc


More information about the ffmpeg-user mailing list