Opened 12 months ago

Closed 12 months ago

Last modified 8 months ago

#10375 closed defect (duplicate)

Cannot copy mkv cover art

Reported by: yumu Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mkv matroska coverart attachment
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
The mkv cover art is not copied as an attachment, but as a video.
I think it's a mkv (matroska) problem because the cover art of the avi, mov, mp4 container copied successfully.

How to reproduce:

  1. Create a mkv with cover art. (or an existing one)
    ffmpeg -f lavfi -i smptehdbars=d=2 -f lavfi -i sine=d=2 ".mkv"
    ffmpeg -i ".mkv" -ss 0 -frames:v 1 ".png"
    ffmpeg -i ".mkv" -attach ".png" -c copy -metadata:s:t mimetype="image/png" -metadata:s:t:0 filename="cover.png" "with-cover.mkv"
    
  2. Copy
    > ffmpeg -i "with-cover.mkv" -c copy -map 0 "with-cover_copied.mkv"
    ffmpeg version N-110654-g63767b79a5-20230518 Copyright (c) 2000-2023 the FFmpeg developers
      built with gcc 12.2.0 (crosstool-NG 1.25.0.152_89671bf)
      configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --disable-libmfx --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20230518
      libavutil      58.  7.100 / 58.  7.100
      libavcodec     60. 14.100 / 60. 14.100
      libavformat    60.  5.100 / 60.  5.100
      libavdevice    60.  2.100 / 60.  2.100
      libavfilter     9.  8.100 /  9.  8.100
      libswscale      7.  2.100 /  7.  2.100
      libswresample   4. 11.100 /  4. 11.100
      libpostproc    57.  2.100 / 57.  2.100
    Input #0, matroska,webm, from 'with-cover.mkv':
      Metadata:
        ENCODER         : Lavf60.5.100
      Duration: 00:00:02.01, start: 0.000000, bitrate: 59 kb/s
      Stream #0:0: Video: h264 (High), yuv420p(tv, bt709/unknown/unknown, progressive), 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1k tbn
        Metadata:
          ENCODER         : Lavc60.14.100 libx264
          DURATION        : 00:00:02.003000000
      Stream #0:1: Audio: vorbis, 44100 Hz, mono, fltp
        Metadata:
          ENCODER         : Lavc60.14.100 libvorbis
          DURATION        : 00:00:02.013000000
      Stream #0:2: Video: png, rgb24(pc, gbr/unknown/unknown), 320x240 [SAR 1:1 DAR 4:3], 90k tbr, 90k tbn (attached pic)
        Metadata:
          filename        : cover.png
          mimetype        : image/png
    Output #0, matroska, to 'with-cover_copied.mkv':
      Metadata:
        encoder         : Lavf60.5.100
      Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(tv, bt709/unknown/unknown, progressive), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 25 fps, 25 tbr, 1k tbn (default)
        Metadata:
          ENCODER         : Lavc60.14.100 libx264
          DURATION        : 00:00:02.003000000
      Stream #0:1: Audio: vorbis (oV[0][0] / 0x566F), 44100 Hz, mono, fltp
        Metadata:
          ENCODER         : Lavc60.14.100 libvorbis
          DURATION        : 00:00:02.013000000
      Stream #0:2: Video: png (MPNG / 0x474E504D), rgb24(pc, gbr/unknown/unknown), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 90k tbr, 1k tbn (attached pic)
        Metadata:
          filename        : cover.png
          mimetype        : image/png
    Stream mapping:
      Stream #0:0 -> #0:0 (copy)
      Stream #0:1 -> #0:1 (copy)
      Stream #0:2 -> #0:2 (copy)
    Press [q] to stop, [?] for help
    [out#0/matroska @ 0000023e8c559740] video:6kB audio:3kB subtitle:0kB other streams:0kB global headers:3kB muxing overhead: 52.075660%
    frame=   50 fps=0.0 q=-1.0 Lq=-1.0 size=      15kB time=00:00:01.99 bitrate=  61.4kbits/s speed= 695x
    

Then the cover art becomes just a video stream instead of an attachment.
In the output of step 2, stream #0:2 has "(attached pic)", but in the actual output of ffprobe, "DISPOSITION:attached_pic" is 0 and it seems to be a normal video stream.

When played back in VLC, the cover art is not displayed in "Media information" and "Track 2" is displayed in "Video Track".

Below is the output of ffprobe.

> ffprobe -hide_banner -show_streams "with-cover.mkv"
Input #0, matroska,webm, from 'with-cover.mkv':
  Metadata:
    ENCODER         : Lavf60.5.100
  Duration: 00:00:02.01, start: 0.000000, bitrate: 59 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709/unknown/unknown, progressive), 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1k tbn
    Metadata:
      ENCODER         : Lavc60.14.100 libx264
      DURATION        : 00:00:02.003000000
  Stream #0:1: Audio: vorbis, 44100 Hz, mono, fltp
    Metadata:
      ENCODER         : Lavc60.14.100 libvorbis
      DURATION        : 00:00:02.013000000
  Stream #0:2: Video: png, rgb24(pc, gbr/unknown/unknown), 320x240 [SAR 1:1 DAR 4:3], 90k tbr, 90k tbn (attached pic)
    Metadata:
      filename        : cover.png
      mimetype        : image/png
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=320
height=240
coded_width=320
coded_height=240
closed_captions=0
film_grain=0
has_b_frames=2
sample_aspect_ratio=1:1
display_aspect_ratio=4:3
pix_fmt=yuv420p
level=13
color_range=tv
color_space=bt709
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=progressive
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=25/1
avg_frame_rate=25/1
time_base=1/1000
start_pts=3
start_time=0.003000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
extradata_size=48
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:ENCODER=Lavc60.14.100 libx264
TAG:DURATION=00:00:02.003000000
[/STREAM]
[STREAM]
index=1
codec_name=vorbis
codec_long_name=Vorbis
profile=unknown
codec_type=audio
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=44100
channels=1
channel_layout=mono
bits_per_sample=0
initial_padding=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
extradata_size=3315
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:ENCODER=Lavc60.14.100 libvorbis
TAG:DURATION=00:00:02.013000000
[/STREAM]
[STREAM]
index=2
codec_name=png
codec_long_name=PNG (Portable Network Graphics) image
profile=unknown
codec_type=video
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=320
height=240
coded_width=320
coded_height=240
closed_captions=0
film_grain=0
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=4:3
pix_fmt=rgb24
level=-99
color_range=pc
color_space=gbr
color_transfer=unknown
color_primaries=unknown
chroma_location=unspecified
field_order=unknown
refs=1
id=N/A
r_frame_rate=90000/1
avg_frame_rate=0/0
time_base=1/90000
start_pts=0
start_time=0.000000
duration_ts=181170
duration=2.013000
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=1
DISPOSITION:timed_thumbnails=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:filename=cover.png
TAG:mimetype=image/png
[/STREAM]
> ffprobe -hide_banner -show_streams "with-cover_copied.mkv"
Input #0, matroska,webm, from 'with-cover_copied.mkv':
  Metadata:
    ENCODER         : Lavf60.5.100
  Duration: 00:00:02.09, start: 0.077000, bitrate: 58 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709/unknown/unknown, progressive), 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1k tbn (default)
    Metadata:
      ENCODER         : Lavc60.14.100 libx264
      DURATION        : 00:00:02.080000000
  Stream #0:1: Audio: vorbis, 44100 Hz, mono, fltp
    Metadata:
      ENCODER         : Lavc60.14.100 libvorbis
      DURATION        : 00:00:02.090000000
  Stream #0:2: Video: png (MPNG / 0x474E504D), rgb24(pc, gbr/unknown/unknown), 320x240 [SAR 1:1 DAR 4:3], 1k tbr, 1k tbn
    Metadata:
      FILENAME        : cover.png
      MIMETYPE        : image/png
      DURATION        : 00:00:00.077000000
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=320
height=240
coded_width=320
coded_height=240
closed_captions=0
film_grain=0
has_b_frames=2
sample_aspect_ratio=1:1
display_aspect_ratio=4:3
pix_fmt=yuv420p
level=13
color_range=tv
color_space=bt709
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=progressive
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=25/1
avg_frame_rate=25/1
time_base=1/1000
start_pts=80
start_time=0.080000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
extradata_size=48
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:ENCODER=Lavc60.14.100 libx264
TAG:DURATION=00:00:02.080000000
[/STREAM]
[STREAM]
index=1
codec_name=vorbis
codec_long_name=Vorbis
profile=unknown
codec_type=audio
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=44100
channels=1
channel_layout=mono
bits_per_sample=0
initial_padding=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/1000
start_pts=77
start_time=0.077000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
extradata_size=3315
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:ENCODER=Lavc60.14.100 libvorbis
TAG:DURATION=00:00:02.090000000
[/STREAM]
[STREAM]
index=2
codec_name=png
codec_long_name=PNG (Portable Network Graphics) image
profile=unknown
codec_type=video
codec_tag_string=MPNG
codec_tag=0x474e504d
width=320
height=240
coded_width=320
coded_height=240
closed_captions=0
film_grain=0
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=4:3
pix_fmt=rgb24
level=-99
color_range=pc
color_space=gbr
color_transfer=unknown
color_primaries=unknown
chroma_location=unspecified
field_order=unknown
refs=1
id=N/A
r_frame_rate=1000/1
avg_frame_rate=0/0
time_base=1/1000
start_pts=77
start_time=0.077000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:FILENAME=cover.png
TAG:MIMETYPE=image/png
TAG:DURATION=00:00:00.077000000
[/STREAM]

My ffmpeg is the Windows version downloaded from ​https://github.com/BtbN/FFmpeg-Builds/releases.
The detailed version is as output in step 2.

Change History (3)

comment:1 by mkver, 12 months ago

Resolution: duplicate
Status: newclosed

Duplicate of #2270, #4591. I have a patchset for this that I finally need to finish.

in reply to:  1 comment:2 by yumu, 12 months ago

I did not know this issue has been around that long. Sorry for the duplicate due to my lack of confirmation.
I hope it will be fixed.
Thank you mkver.

comment:3 by Tavish McEwen, 8 months ago

Is this also related to #7717?

Note: See TracTickets for help on using tickets.