Opened 12 months ago

Closed 6 months ago

#8947 closed defect (invalid)

Converting mp3 with cover art into mp4 with cover art as video fails

Reported by: naktinis Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

I'm trying to convert an mp3 (mp3 + mjpeg) into mp4 (aac + h264).

ffmpeg -i in.mp3 out.mp4

Fails with "Could not find tag for codec h264 in stream #0, codec not currently supported in container". I tried various parameters like setting frame rate, using stream_loop, but nothing helps and looks like the problem is at a different level. Also, tried multiple different input files and the same thing happens every time.

ffmpeg -i in.mp3 cover.jpg
ffmpeg -i in.mp3 -i cover.jpg -map 0:a:0 -map 1:0 out.mp4

Extracting the cover and muxing from two separate files works fine.

ffmpeg -i in.mp3 out.webm

Converting to webm instead of mp4 works fine as well (sure, you need to set the framerate to see the cover, but with mp4 you always get an error, and nothing I tried helps).

Built with the lastest branch: 343c3149ab.
Input file attached.

How to reproduce:

% ./ffmpeg -i bunny_with_cover.mp3 out.mp4
ffmpeg version N-99744-g343c3149ab Copyright (c) 2000-2020 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.2)
  configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid --samples=fate-suite
  libavutil      56. 60.100 / 56. 60.100
  libavcodec     58.112.100 / 58.112.100
  libavformat    58. 63.100 / 58. 63.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 88.100 /  7. 88.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, mp3, from '/Users/naktinis/data/audio/bunny_with_cover.mp3':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Lavf58.45.100
  Duration: 00:00:10.03, start: 0.025056, bitrate: 156 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.91
    Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 640x360 [SAR 1:1 DAR 16:9], 90k tbr, 90k tbn, 90k tbc (attached pic)
    Metadata:
      comment         : Other
Stream mapping:
  Stream #0:1 -> #0:0 (mjpeg (native) -> h264 (libx264))
  Stream #0:0 -> #0:1 (mp3 (mp3float) -> aac (native))
Press [q] to stop, [?] for help
[mp4 @ 0x7f816101b400] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[libx264 @ 0x7f8161017e00] using SAR=1/1
[libx264 @ 0x7f8161017e00] MB rate (82800000) > level limit (16711680)
[libx264 @ 0x7f8161017e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f8161017e00] profile High, level 6.2, 4:2:0, 8-bit
[libx264 @ 0x7f8161017e00] 264 - core 160 r3011M cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=11 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x7f816101b400] 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 -- 
[aac @ 0x7f8161808e00] Qavg: nan
Conversion failed!
./ffmpeg -v 9 -loglevel 99 -i bunny_with_cover.mp3
ffmpeg version N-99744-g343c3149ab Copyright (c) 2000-2020 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.2)
  configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid --samples=fate-suite
  libavutil      56. 60.100 / 56. 60.100
  libavcodec     58.112.100 / 58.112.100
  libavformat    58. 63.100 / 58. 63.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 88.100 /  7. 88.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-i' ... matched as input url with argument '/Users/naktinis/data/audio/bunny_with_cover.mp3'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input url /Users/naktinis/data/audio/bunny_with_cover.mp3.
Successfully parsed a group of options.
Opening an input file: /Users/naktinis/data/audio/bunny_with_cover.mp3.
[NULL @ 0x7ffcc3808200] Opening '/Users/naktinis/data/audio/bunny_with_cover.mp3' for reading
[file @ 0x7ffcc3605340] Setting default whitelist 'file,crypto,data'
Probing mp3 score:12 size:2048
Probing mp3 score:12 size:4096
Probing mp3 score:12 size:8192
Probing mp3 score:12 size:16384
Probing mp3 score:12 size:32768
Probing mp3 score:51 size:29600
[mp3 @ 0x7ffcc3808200] Format mp3 probed with size=65536 and score=51
id3v2 ver:3 flags:00 len:35926
[mp3 @ 0x7ffcc3808200] pad 576 792
[mp3 @ 0x7ffcc3808200] Skipping 0 bytes of junk at 36353.
[mp3 @ 0x7ffcc3808200] Before avformat_find_stream_info() pos: 36353 bytes read:65536 seeks:0 nb_streams:2
[mjpeg @ 0x7ffcc400d000] marker=d8 avail_size_in_buf=35772
[mjpeg @ 0x7ffcc400d000] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x7ffcc400d000] marker=e0 avail_size_in_buf=35770
[mjpeg @ 0x7ffcc400d000] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x7ffcc400d000] marker=fe avail_size_in_buf=35752
[mjpeg @ 0x7ffcc400d000] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x7ffcc400d000] marker=db avail_size_in_buf=35734
[mjpeg @ 0x7ffcc400d000] index=0
[mjpeg @ 0x7ffcc400d000] qscale[0]: 6
[mjpeg @ 0x7ffcc400d000] marker parser used 67 bytes (536 bits)
[mjpeg @ 0x7ffcc400d000] marker=c4 avail_size_in_buf=35665
[mjpeg @ 0x7ffcc400d000] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x7ffcc400d000] marker=c0 avail_size_in_buf=35489
[mjpeg @ 0x7ffcc400d000] Changing bps from 0 to 8
[mjpeg @ 0x7ffcc400d000] sof0: picture: 640x360
[mjpeg @ 0x7ffcc400d000] component 0 2:2 id: 0 quant:0
[mjpeg @ 0x7ffcc400d000] component 1 1:1 id: 1 quant:0
[mjpeg @ 0x7ffcc400d000] component 2 1:1 id: 2 quant:0
[mjpeg @ 0x7ffcc400d000] pix fmt id 22111100
[mjpeg @ 0x7ffcc400d000] Format yuvj420p chosen by get_format().
[mjpeg @ 0x7ffcc400d000] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x7ffcc400d000] escaping removed 125 bytes
[mjpeg @ 0x7ffcc400d000] marker=da avail_size_in_buf=35470
[mjpeg @ 0x7ffcc400d000] marker parser used 35345 bytes (282760 bits)
[mjpeg @ 0x7ffcc400d000] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x7ffcc400d000] decode frame unused 0 bytes
[mp3 @ 0x7ffcc3808200] demuxer injecting skip 1105 / discard 0
[mp3float @ 0x7ffcc4008200] skip 1105 / discard 0 samples due to side data
[mp3float @ 0x7ffcc4008200] skip 1105/1152 samples
[mp3 @ 0x7ffcc3808200] All info found
[mp3 @ 0x7ffcc3808200] stream 0: start_time: 0.0250567 duration: 10.031
[mp3 @ 0x7ffcc3808200] stream 1: start_time: 0.0250556 duration: 10.031
[mp3 @ 0x7ffcc3808200] format: start_time: 0.025056 duration: 10.031 (estimate from stream) bitrate=156 kb/s
[mp3 @ 0x7ffcc3808200] After avformat_find_stream_info() pos: 57857 bytes read:65536 seeks:0 frames:51
Input #0, mp3, from '/Users/naktinis/data/audio/bunny_with_cover.mp3':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Lavf58.45.100
  Duration: 00:00:10.03, start: 0.025056, bitrate: 156 kb/s
    Stream #0:0, 50, 1/14112000: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.91
    Stream #0:1, 1, 1/90000: Video: mjpeg (Baseline), 1 reference frame, yuvj420p(pc, bt470bg/unknown/unknown, center), 640x360 [SAR 1:1 DAR 16:9], 0/1, 90k tbr, 90k tbn, 90k tbc (attached pic)
    Metadata:
      comment         : Other
Successfully opened the file.
At least one output file must be specified
[AVIOContext @ 0x7ffcc3605500] Statistics: 65536 bytes read, 0 seeks

Attachments (2)

bunny_with_cover.mp3 (192.2 KB ) - added by naktinis 12 months ago.
ffmpeg-20201026-110629.log (10.0 KB ) - added by naktinis 12 months ago.

Download all attachments as: .zip

Change History (3)

by naktinis, 12 months ago

Attachment: bunny_with_cover.mp3 added

by naktinis, 12 months ago

Attachment: ffmpeg-20201026-110629.log added

comment:1 by mkver, 6 months ago

Resolution: invalid
Status: newclosed

The reason for the behaviour you are observing is that the video stream's disposition is "attached pic" when demuxing from the mp3, but not when you are demuxing it from jpeg (the disposition gets lost when muxing into jpeg). When muxing a stream with disposition "attached pic" into mp4, only a few image codecs are allowed (by our muxer, wouldn't be surprised if the format allowed more), H.264 is not among them, leading to the error message.
You can unset the disposition by adding "-disposition:v -attached_pic" to your commandline.

Note: See TracTickets for help on using tickets.