Tagging mkv files with cover images?
Asked Answered
A

1

17

I found this screenshot which shows that you can add a cover image to an mkv file in a way that it is displayed as the icon of the file in the Windows explorer using Shark007+icaros. enter image description here
But these tools are messing with the system in a really bad way. A lot of people are having problems with it and I too very much regret that I've installed it. I'm really glad I got my Windows to boot again...

Anyway, how could I programmatically add a cover image to an mkv file?
And would I need to change something in the registry to make Windows display them?

I'm not neccessarely looking for code, I'm more looking for something like the format the cover needs to have and the byte at which I have to inject/insert/attach the image file and maybe a registry entry that would cause the tagged images to be displayed etc.

Ardellearden answered 7/12, 2015 at 15:39 Comment(0)
H
13

You can use the FFmpeg multimedia framework to attach an image as MKV metadata. More Windows builds can be found at Zeranoe.

Example CLI usage:

ffmpeg -i input.mkv -c copy -attach image.jpg -metadata:s:t \
mimetype=image/jpeg output.mkv
  • -c copy copy all streams in the source file without re-encoding
  • -attach image.jpg attach a JPEG image
  • -metadata:s:t mimetype=image/jpeg set the attachement MIME type

On *nix the same can be accomplished with MKVToolNix.

Ubuntu demo:

enter image description here


Programmatic approach:

  • use the ffmpeg C libraries to attach or replace the cover art
  • write a custom Shell Extension to read the MKV format and display the image attachement as thumbnail.
Howdoyoudo answered 10/12, 2015 at 9:52 Comment(7)
But does attaching an image mean that it is visible in the file explorer of Windows? Like on the screenshot.Ardellearden
I just tried it. It always displays the default icon on Windows (8.1). :/Ardellearden
Yeah, I already mentioned that tool in my question. And it is not an option for me. I'd really like to know what that tool does internally and how I could replicate it. I mean it's probably just some registry changes, right?Ardellearden
I actually don't want to use any third party tool for that. I also don't want to force my users to have codec packs installed etc.Ardellearden
Of course it is possible. The question is just, how? ;) And I wouldn't say that ffmpeg is the way. It surely is a way, but not really a programmatic solution. It's a workaround I could live with. But for making the Windows explorer display the covers, I definitely need a programmatic solution that doesn't involve running third party executables.Ardellearden
I said it's impossible in the sense of a simple registry modification like you asked. See the updated answer.Howdoyoudo
I used mkvtoolnix command method to attach the movie poster to mkv file. It basically copies the file and attaches the image I provide to a new file. But is there a way to add a poster image to the original mkv file (without making a copy)?Arielle

© 2022 - 2024 — McMap. All rights reserved.